php - Magento product rediret issue
Get the solution ↓↓↓I have recently changed our Magento 1.8 store to including category path in product URL to excluding.
We now have some 404 error issues. I am not sure if its related or a seperate issue altogether...
We have recently cleaned up some of our discontinued product by removing the products from all categories and changing 'catalog,search' to just 'catalog'. We have also included an out of stock message on these pages.
Previously (before turning off catalog path product URLs) we would have the below url.
www.website.com/t-shirts/mens-black-t-shirt.html
Now when we have removed this product from its associated category this URL is giving 404 error in our Google webmaster dashboard
This URL works www.website.com/mens-black-t-shirt.html
If we add the product back to 't-shirts' category and then visit the URL including the category path then it does not return 404 error any more. Shouldn't magento be redirecting when a product is removed from category?
We have always had selected Create Permanent Redirect for URLs if URL Key Changed > Yes
Any help appreciated on this.
Thanks
Answer
Solution:
Problem will probably solved if you re-indexcatalog_url (Catalog URL Rewrites)
If you still face problem then run following MySQL query to the database you are using for your magento store.TRUNCATE table core_url_rewrite;
When you are done with above query. Do re-indexcatalog_url (Catalog URL Rewrites)
.
I'm sure problem will be resolved.
[Reason:- when you unassigned your item from the category, a record of the urlwww.website.com/t-shirts/mens-black-t-shirt.html
presents in the tablecore_url_rewrite
so either re-index or delete record manually]
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: attempt to read property "id" on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.