Skip to main content

Posts

How to add tab in Customer Information in Magento Admin

Step 1) Override the file /app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tabs.php, Inside _beforeToHtml() method, add the following code: $ this -> addTab ( 'Custom' , array (      'label'   = > Mage :: helper ( 'customer' ) -> __ ( 'Custom' ) ,      'class'   = >     'ajax' ,      'url'     = >     $ this -> getUrl ( '*/*/custom' , array ( '_current' = > true ) ) , ) ) ; Step 2)  Override the file /app/code/core/Mage/Adminhtml/controllers/CustomerController.php, Add the following code: public function customAction() { $this->_initCustomer(); $this->getResponse()->setBody( Mage::app()->getLayout()->createBlock('core/template')->setTemplate('custom/customer/tab/custom.phtml')->setCustomerId(Mage::registry('current_customer')->getId())         ->setUseAjax(true)->toHtml() ); } Step

Create custom attribute in magento category

HI friends to create custom attribute for product is to easy , but for a category its tricky. For creating attribute in category general tab use this code and create a new file, place it in root folder like http://localhost/magento-1.6.2.0/magento/attribute.php and run it. its All done enjoy:)  +ankur rai   <?php require_once ( 'app/Mage.php' ); Mage :: app () -> setCurrentStore (Mage :: getModel ( 'core/store' ) -> load (Mage_Core_Model_App :: ADMIN_STORE_ID )); $installer = new Mage_Sales_Model_Mysql4_Setup; $attribute = array ( 'type' => 'int' , 'label' => 'Is Open' , 'input' => 'select' , 'source' => 'eav/entity_attribute_source_boolean' , 'global' => Mage_Catalog_Model_Resource_Eav_Attribute :: SCOPE_GLOBAL , 'visible' => true , 'required' => false , 'user_defined' => true , '

Improve Your YSlow Grade Using .htaccess

Put these lines in you .htaccess and see magic :)                                                                           < 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>

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.

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_visi