0

I created one custom back-end module and admin can add products id in the back-end with comma separated , so how can I display that products on home page which is admin add in the back-end.

Here is my productlisting.phtml file

$collection1 = Mage::getModel('catalog/product')->getCollection()->getAllIds();
        echo "<pre>";
        //print_r($collection1);
        echo "</pre>";
        $collection = Mage::getModel('productlisting/productlisting')->getCollection();
        foreach($collection as $date_to){
            if($date_to == $collection1)
        //  print_r($date_to->getProductId());
                $date_to->getLimit();
            //  print_r ($date_to->getLimit());
    //  var_dump($date_to->getProductId());
            echo "<br>";
            //print_r($date_to->getDateTo());
        }  
  • Are you using cms/page to manage home page content? – dat.tran May 8 '17 at 6:56
  • no i am using xml layout file – H_Parekh May 8 '17 at 6:59
1

A. First create your own Module on "local" code pool.

This module will contains product collection with your own conditions.

For example,

class Mymodule_Myblock_Block_Product_Category_List extends Mage_Catalog_Block_Product_Abstract
{
    protected function _getCollection()
    {
        /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
        $collection = Mage::getResourceModel('catalog/product_collection');

        $collection = $this->_addProductAttributesAndPrices($collection)
            ->setStoreId(Mage::app()->getStore()->getId())
            ->addStoreFilter()
            ->addCategoryFilter(Mage::getModel('catalog/category')->load($this->_categoryId));

        // filter by visible and status
        Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);

        $collection->load();

        return $collection;
    }
}

You can add some own conditions or filter for product collection.

B. Go to Admin panel, CMS > Page > Edit Home Page > Content.

Add below code to call out the block.

{{block type="mymodule_myblock/product_category_list" template="mymodule/myblock/product/list.phtml" categoryId="1" title="New Products"}}

Also, you need to go to Permission > Blocks to add block name for white list.

*** This is just a simple example, you can add more different parameters to block/product collection to achieve your own Module more user-friendly.

0

If you are using cms/page to modify homepage content

  • You can search for how to create widget in magento. (to do show product you wish)
  • In cms/page,you edit homepage. At content tab you insert the widget to homepage via wysiwyg panel

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.