So, your web-site sells all sorts of home furniture, and you have a Christmas section. It is two weeks until Christmas Day, and you realise you’ve got quite a lot of seasonal stock that you need to shift – as you don’t want to be left with a warehouse full of Christmas Trees, Christmas Wreaths and Garlands do you?
Well, offering discounts on those products is probably an idea, and why not do it via a coupon code – that way, you can send a lovely email out to all your customers informing them that if they type in XMAS15 on your checkout, they’ll get a whopping 15% off their order.
With some E-Commerce platforms you might have a few problems with trying to offer money off for specific products or categories – however, with Magento, thankfully this is childs play – and it only takes a couple of seconds to set up.
In your Magento Admin system, simply click on Promotions, and then click on Shopping Cart Price Rules – and then click Add New Rule.
On the left you’ll see three tabs, in the uppermost one you’ll have to name your Price Rule, choose which website it will be activated on and what customers will see it, and also name the actual coupon code itself.
It is then the followed tab (entitled “Conditions”) which is the important one, as this area specifies which products/categories will be available for the promotion. So, click the little green plus, and then select “Product Attribute Combination” – this will create a rule which says “[Do this] If an item is found in the cart with all of these conditions true”…
On this occasion we want to select products from certain categories, so click the green plus again and select “Categories”. Then you can select which of the categories that you’ll like to be enabled – simply click the drop down box and save it.
At this point your rule will say “Category IS 167, 168, 171, 174, etc”. You’ll need to click on the “IS” and change it to “IS ONE OF”.
Subsequently, as long as you save it all and apply the rules, you have now successfully made sure that certain products within your store are now available at 15% off. Furthermore, you can do these reductions based on a plethora of rules including SKU, Colour, Price, nearly any attribute you can think of. You could have a “Blue Monday” if you wanted, offering money off on every product that is blue – that is how random and deep you can go with this amazing piece of E-Commerce software!
Hope it Helps.. Thanks....
Wednesday, September 7
how to Change Default Quantity on Magento Product Page
I find it a tad annoying how on Magento, you’ve got this empty quantity box next to the Buy Now/Add to Basket button. Although clicking the button alone will add an item to the cart, some users may experience doubt in this motion, and enter the quantity required AS WELL as press the button.
But why even have any doubt? Why not just make the default quantity set to 1 – well this something that a lot of people have required, and fortunately, I have got the answer!
In app\design\frontend\default\default\template\catalog\product\view\type\Simple.phtml
Just change..
to
Hope it Helps.. Thanks..
But why even have any doubt? Why not just make the default quantity set to 1 – well this something that a lot of people have required, and fortunately, I have got the answer!
In app\design\frontend\default\default\template\catalog\product\view\type\Simple.phtml
Just change..
to
Hope it Helps.. Thanks..
Tuesday, September 6
How to get current currency and currency symbol in Magento
here is the script to get current currency & Currency symbol in Magento
for current currency
for currency symbol
Hope it helps... Thanks....
for current currency
$currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
for currency symbol
Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
Hope it helps... Thanks....
How to get Order Increment ID in Magento
Here is the script to increment the order id in magento
Last real order id
Hope it helps.. Thanks...
$order = Mage::getModel('sales/order');
$order->load(Mage::getSingleton('sales/order')->getLastOrderId());
$lastOrderId = $order->getIncrementId();
Last real order id
Mage::getSingleton('checkout/session')->getLastRealOrderId();
Hope it helps.. Thanks...
How to Re-Index manually using SQL query in Magento
Here is the script to reindex the data in magento
Hope it helps... Thanks...
getConnection('core_write');
$mysqli->query($sql);
/*
Process_id Indexer_code
1 catalog_product_attribute
2 catalog_product_price
3 catalog_url
4 catalog_product_flat
5 catalog_category_flat
6 catalog_category_product
7 catalogsearch_fulltext
8 cataloginventory_stock
9 tag_summary
*/
$process = Mage::getModel('index/process')->load(7);
$process->reindexAll();
echo "Finished Rebuilding Search Index At: " . date("d/m/y h:i:s");
?>
Hope it helps... Thanks...
How to get Product Image path in Magento
Here is the script to get product image path in magento
Hope it Helps... Thanks
$productId = 1;
$product = Mage::getModel('catalog/product')->load($productId);
$path = Mage::helper('catalog/image')->init($product, 'image')->resize(75, 75);
Hope it Helps... Thanks
Monday, September 5
How to change Admin URL Path in Magento
Here is a quick guide on how to change admin url path in Magento. This need to be done for security reason to be safe from hacking/cracking issue. Basically, this is done not to let any general user to access the admin page.
Generally, we do have ‘admin‘ as the administrator path for Magento. So, the admin URL will be http://www.example.com/admin/
This article will show you, how you can change the admin url. Let’s say from ‘admin‘ to ‘backend‘. So, the new admin URL will be http://www.example.com/backend/
Here is how we do it:-
- Open app/etc/local.xml
- Find the following:-
- Change
to your desired name. Like below:-
- Save the file
- Refresh the Cache from Magento Admin (System -> Cache Management)
Now, you should be able to access admin panel from http://www.example.com/backend/ instead of http://www.example.com/admin/
Important Note
If you just need to change the admin base URL then the proper way I find is by doing the change in local.xml like explained above, instead of editing configuration setting from admin like said below.
I tried to change the Admin Base URL from Magento admin panel. But, I ran into problem and could not access the admin after that. Here is what I did:-
- System -> Configuration -> ADVANCED -> Admin -> Admin Base URL
- Changed Use Custom Admin URL = Yes
- Changed Custom Admin URL (Once I tried with ‘backend/’ and then with ‘http://www.example.com/backend/’)
To solve the problem, I had to make some change in database. If you had similar problem then here is a workaround:-
- Open your database
- Browse table ‘core_config_data‘
- Search in path field for ‘admin/url/use_custom‘ and set its value to ’0′
- Search in path field for ‘admin/url/custom‘ and set its value to empty
- Search in path field for ‘web/secure/base_url‘
- You will find two row result. One with scope = default and another with scope = stores.
- Edit the value of row with scope = stores with the value of the row with scope = default
- Similarly, repeating the process for ‘web/unsecure/base_url‘:-
- Search in path field for ‘web/unsecure/base_url‘
- You will find two row result. One with scope = default and another with scope = stores.
- Edit the value of row with scope = stores with the value of the row with scope = default
- Now, you will be able to login to Magento admin with your old admin base URL.
Ref : http://blog.chapagain.com.np/magento-how-to-change-admin-url-path/
Generally, we do have ‘admin‘ as the administrator path for Magento. So, the admin URL will be http://www.example.com/admin/
This article will show you, how you can change the admin url. Let’s say from ‘admin‘ to ‘backend‘. So, the new admin URL will be http://www.example.com/backend/
Here is how we do it:-
- Open app/etc/local.xml
- Find the following:-
<admin>
<routers>
<adminhtml>
<args>
<frontName><![CDATA[admin]]></frontName>
</args>
</adminhtml>
</routers>
</admin>
- Change
<frontName><![CDATA[admin]]></frontName>
to your desired name. Like below:-
<frontName><![CDATA[backend]]></frontName>
- Save the file
- Refresh the Cache from Magento Admin (System -> Cache Management)
Now, you should be able to access admin panel from http://www.example.com/backend/ instead of http://www.example.com/admin/
Important Note
If you just need to change the admin base URL then the proper way I find is by doing the change in local.xml like explained above, instead of editing configuration setting from admin like said below.
I tried to change the Admin Base URL from Magento admin panel. But, I ran into problem and could not access the admin after that. Here is what I did:-
- System -> Configuration -> ADVANCED -> Admin -> Admin Base URL
- Changed Use Custom Admin URL = Yes
- Changed Custom Admin URL (Once I tried with ‘backend/’ and then with ‘http://www.example.com/backend/’)
To solve the problem, I had to make some change in database. If you had similar problem then here is a workaround:-
- Open your database
- Browse table ‘core_config_data‘
- Search in path field for ‘admin/url/use_custom‘ and set its value to ’0′
- Search in path field for ‘admin/url/custom‘ and set its value to empty
- Search in path field for ‘web/secure/base_url‘
- You will find two row result. One with scope = default and another with scope = stores.
- Edit the value of row with scope = stores with the value of the row with scope = default
- Similarly, repeating the process for ‘web/unsecure/base_url‘:-
- Search in path field for ‘web/unsecure/base_url‘
- You will find two row result. One with scope = default and another with scope = stores.
- Edit the value of row with scope = stores with the value of the row with scope = default
- Now, you will be able to login to Magento admin with your old admin base URL.
Ref : http://blog.chapagain.com.np/magento-how-to-change-admin-url-path/
How to Sort latest product by ‘created date’ and ‘new from date’ in Magento
Here is a quick tip to sort/order latest product by both created date and new from date.
Created At date is automatically added when you add a new product. However, you have to set New from Date manually while adding or editing product.
You may have product with same new from date. And, then you need created at date to sort the latest product.
Here is the code to sort/order product by both created date and new from date:-
Thanks to Mukesh Chapagain's Blog
Reference : http://blog.chapagain.com.np/magento-sort-latest-product-by-created-date-and-new-from-date
Created At date is automatically added when you add a new product. However, you have to set New from Date manually while adding or editing product.
You may have product with same new from date. And, then you need created at date to sort the latest product.
Here is the code to sort/order product by both created date and new from date:-
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))
->addAttributeToFilter('news_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $todayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')
->addAttributeToSort('news_from_date', 'desc')
->addAttributeToSort('created_at', 'desc');
Thanks to Mukesh Chapagain's Blog
Reference : http://blog.chapagain.com.np/magento-sort-latest-product-by-created-date-and-new-from-date
How to disable / remove Secret Key from Admin URL in Magento
A new secret key is created every time you login to Magento Admin. So, there will be a unique key (32 chars long) for each session of your Magento admin login. This key is appended to the admin URL as http://your-admin-url/key/743c37b1…adf6588/
This is basically added for security reason. In their release note, Magento say that they added secret key to URL for CSRF (Cross-site request forgery) Attack Prevention.
Cross-site request forgery, also known as a one-click attack or session riding and abbreviated as CSRF or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user’s browser.
You can learn more about CSRF here:- http://en.wikipedia.org/wiki/Cross-site_request_forgery
Sometime you may want to access admin URL without the secret key. For this, you can disable the secret key from admin URL.
Here is how you do it:-
- Login to admin
- Go to System -> Configuration -> ADVANCED -> Admin -> Security -> Add Secret Key to URLs
- Select No
- Save Config
You are done. You will not see the secret key in admin URL nowonwards.
Thanks to Mukesh Chapagain's Blog
Reference : http://blog.chapagain.com.np/magento-how-to-disable-remove-secret-key-from-admin-url
This is basically added for security reason. In their release note, Magento say that they added secret key to URL for CSRF (Cross-site request forgery) Attack Prevention.
Cross-site request forgery, also known as a one-click attack or session riding and abbreviated as CSRF or XSRF, is a type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user’s browser.
You can learn more about CSRF here:- http://en.wikipedia.org/wiki/Cross-site_request_forgery
Sometime you may want to access admin URL without the secret key. For this, you can disable the secret key from admin URL.
Here is how you do it:-
- Login to admin
- Go to System -> Configuration -> ADVANCED -> Admin -> Security -> Add Secret Key to URLs
- Select No
- Save Config
You are done. You will not see the secret key in admin URL nowonwards.
Thanks to Mukesh Chapagain's Blog
Reference : http://blog.chapagain.com.np/magento-how-to-disable-remove-secret-key-from-admin-url
Can’t send header. Header is already sent” in Magento - Tips to solve the problem
In this article I will show you quick tip that will help you solve common problems in Magento: “Can’t send header. Header already sent” in Magento.
I got this error when I have managed to bring back the client store. Basically, this error happens when there is an extra space or character outside the the php tag . Thanks to the help of excellent Magento users, I have been able to solve it. I think it will be useful if I explained steps by steps what I personally have done so that you can reference it later. When this error happens, you should try the following things.
Open the file that has the problem. In my case, this file is index.php in the site root of Magento.
Open the file with some text editors that supports the encoding. I prefer Notepad++ because its great support in multi languages as well as encoding.
If you open it by Notepad++, click on the menu Encoding, click on UTF-8 without BOM. Save it and then re-upload it to the server.
We just save the error file in the UTF-8 encoding to make sure that everything extra space, line is wiped out. Encoding without BOM ensures you will not have any extra, unwanted characters in the file that prevent it from being executed properly.
Hope it Helps... Thanks..
I got this error when I have managed to bring back the client store. Basically, this error happens when there is an extra space or character outside the the php tag . Thanks to the help of excellent Magento users, I have been able to solve it. I think it will be useful if I explained steps by steps what I personally have done so that you can reference it later. When this error happens, you should try the following things.
Open the file that has the problem. In my case, this file is index.php in the site root of Magento.
Open the file with some text editors that supports the encoding. I prefer Notepad++ because its great support in multi languages as well as encoding.
If you open it by Notepad++, click on the menu Encoding, click on UTF-8 without BOM. Save it and then re-upload it to the server.
We just save the error file in the UTF-8 encoding to make sure that everything extra space, line is wiped out. Encoding without BOM ensures you will not have any extra, unwanted characters in the file that prevent it from being executed properly.
Hope it Helps... Thanks..
Subscribe to:
Posts (Atom)
Google Play
Magento Talks now available in Google Play. Please download it from Here
Followers
Hit Counter
Popular Posts
Feedjit
Subscribe via email
My Blog List
Powered by Blogger.
About Me
- Mohan Natarajan
- Chennai, Tamil Nadu, India
- Hi, this is Mohan Natarajan working as a Senior Software Engineer at DCKAP Technologies.I have completed BE Computer Science and Engineering in Ranipet Engineering College. I did my schooling in Govt Boys Hr Sec School Timiri.(Vellore Dist)
Categories
Text Widget
Pages
Mohan Natarajan Powered by Blogger