Pregunta

I have the following code which shows 4 random products in the homepage, however its also showing sometimes out of stock products, how can I avoid that?

We want to show out of stock products on our website everywhere, except in the homepage.

{{block type="catalog/product_list" category_id="108" template="catalog/product/list_home.phtml"}}

 $_helper = $this->helper('catalog/output');
 $_category = Mage::getModel('catalog/category')->load($this->getCategoryId());
 $_productCollection = Mage::getResourceModel('reports/product_collection')
                       ->addAttributeToSelect('*')
                       ->addCategoryFilter($_category)
                       ->setVisibility(array(2,3,4));
 $_productCollection->getSelect()->order(new Zend_Db_Expr('RAND()'));                  
 $_productCollection->setPage(1, 4);
¿Fue útil?

Solución

Luis Valencia

I think In magento you can create a Featured category for home page product. where you can shows only that product which is featured category. and you add there only in stock product

Its easiest way in magento showing a featured product.

How to create featured product in magento. http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/how_to_create_a_featured_product

foreach ($_productCollection as $_product)

then you can use $_product->isInStock() or $_product->isSaleable() function as if and else condition

Thanks

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top