/** * Normally this methods check to see whether the product is configured * to be visible on the frontend. We're overloading that so that * the product will actually show up as long as the url hash key * is correct. * * @param int|Mage_Catalog_Model_Product $product * @param string $where * @return bool */ public function canShow($product, $where = 'catalog') { if ($this->_validateUrlHash()) { return true; } return parent::canShow($product, $where); }
/** * @magentoDataFixture Mage/Catalog/_files/products.php */ public function testCanShow() { // non-visible or disabled $product = new Mage_Catalog_Model_Product(); $this->assertFalse($this->_helper->canShow($product)); // enabled and visible $product->setId(1); $product->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED); $product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH); $this->assertTrue($this->_helper->canShow($product)); $this->assertTrue($this->_helper->canShow(1)); }
function canShow($product, $where = 'catalog') { $isVisible = parent::canShow($product, $where); if (!$isVisible && Mage::app()->getRequest()->getParam('pid') > 0) { $product = Mage::getModel('catalog/product')->load(Mage::app()->getRequest()->getParam('pid')); foreach ($product->getTypeInstance(true)->getUsedProducts(null, $product) as $childProduct) { $childIds[] = $childProduct->getId(); } if (in_array(Mage::app()->getRequest()->getParam('id'), $childIds)) { $isVisible = true; } } return $isVisible; }