2

I want to add the Featured product,Best Seller and New arrival in tab format. Means when I click on featured product the featured product slider get display, when click on best seller product then best seller product get display.Please can anyone suggest me suitable solution for it. Because I am new user of Magento. Should I need to create the custom extension. If yes then please give me steps to be followed.

  • what do you mean by featured product? – Mujahidh Sep 1 '15 at 9:51
  • Featured product is special type of category product which I want to show on Home page. – Ashwini Sep 1 '15 at 10:03
  • fine then you have to create a category.and retrieve product collection according to that category id.I will post you the answer. – Mujahidh Sep 1 '15 at 10:04
1

You can customize your product collection as you want in home home page

For Featured Products

Create you category(Featured Product) from back end and use that id in the collection. You can use your featured category id instead of #yourid

$productsCollection = Mage::getModel('catalog/product')
                ->getCollection()
                ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
                ->addAttributeToSelect('*')
                ->addAttributeToFilter('category_id', '#yourid')
                ->addAttributeToSort('created_at', 'desc')
                ->setPageSize(6);
    foreach ($productsCollection as $product):
        $_product   = Mage::getModel('catalog/product')->load($product->getId());

For Latest Products

$productsCollection = Mage::getModel('catalog/product')
                ->getCollection()
                ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
                ->addAttributeToSelect('*')
                ->addAttributeToSort('created_at', 'desc')
                ->setPageSize(6);
    foreach ($productsCollection as $product):
     $_product  = Mage::getModel('catalog/product')->load($product->getId());
       **What ever prodcut details you want to view**
    endforeach;

For Most Viewed Prodcuts

<?php 
    $productCount_mostviewd = 15; 
    // store ID
    $storeId    = Mage::app()->getStore()->getId();       
    // get most viewed products for current category
    $products_mostviewd = Mage::getResourceModel('reports/product_collection')
        ->addAttributeToSelect('*')     
        ->setStoreId($storeId)
        ->addStoreFilter($storeId)
        ->addViewsCount()
        ->addCategoryFilter(Mage::registry('current_category'))
        ->setPageSize($productCount_mostviewd); 
    Mage::getSingleton('catalog/product_status')
            ->addVisibleFilterToCollection($products_mostviewd);
    Mage::getSingleton('catalog/product_visibility')
            ->addVisibleInCatalogFilterToCollection($products_mostviewd);
foreach ($products_mostviewd as $product): $_product    = Mage::getModel('catalog/product')->load($product->getId());?>
endforeach;

For Best Selling Products

$storeId = Mage::app()->getStore()->getId();
    $products = Mage::getResourceModel('reports/product_collection')
        ->addOrderedQty()
        ->addAttributeToSelect('*')
        ->addAttributeToSelect(array('name', 'price', 'small_image'))
        ->setStoreId($storeId)
        ->addStoreFilter($storeId)
        ->setOrder('ordered_qty', 'desc'); // most best sellers on top
    Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
    Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);

    $products->setPageSize(3)->setCurPage(1);
    $this->setProductCollection($products);

You can use this collection. notice that setPageSize(5) is help retrieve n number of products in your collection.

  • For adding above code should I follow the steps for creating custom module..?code.tutsplus.com/tutorials/…, as I m new user of Magento – Ashwini Sep 1 '15 at 10:22
  • Please can you text me here which steps should I follow..if me not wrong.. – Ashwini Sep 1 '15 at 10:25
  • i just suggest you the algorithms for getting the product collection for each category(featured, latest, best selling).You can customize the home page listing with this algorithms by adding any slider or tabs according to your need.For the home page listing purpose no need to create any modules. – Mujahidh Sep 1 '15 at 10:25
  • you can get idea from blog.amasty.com/… – Mujahidh Sep 1 '15 at 10:32
  • I am adding the bestseller product as per link :blog.amasty.com/… on home page it just showing lable Bestseller but not displaying product list below that..how should I overcome this..? – Ashwini Sep 1 '15 at 11:36

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.