Friday, 24 April 2015

How to keep applied magento catalog price rule



There is a bug in magento(it's a feature actually, not bug). Whenever we create a catalog price rule and apply this rule to our catalog products, It stops working automatically or you can say it disappears at night. Let me explain what actually happens.

When Magento displays products on frontend, it checks if there are catalog rules for this date. And the date used for this check is your local. When catalog rules are being applied, it uses GMT date. 

Now, the challenge is how to keep applied magento catalog price rule.

The best way to achieve this, is by setting cron job on your server. I will discuss this later. Actually I have got the another solution which is not the healthiest way for Magento modification, but it is the easiest one.

The problem is in Mage_CatalogRule_Model_Action_Index_Refresh::execute() function. You will have to rewrite this function/class.

Step 1:  Copy app/code/core/Mage/CatalogRule/Model/Action/Index/Refresh.php to                                                                           app/code/local/Mage/CatalogRule/Model/Action/Index/Refresh.php

Step 2:  Find execute() function. Inside the body of this function, replace line 121:
                                $timestamp = $coreDate->gmtTimestamp('Today');
                with this line:
                                $timestamp = Mage::app()->getLocale()->date(null, null, null, true)->get(Zend_Date::TIMESTAMP);

Now, you will be able to apply catalog price rule for your store products.
Enjoy e-commerce !

Wednesday, 11 March 2015

Removing recently viewed products from left/right sidebar in magento



In magento, Recently viewed products is actually a default sidebar block. It may be on left side or right side depending on your theme layout. Whenever you view any product, it would be added under this block.

Now I am trying to remove this block from sidebar. Actually there may be more than one approach to do this, but I'll going to discuss two popular approaches here:

Approach 1: Go to app/design/frontend/base/default/layout/report.xml. Open this file with your favorite text editor (I'll prefer notepad++) and comment out following line :

<block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />

But I don't like this approach because I'll never recommend to edit/change base files, however, you do not have to worry as I've got an another solution and it really worked for me. So, If you want to do this, I'll prefer this one :

Approach 2: In your Theme's local.xml file, under <default> section, put this line:

If your block is located at right side, then the line would be
                 <remove name="right.reports.product.viewed" />

If your block is located at left side, then the line would be
                 <remove name="left.reports.product.viewed" />

Enjoy e-commerce with magento !!!


Note: Tested over magento 1.9.0.1

Saturday, 3 January 2015

Setting-up Google Analytics for your magento store

The Benefits of Using Google Analytics for magento:

Using Google Analytics for ecommerce conversion tracking is one of the best things you can do to ensure your business is on track for success. It's good in practice to use ecommerce tracking to find out what users buy through your site or app, including information about:
  • Products: Which products they buy, in what quantity, and the revenue generated by those products.
  • Transactions: The revenue, tax, shipping, and quantity information for each transaction.
  • Time to Purchase: The number of days and number of sessions it takes to purchase, starting from the most recent campaign through the completed transaction.

Steps to configure your magento store for google analytics:

step 1: Just go through this link
step 2: sign in with a google id or create an google account.
step 3: Select the Admin tab into your google Analytics account.
step 4: In the ACCOUNT column, select Create new account from the dropdown menu.
step 5: Click Web site or Mobile app.
step 6: Now, fill the entries as shown below and click on get tracking id.
step 7: Now, go to your magento admin panel.
step 8: Navigate to System -> Configuration -> Sales -> Google API and expand the Google Analytics section.
step 9: Pick the Yes option from the Enable drop-down menu. Enter your Google Analytics Tracking ID into the Account Number field. Additionally, pick Yes option from the drop-down for Enable IP Anonymization.
step 10: Then, click on save config. You're all done.