Kriuchko
1/9/2019 - 11:17 AM

Latest products all product root products

Magento 1 latest products

{{block type="catalog/product_list" name="latest.products" template="impl/latest-products-list.phtml"}}

<?php
    $_productCollection = Mage::getResourceModel('catalog/product_collection');
    
    $_helper = $this->helper('catalog/output');
    
    if($_productCollection->count())
    {
        foreach($_productCollection as $item)
        {
            $_product = Mage::getModel('catalog/product')->load($item->getId());
            
            if($_product->getVisibility() != 1)
                $latest_products[] = $item->getId();
        }
    }
    $latest_products = array_reverse($latest_products);
    $count = 0;
?>
<?php if($_productCollection->count()): ?>
    <div class="section-box">
        <h2><?php echo $this->__('Latest products') ?></h2>
        <div class="gallery3">
            <a href="#" class="btn-prev">prev</a>
            <div class="gallery3-holder">
                <ul class="products-grid">
                <?php foreach ($latest_products as $item_id): $count++; if($count == 11) break; ?>
                    <?php $_product = Mage::getModel('catalog/product')->load($item_id); ?>
                    <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
                        <?php if($_helper->productAttribute($_product, $_product->getOffer(), 'offer')): ?>
                            <span class="offer">offer</span>
                        <?php endif ?>
                        <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(195,260); ?>" width="195" height="260" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
                        <div class="section-slide">
                            <div class="price-section">
                                <?php echo $this->getPriceHtml($_product, true) ?>
                            </div>
                            <div class="add-section">
                                <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
                                <div class="actions">
                                    <?php if($_product->isSaleable()): ?>
                                        <button type="button" title="<?php echo $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>
                                    <?php else: ?>
                                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                                    <?php endif; ?>
                                </div>
                                <ul class="add-to-links">
                                    <li><a href="#" class="link-learn">more info</a></li>
                                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                                        <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('add to wish list') ?></a></li>
                                    <?php endif; ?>
                                    <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                                        <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('add to compare') ?></a></li>
                                    <?php endif; ?>
                                </ul>
                            </div>
                        </div>
                    </li>
                <?php endforeach ?>
                </ul>
                <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
            </div>
            <a href="#" class="btn-next">next</a>
        </div>
    </div>
<?php endif; ?>