0

I'm trying to add a product slider at my website's home page. I have tried using almost all the {{block type="catalog/xxxxx"}} but I cannot get it to display ALL PRODUCTS in the home page's content.
I know it's possible to get New products or Featured Products, but having all of them in a single slider doesn't seem to work. I have spent hours now trying to achieve this. Any help would be greatly appreciated!

Note: I have previously been able to achieve this but the code doesn't work anymore! I'm using Ultimo theme by Rainforest, if it helps!

EDIT:
I've also tried using the below

{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}

but this causes the HTML code to break and results in the content below the homepage (i.e footer, link etc to disappear).

4
  • post your code. Commented Sep 8, 2015 at 13:53
  • {{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}} Even this doesn't work, I believe it should but it only breaks my page and the footer disappears. The only thing I see on the page is the Header and the slideshow Commented Sep 8, 2015 at 13:57
  • Turn on error displaying and check magento adn apache logs for errors Commented Sep 8, 2015 at 14:32
  • How would I do that? Commented Sep 8, 2015 at 14:34

1 Answer 1

1

you need to create your own module and inside it create this block

<?php
class [Namespace]_[Module]_Block_Product_All extends Mage_Catalog_Block_Product_List
{
    protected function _getProductCollection()
    {
        if (is_null($this->_productCollection)) {
            $collection = Mage::getResourceModel('catalog/product_collection')
                ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
                ->addAttributeToFilter('status', 1)
                ->addAttributeToFilter(array(array('attribute'=>'visibility', 'in'=>"2,3,4")));
            $this->_productCollection = $collection;
        }
        return $this->_productCollection;
    }
}

Then create the template app/design/frontend/base/default/template/[namespace]_[module]/product/all.phtml where you place your markup.
Something like this (will require styling):

    <?php 
    $products = $this->getLoadedProductCollection();
    foreach ($products as $product) : ?>
        <div>
            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
            <?php // Product description ?>
            <div class="product-shop">
                <div class="f-fix">
                    <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
                    <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
                    <?php if($_product->getRatingSummary()): ?>
                    <?php echo $this->getReviewsSummaryHtml($_product) ?>
                    <?php endif; ?>
                    <?php echo $this->getPriceHtml($_product, true) ?>
                    <?php if($_product->isSaleable()): ?>
                        <p><button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>
                    <div class="desc std">
                        <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
                        <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
                    </div>
                </div>
            </div>
        </div>
    <?php endforeach;?>

now you can use it in your homepage like this

{{block type="[block_alias]/product_all" template="[namespace]_[module]/product/all.phtml"}}
2
  • I really appreciate your effort in answering my question. However, like my question suggests, I have been able to do this before using just the {{block....}}. But, it wouldn't work anymore? Do you have any ideas why? Commented Sep 8, 2015 at 14:05
  • @NavikGoswami. I don't...If I did, I wouldn't have written a full book as an answer.
    – Marius
    Commented Sep 8, 2015 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.