404 error when switching between stores when in a category on magento - magento

My magento website has 5 store views. When we are in a product in English and select French, it redirects correctly and show the product in French. But when it comes to categories, it doesn't work at all.
I'm on a category with the url http://myweb.com/en/body-care, if I change to the Spanish view, it doesn't redirect to the url "../cuidado-del-cuerpo" it just goes to to http://myweb.com/es/body-care and shows a 404 error (it changes the 'en' for 'es', but doesn't change the last part of the url).
The rewrite is not defined on the URL Rewrite Management section. I have 5 categories and 5 store views, so it's not a good idea to create the rewrites rules manually.
How can I solve this? Why the rewrite rules were not written when we created/modified the url of each category?

1) Can you check if the urlkey is definable on store view level, or if it is set to website level? That way, you can only create 1 url key for EN and ES. You need it to be at store view level, do define 2 separate values.
2) Is there something in your error log? (and is your error log turned on?) Normally url rewrites are created automatically for each store view. If not, you may need to manually reindex.
It's hard to give further advice, since the problem could be anywhere (conflicting module? bad code?)

Related

Change to magento indexer process

I need to make product urls like this "attribute1/attribute2/product-url-key" dynamically. I've found that the urls of every product are in the enterprise_url_rewrite table, request path field.
I would like to make change to the indexer process as well, so the changes will stay when its rerun, but I don't know where it is?
Good afternoon! Let's break this down:
I need to make product urls like this "attribute1/attribute2/product-url-key" dynamically
Yes - you can create URL rewrites dynamically using the Magento models that represent the database table you've identified already:
/** #var Enterprise_UrlRewrite_Model_Redirect $rewrite */
$rewrite = Mage::getSingleton('enterprise_urlrewrite/redirect');
// Create new record or load the existing one
$rewrite->loadByRequestPath($requestUrl, $store->getId());
$rewrite
->setStoreId($store->getId()) // define which store the rewrite should be
->setOptions(null) // specify any rewrite/redirect/custom options
->setRequestPath($requestUrl) // specify the request URL
->setIdentifier($requestUrl)
->setTargetPath($targetPath) // specify the redirect target
->setEntityType(Mage_Core_Model_Url_Rewrite::TYPE_CUSTOM)
->setDescription('Add a comment if you want to');
$rewrite->save();
This will attempt to load an existing URL rewrite/redirect by the $requestUrl and will return an empty model if it was not found which you can embellish with your data and save.
The "options" define whether it's a temporary or permanent redirect (302 vs 301).
More information here via the Magento EE user guide.
I would like to make change to the indexer process as well, so the changes will stay when its rerun, but I don't know where it is?
Don't worry about it. The (modern) Magento database has table triggers wherever records need to be indexed, and will detect creations, updated and deletions on those tables. The indexers will detect that change need to be made and will make them for you as required.
If you're seeing URL rewrites disappearing it's most likely because you've been adding them directly to the index table with SQL, so the table is rewritten whenever the indexer runs. To avoid this use the model as noted above and everything will be saved into the correct location and indexed properly.

Magento appending '-1' in Category URL Key in frontend

Magento is appending '-1' only to certain categories URL key despite not being defined by us like that in backend.
Eg. if URL key for category 'sample' is 'sample' .. in frontend its showing as '/sample-1'
It's not the case with all categories but 2 or 3 that too in desktop version alone. It's working fine in mobile version. What could be the issue?
There are few things that can cause this.
Duplicate Categories trying to use the same URL, upon reindex Magento will auto increment these values. To the next higher integer.
It's sometimes easy to miss.
Say you have the category "shoes" as a subcategory of "women"
The URL key created automatically for this category would be "/shoes"
Now say you have the category "shoes" as a subcategory of "men"
This category would automatically have the url key of "shoes" however because it already exists Magento will auto increment this key to "shoes-1"
Under a multi-store instance of Magento, you also can't have two categories with the same url keys even if they are part of different stores.
Additionally, Magento Enterprise 1.13 has a whole different problem with auto increments of URL Ids
What version of Magento are you running and is it a multi-store platform? I can provide further assistance from there.

Why does a category have a weird path defined in the Magento database?

My catalog_category_entity table has an entry for a category that does not appear anywhere in the admin area of the site, or in the front end.
It has a weird path: "/30" (30 is its entity_id). Every other category in every other Magento site I have access to starts its path with a number, not a slash.
It has entries through the rest of the EAV system in various places.
My suspicion is that someone ran a bad import, or other manual process, which left this category in the database, when really it should have been simply deleted.
Is this an anomaly, or is there a reason for this category to have a weird path?
Your suspicion is right. Most probably this is due to a bad import. Normally all paths look like this: 1/2/5/17. The path represents the ids of the categories starting from "root of all roots" (1) and continuing with all the parents and last is the category id. The path is used for displaying the categories in frontend and backend. That's why the category does not appear in any list.
If you have data on that category and you need it, just edit the path field and make it 1/2/30. 2 is the id of the root catalog so it may be different for you.
Then just increment the field children_count for the categories with id 1 and 2.
Back-up your db before trying this.

Magento website, store en store view names - can they be changed?

In our magento shop we have about 8 websites, for some websites 3 store views. Some of the website and store view names are not meaningful, and I would like to change them.
So basically my question are:
What happens if I change the website name of an existing website?
What happens if I change the store name of an existing store?
What happens if I change the store view name of an existing store view?
I'm not talking about the codes. I understand that they are used in the vhost/htaccess, and maybe somewhere else, so they should stay as they are.
If by name you mean the label of stores and websites, then nothing will happen. It's a just a human friendly string. It is no used to load a store/website in Magento core. Only id and code are used.
However, I cannot guarantee that your custom modules also respect this rule.

Magento creating invoice redirect to wrong url

When I create an invoice from the order in the backend, this on this url:
http://www.site.com/index.php/safe/sales_order_invoice/new/order_id/4372/
But when the Invoice is about to be created it goes to:
http://www.site.com/shop/safe/sales_order/view/order_id/4372/
You see the (Shop), which is mostly correct because the storefront is named that(We had 2 storefronts once) If I remove the (Shop) part from the url, I'm getting back to the correct page and it shows that the invoice was correctly created. This only happens from the Order itself. If I use Mass action to create invoices from the orders list, it's not giving me any problems.
If anyone else has the problem (Using multi stores)
Please check your database, core_config_data and see if web/secure/base_url etc. is redirecting to the right path. And make sure to check that it's doing so for the right store ID that is giving you the trouble.
My problem was that the secure path for one of my stores, was ruining it.
All works fine now!

Resources