0

I have a major problem with this one. Basically when i try to click on product link that is generated from custom product collection (i mean filtered). It SOMETIMES gives me 404 page. The URL is correct. I don't know how to even debug this thing. It's really bumming me out. This is my filtered collection class:

class Mage_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_Abstract {

public function __construct() {
    parent::__construct();
    $products = Mage::getModel('catalog/product')->getCollection()
                    ->addAttributeToSelect('*')
                    ->addAttributeToFilter('featured',array('eq' => 1))
                    ->addAttributeToFilter('status', array('eq' => 1))
                    ->setPageSize(4)->setCurPage(1)
                    ->setStore(Mage::app()->getStore()->getStoreId());

    $this->setProductCollection($products);
}

More importantly 404 page shows up not all times. Is this some rewrite problem? Because i can open product 100 times and it will open up. But then after some time doing nothing on the page and then click the product it gives me 404 page. That is really really weird..

I'm getting url like this:

$_product->getProductUrl()

Is there a way to fix this? I don't know what i'm doing wrong here. Please help.

1

The products giving 404 error may have set visibility to Not display individually i.e they are associated products and not available to sale individually.

To filter your collection with visibility and Salable product use below code-

Visibility Filter

$product->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);

Salable Filter

Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($product);
  • You may be understanding my question wrong. Because 404 is popping up SOMETIMES that means not all times. If products would be not visible individually 404 would pop up every time. Do you have any more ideas? – Žygimantas Baranauskas Dec 30 '16 at 8:30

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.