0

How could i display the Featured Products / Products in default iphone Theme homepage in magento1.9.3? Please help!

I searched and tried the below steps but the featured products not displayed.

1)Create "featured" attributes under Catalog > Attributes 2) Create a new file app/code/local/FeaturedProduct/Catalog/Block/Product/Featured.php

    <?php class FeaturedProduct_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_Abstract
{

        $select = $read->select()
                        ->distinct(true)
                        ->from(array('cp'=>$categoryProductTable), 'product_id')
                        ->join(array('pei'=>$productEntityIntTable), 'pei.entity_id=cp.product_id', array())
                        ->joinNatural(array('ea'=>$eavAttributeTable))
                        ->where('pei.value=1')
                        ->where('ea.attribute_code="featured"');

        $res = $read->fetchAll($select);

        return $res;
    }
}
?>

3) Created the file app/design/frontend/default/iphone/template/catalog/product/featured.phtml

<?php $featured_products = $this->getFeaturedProducts(); ?>
<?php shuffle($featured_products); ?>
<div class="box recently" style="padding-left:15px; padding-right:15px;">
    <h3><?php echo $this->__('Featured Products') ?></h3>
    <div class="listing-type-grid  catalog-listing">
        <?php $_collectionSize = count($featured_products) ?>
        <table cellspacing="0" class="recently-list" id="product-list-table">
            <?php 
                $i=0; 
                foreach ($featured_products as $_res): ?>
                    <?php $_product = Mage::getModel('catalog/product')->load($_res['product_id']); ?>
                    <?php if ($i++%3==0): ?><tr><?php endif ?>
                    <td>
                        <div>
                            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
                                <img class="product-image" src="<?php echo $this-/>helper('catalog/image')->init($_product, 'small_image')->resize(135, 135); ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" />
                            </a>
                        </div>
                        <p>
                            <a class="product-name" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>)"><?php echo $this->htmlEscape($_product->getName()) ?></a>
                        </p>
                        <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                    </td>
                    <?php if ($i%3==0 && $i!=$_collectionSize): ?></tr><?php endif ?>
                <?php endforeach ?>

                <?php for($i;$i%3!=0;$i++): ?>
                    <td class="empty-product">&nbsp;</td>
                <?php endfor ?>
                <?php if ($i%3==0): ?>&nbsp;<?php endif ?>
        </table>
        <script type="text/javascript">decorateTable('product-list-table')</script>
    </div>
</div>

4) Created a block with name "iphone-feature-product" in Cms >Static Blocks and added the below code.

{{block type="catalog/product_featured" name="product_featured" as="product_featured" template="catalog/product/featured.phtml}}

5) Insert the block in the file app/design/frontend/default/iphone/template/catalog/navigation/top.phtml

<?php echo Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('iphone-feature-product')->toHtml(); ?>

I have tried the above steps to display the featured product but it not works. Please anybody could help how could i do it or what wrong i have made.

Thanks in advance!!

  • It depends what you are after, is it a list of featured products you define, best selling, latest? – pip Jun 21 '17 at 12:43
0

Create on category in admin and keep it invisible after that assign products to that category and from that category id using phtml file call it on home page. in that phtml file write a logic call get products of that category only.

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.