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

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.

Related

Magento FPC and $_SESSION object

How to use a cache when you have content depending on SESSION variable?
Does it work with Varnish-like cache? Does it require FPC?
let me explain.
My customers can select their model of Car (manufacturer, model, year), once selected this is stored in SESSION object.
(Of course every product is linked to a list of Cars in the back end.)
The thing is, on the frontend, There is a module that automatically filters the products according to the Car selected by the customer.
I'm not only talking about a user that would search for a product by entering a keyword on the search bar.
I'm also talking about the category pages.
When the customer visits the website, clicking on a category, then the list of products within this category is filtered too!
So while the customer navigates, he only see compatible products with his car.
I failed to use VARNISH because of this (VARNISH is based on url only, and the selected Car is not part of every url...).
That's why I'm wondering if there is any concept of Cache that would take into account SESSION variables?
thanks,
Rod

How do you query the category id or name in Opencart 1.5.5.1 Joomla 3.3.0

So I am modifying a module and I've successfully queried the product ID. So if I am browsing products and go into the product details page, I can see my product ID using
JRequest::getInt('product_id');
but for some reason I cannot get the category ID. I've tried.
JRequest::getInt('category_id');
and it always comes out to zero no matter what category I go to. Anyone else experience this? I could get it from the nonSEF url but there's gotta be another way. My goal is to basically query the category ID when I am browsing that category or if I am in the product details of a product.
I assume, you're using some OpenCart component for Joomla. In this case, you have to look into controller and model files for OpenCart. It's not THAT easy to get certain values sometimes, because these are 2 different engines.
In short, you may have to use VQMod for OpenCart, add category_id to data array and only then JRequest it. Solely depends on task.

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.

why magento using other product's url key for url rewrite

I am using magento 1.7. i am faceing strange problem. magento making duplicate product url with random number with wrong url key please my attached screenshot
I also empty table rewrite_urls and reindex urls but still i am getting wrong urls. please help me to solve this problem. if you are unable to view images in question then please click on links duplicate product urls and Product in admin panel
,
Let me make understand u with example
Like i have one product named "example" and url key is "example" Url will be
www.example.com/example
and now i have created new product "xyz and url key is "xyz" and url should be
www.example.com/xyz
but magento generating url
www.example.com/example-123
This seems to be a bug in 1.7.
If you have multiple simple products with the same url key as the configurable product (e.g. all names are the same), than magento always creates a new url rewrite on every index process.
Example:
First index:
myproducturl (config product)
myproducturl-id (simple product with its id appended, so far so good)
Second index:
myproducturl (config product)
myproducturl-randomnumber (simple product with random number, BAD)
myproducturl-id --> myproducturl-randomnumber (rewrite to the new url)
And on every new index process the last step will be repeated, so always a new random url key is generated.
If magento would check, that a url key with the id for that product already exists, this should be no problem.
After a few months, you will have a really big url_rewrite table, because nothing will be deleted and on every run, at least 1 record for every product with the same url key will be created.
I was able to eliminate the extra numbers at the end of the URLs by truncating the table "core_url_rewrites" (I made sure to make copy first) then reindexed it.

404 error when switching between stores when in a category on 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?)

Resources