Shopify Cheat Sheet – Liquid variables

Cheat sheet with all the variables, filters, and templates you can use on your Shopify theme.


Magento 2 create simple module (Hello word)

Check it Here


Magento how to get all rewrite classes in magento

Here a small one-liner that gives you all active rewrites:


To limit it by object type, add models, blocks, or helpers to the xpath respectively.
For example:


How to replace Rs with rupee Symbol in Magento

Magento by default sets Indian currency as Rs.
If you are looking to replace it with the new Symbol, here is how to get that done.
[root folder]\lib\Zend\Locale\Data\root.xml
Open [root folder]/lib/Zend/Locale/Data/root.xml in notepad++
find the line which says

<currency type=”INR”><symbol>Rs</symbol></currency>

Replace with :
<currency type=”INR”>

Clear cache from admin backend and delete all files inside /var/cache.

Done 🙂


Magento API (web service) Tutorial


Magento automatically clear old cart items when user logged in using event observer

File: app/ect/modules/Nik_Clearoldcart.xml

<?xml version="1.0"?>

File: app/code/local/Nik/Clearoldcart/etc/config.xml

<?xml version = "1.0" ?>
<sales_quote_merge_before><!--calling this event before merging the old cart with newly added cart items while login-->
<nik_clearoldcart_observer><!--unique identifier name for our observer-->
<class>Nik_Clearoldcart_Model_Observer</class><!--Our observer class name-->
<method>loadCustomerQuote</method><!--Method to be called from our observer class-->

File: app/code/local/Nik/Clearoldcart/Model/Observer.php


class Nik_Clearoldcart_Model_Observer extends Mage_Checkout_Model_Session {

* Clears old cart items after login
* @return object currently added cart items
public function loadCustomerQuote() {
$customerQuote = Mage::getModel('sales/quote')

if ($customerQuote->getId() && $this->getQuoteId() != $customerQuote->getId()) {
// Removing old cart items of the customer.
foreach ($customerQuote->getAllItems() as $item) {
if ($item->getHasChildren()) {
foreach ($item->getChildren() as $child) {
} else {

return $this;


In above code we have overridden the Mage_Checkout_Model_Session::loadCustomerQuote() action to avoid merging of old cart items.
Instead of merging the products we have just deleted it!
That’s what we have done!


Magento Set Get and Delete cookie in Magento Client Side – javascript

var name = 'Aman';

var name = Mage.Cookies.get('name');


Magento get product attributes options label/value using id

$attr = $productdata->getResource()->getAttribute("yourAttributeCode");
	if ($attr->usesSource()) {
		$intolerances_label = $attr->getSource()->getOptionText('1'); // 1 us attribute id //
		echo $intolerances_label;


Magento set product attribute in getAllOptions (get option from attribute)

File: \Model\Eav\Entity\Attribute\Source\Customeroptions.php

  public function getAllOptions($withEmpty = true, $defaultValues = false)
        $source  = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attributeName');
        return $source->getSource()->getAllOptions($withEmpty, $defaultValues);