adampmoss / CreareSEO

A free SEO extension for Magento 1
GNU General Public License v2.0
151 stars 72 forks source link

Product redirect don't work #137

Closed Zenpytory closed 6 years ago

Zenpytory commented 6 years ago

Hi,

Firstly I want to say thank you for this useful free module! For some reason the redirects didn't work at us, none of them. I figured out where is the problem. The function "getDiscontinuedProductUrl" at line 11 in "Helper/Data.php" got empty product object from "discontinuedCheck" at line 80 in "Model/Observer.php".

I fixed it temporarily in "Model/Observer.php" around line 90.:

`public function discontinuedCheck($observer) { ... if ($request->getControllerName() === "product") {

        /*$product = Mage::getResourceModel('catalog/product_collection')
            ->addAttributeToSelect('creareseo_discontinued')
            ->addAttributeToSelect('creareseo_discontinued_product')
            ->addAttributeToSelect('name')
            ->addIdFilter($request->getParam('id'))
            ->setPageSize(1)
            ->getFirstItem();
        */

    // Temporary fix
    $product= Mage::getModel('catalog/product')->load($request->getParam('id'));

        if ($discontinuedUrl = $this->helper->getDiscontinuedProductUrl($product)) {
            $this->redirect301($discontinuedUrl, $product->getName());
        }
    }
 ...
}`

Unfortunately at now I have no time to further investigations and I don't know that is category redirects working or not, I just made a quick hotfix now, maybe this helps someone.

Magento CE 1.9.3.4

sprankhub commented 6 years ago

I guess you are using flat tables, so it is the same issue as in https://github.com/adampmoss/CreareSEO/pull/133.

Zenpytory commented 6 years ago

I checked, you are right, it's fixed my problem.

Thank you!