We currently have Magento setup to "use categories path for product URLs", this ensures the category url key is applied in-between the domain and product key.

Working correct URL


It works perfectly however when you search for products using the "quick search" the product links on the resulting page do not have the category key in them and hence the product links do not work?

Not working incorrect URL search page


How can I change the quick search result page to use the categories path in the product URLs?

  • 3
    Given that a product can be placed in multiple categories, how would search determine which category to use in the link? Jan 2, 2015 at 14:38
  • Well in this example they'd only be in 1 category.
    – Dan
    Jan 22, 2015 at 17:04
  • Like Cags told you the category is not selected so the normal url came as output. But if you enable "Use Canonical Link Meta Tag For Products" at the backend you hopefully get teh crawler to the correct site
    – daim2k5
    Feb 6, 2015 at 20:03

1 Answer 1


The category path is added based on the registry value for current_category. Since there is none on search it doesn't add a category.

In order to get this to work you wold need to overwrite the class Mage_Catalog_Model_Product_Url method getCategoryId to fall back on the products assigned categories when no category is registered.

It would look something like this

   public function getCategoryId()
      if ($category = Mage::registry('current_category')) {
         return $category->getId();
      } else {
         $categories = $product->getCategoryIds();
         return count(categories) ? reset(categories) : false ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.