Setting Up Mage Featured Products in FrontEnd – Set Attribute – Part 2

Here we will continue the setup for Mage Featured products. Also a responsive Magento home page with featured products can do the trick for any seller. After setting up properties for attributes. Next we will add the product attribute in to the attribute set.

However with a responsive theme and a stylish template you can make your Magento Home page more attractive. Our hosting has dedicated servers for the Mage platform and comes with all the software and installation support you could need. As experts, you’ll have only 7 secs to convert a client in to a customer. So, our cloud SSD storage and CDN service ensures fast loading of your Magento Home page. Next you’ll get all of these premium service absolutely free with our hosting plans. Our basic plan starts at $9.99 per month. So feel free to contact us Now!!!

Tanzia Farin Chy – Aspiration Hosting

Managing the attribute set

For adding the product Attribute under Attribute sets go to Catalog from the admin panel. Next find the Attribute and navigate to Manage Attribute sets.

Now we can see our featured product attribute is displaying as “Unassigned Attribute”. Rather a unique name was picked for the attribute. So, pick the Attribute from the Right hand side of the Screen. Next, Drag and Drop the attribute in “Groups” under the “General tab”. Generally the groups are on the left hand side of screen. Further click to “Save Attribute Set” for saving the new Attribute set.

magento home page

Creating Magento Home Page Block

Next we need to create a block for featured products. For creating a block file log into the cPanel. Next using the File Manager navigate through Local DIR (app/code/local). Now create a Directory. Next create a DIR level (Featured Product/Catalog/Block/Product/Featured.php). Hence, following are the codes for creating a Featured.php file.

<?php

class FeaturedProduct_Catalog_Block_Product_Featured extends Mage_Catalog_Block_Product_Abstract {

    public function getFeaturedProduct() {

//database connection object

        $storeId               = Mage::app()->getStore()->getId();

        $resource              = Mage::getSingleton( 'core/resource' );

        $read                  = $resource->getConnection( 'catalog_read' );

        $categoryProductTable  = $resource->getTableName( 'catalog/category_product' );

        $productEntityIntTable = (string) Mage::getConfig()->getTablePrefix() . 'catalog_product_entity_int';

        $eavAttributeTable     = $resource->getTableName( 'eav/attribute' );

// Query for featured product

        $select = $read->select()

                       ->from( array( 'cp' => $categoryProductTable ) )

                       ->join( array( 'pei' => $productEntityIntTable ), 'pei.entity_id=cp.product_id', array() )

                       ->joinNatural( array( 'ea' => $eavAttributeTable ) )

                       ->where( 'pei.value=1' )

                       ->where( 'ea.attribute_code="featured"' );

        $row    = $read->fetchRow( $select );

        return Mage::getModel( 'catalog/product' )->setStoreId( $storeId )->load( $row['product_id'] );

    }

}

Here we will request you to continue to Part 3 to complete the setup. So, Let’s go to the final part!

Go Back Part 1 | Currently Viewing Part 2 | Go to Part 3