0

In one of my categories there is a lot products that are out of stock. I want to redirect the products that are out of stock to the category page without Filter By mark

Ex: website/product1 -> website/category1/filter1

I want it instead to redirect to website/category1

I have done simply this action in the file :

app/code/local/MyWebsite/Redirect/Model/Observer.php

I have replaced this line

$_categoryUrl = $_category-getUrl().'/'.$urlKey ;

by this line

$_categoryUrl = $_category->getUrl()  ;

in this snippet of code

         $_redirect-setCreatedAt($this-getDatetime());
         $_redirect->save();
     }

    $_categoryUrl = $_category-getUrl()  ;
     Mage::app()->getResponse()-setHeader('X-Redirect', 'product-not-available')->setRedirect($_categoryUrl, $_redirectStatus);
 } else {
     Mage::app()->getResponse()-setHeader('X-Redirect', 'no-category')-setRedirect('/', $_redirectStatus);

But even It is visually correct It is incorrect; I should redirect by product but I did not understand what that means. Don't hesitate if you need any additional information.

Thanks in advance,

Your Answer

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

Browse other questions tagged or ask your own question.