Magento has fields for a Product and Category to create custom SEO friendly URL keys. But when you have multiple stores, then you cannot normally have different URL keys for different stores because the field url_key is ‘GLOBAL’ by default. For products, you can update the url_key attribute’s is_default field to ‘Store Views‘ from Attribute Management. But for the category’s url_key field, you don’t have that option in Magento. But the field does exist in the database with the same attribute code but having different backend_model so you need to go to the database directly and change the ‘is_global’ field 1 to 0.
reference: http://www.devraju.com/magento/different-category-url-keys-for-different-store-views-in-magento/ see comments on the bottom of the page.
same issue here: Magento multilanguage - double change in language resuts in 404 (or how to change language within stores not views)
This strategy seems to work in older versions, but in 7.1 I am having trouble. When I go to Catalog >> Attributes >> Manage Attributes, the url_key attribute is already set to store view. See image below.
Furthermore the attribute table looks properly configured. See SQL below.
The Switching code looks like this:
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
SQLs
SELECT * FROM eav_attribute WHERE attribute_code LIKE '%url_key%';
attribute_id Attribute Id entity_type_id Entity Type Id attribute_code Attribute
Edit Delete 43 3 url_key catalog/category_attribute_backend_urlkey
Edit Delete 97 4 url_key catalog/product_attribute_backend_urlkey
SELECT attribute_id, is_global FROM catalog_eav_attribute WHERE attribute_id=43;
SELECT attribute_id, is_global FROM catalog_eav_attribute WHERE attribute_id=97;
Full Texts attribute_id Attribute ID is_global Is Global
Edit Delete 43 0
Full Texts attribute_id Attribute ID is_global Is Global
Edit Delete 97 0
I also tried to solve it using re-write rules, but re-write rules do not seem to cover language switching. ref: http://www.magentocommerce.com/wiki/modules_reference/english/mage_adminhtml/urlrewrite/index
i am looking for solution with appropriate code modifications.