Posts

Showing posts from September, 2012

Get best seller,newarrivals ,most viewed product collection

//Get most sold product collection <?php $visibility = array ( Mage_Catalog_Model_Product_Visibility :: VISIBILITY_BOTH , Mage_Catalog_Model_Product_Visibility :: VISIBILITY_IN_CATALOG ); $_productCollection2 = Mage :: getResourceModel ( 'reports/product_collection' ) -> addAttributeToSelect ( '*' ) -> addOrderedQty () -> addAttributeToFilter ( 'visibility' , $visibility ) -> setOrder ( 'ordered_qty' , 'desc' ); //Get most viewed product collection $_productCollection1 = Mage :: getResourceModel ( 'reports/product_collection' ) -> addAttributeToSelect ( '*' ) -> setStoreId ( $storeId ) -> addStoreFilter ( $storeId ) -> addViewsCount (); //->setPageSize($productCount); Mage :: getSingleton ( 'catalog/product_status' ) -> addVisibleFilterToCollection ( $_productCollection1 ); Mage :: getSingleton ( 'catalog/product_visib

Show top level categories in magento.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 <?php $obj = new Mage_Catalog_Block_Navigation(); $store_cats = $obj -> getStoreCategories (); $current_cat = $obj -> getCurrentCategory (); $current_cat = ( is_object ( $current_cat ) ? $current_cat -> getName () : '' ); foreach ( $store_cats as $cat ) { if ( $cat -> getName () == $current_cat ) { echo '<li><a href="' . $this -> getCategoryUrl ( $cat ) . '">' . $cat -> getName () . "</a> \n <ul> \n " ; foreach ( $obj -> getCurrentChildCategories () as $subcat ) { echo '<li><a href="' . $this -> getCategoryUrl ( $subcat ) . '">' . $subcat -> getName () . "</a></li> \n " ; } echo "</ul> \n </li> \n " ; } else { echo '<li><a href="' . $this -> getCategoryUrl ( $cat ) . '">' . $

How to configure Magento to work with a new domain

Select your Magento database from the  left menu, find the table called  core_config_data and click on it.  Click the Browse tab and edit the first two fields: web/unsecure/base_url web/secure/base_url by clicking the pen icon in front of each of them. Replace your old domain name with your new one and click the Go button to save the change. Clear the Magento cache. The Magento cache folder is located in your Magento installation directory > /var/cache. To clear the cache, simply delete the folder.  Many Magento issues can be fixed just by deleting the cache.

Improve Your YSlow Grade Using .htaccess

Put these lines in you .htaccess and see magic :)                                                                                      @Saurabh Mishra < FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$" > Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT" < / FilesMatch > <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$"> Header unset ETag FileETag None </FilesMatch> <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$"> Header set Expires "Thu, 15 Apr 2012 20:00:00 GMT" Header unset ETag FileETag None </FilesMatch>