Friday, January 20, 2012

Code to get multiple SKUs in Sales->Order Grid in Magento Admin



$collection = Mage::getResourceModel($this->_getCollectionClass())
   ->join(
    'sales/order_item',
    '`sales/order_item`.order_id=`main_table`.entity_id',
    array(
        'skus'  => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR ",")'),
        'names' => new Zend_Db_Expr('group_concat(`sales/order_item`.name SEPARATOR ",")'),
        )
    );
$collection->getSelect()->group('entity_id');

Monday, January 9, 2012

Magento | Get Cart Summary


Magento Get Cart Items and Cart Total -



To display items in cart use following code -

$this->helper('checkout/cart')->getSummaryCount();
or 


Mage::helper('checkout/cart')->getSummaryCount();

And for the Cart Total: 

Mage::getSingleton('checkout/session')->getQuote()->getSubtotal();

This will display only the total amount for the products. 
If you want the grand total (including shipping & handling) do this: 



Mage::getSingleton('checkout/session')->getQuote()->getGrandTotal();

Google - Website Translator Gadget for Magento

you don’t need a plugin for that. Just add this code:


<div id="google_translate_element"></div><script>
function 
googleTranslateElementInit() {
  
new google.translate.TranslateElement({
    pageLanguage
'en'
  
}'google_translate_element');}
</script>
<script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>



anyware you want in any phtml pages. 
But be careful. The translations is far from perfect.

How To Install A Downloaded Magento Theme


Unlike single template themes (WordPress) Magento themes are quite different as its layout depends on four elements i.e.
  1. Layout – Present is (app/design/frontend/your_interface/new_theme/layout/)
  2. Templates – Present in (app/design/frontend/your_interface/new_theme/template/)
  3. Skins – Present in (skin/frontend/your_interface/new_theme/)
  4. Locale – Present in (app/design/frontend/your_interface/new_theme/locale/)
In order to install and integrate a new theme you need to follow few steps more than what you are accustomed to follow in case of wordpress themes.
If you have already downloaded your preferred Magento theme then here is how you can install and integrate this new theme into your existing Magento installation.

  1. Uncompress the zip file containing theme templates (you can use winrar or winzip to uncompress files on windows machine or use unzip zipfilename.zip to uncompress files on Linux server)
  2. Copy entire app folder of your new theme underYour_Magento_Installation/app/design/frontend/default/ so it becomes likeYour_Magento_Installation/app/design/frontend/default/new_theme
  3. Copy entire skin folder of your new theme underYour_Magento_Installation /skin/frontend/default/ so it becomes like Your_Magento_Installation/ skin/frontend/default/ new_theme
  4. Now, as you have added your newly downloaded theme in your Magento store you need to login to your Magento store admin to tell Magento which theme to use as layout.
  5. Sometimes Magento Cache doesn’t let you see your changes instantly. In order to test your new theme it would be wise to disable cache for the time being. Go to System > Cache Management and select “Disable” then click “Save Cache”. Once you are done with all the steps Enable the cache again.
  6. Now go to System -> Configuration and select the Design Tab
  7. Type the name of your new theme which you have copied in your Magento installation in front of skin (Images/CSS) input box and click “Save Config”.
  8. Optional – If you have downloaded a widget ready Magento template then you need to install the widget provided with the theme. In order to install Magento theme widget you have to go to CMS -> Static Blocks and click on “Add New Block”. Based on your widget installation instructions you have to add your new widget and activate that using this new widget block. Finally select “Enabled” and click “Save Block”. Go and select “Custom Design” Tab and in Layout select “Homepage” otherwise your widget won’t show on home page.
  9. Optional – Home page of default Magento store is a CMS block so you have to provide custom code there in order to display something on home page. To do so you have to go to CMS- > Manage Pages and select “Home page” and in the content area type the home page content code which comes up with your new theme. You can change this area anytime you want.
  10. All set. Open up a new page on your browser and type in your store name to see the new theme. Your new Magento theme is ready to be used.

How To Install a Magento Theme Via Magento Connect?


To install a theme from Magento Connect you need to follow certain steps which are explained below (Advance users may skip few steps):
1. Select the theme by browsing the huge Magento theme archive. OR, If you know the direct URL of your favourite theme just open it’s Magento connect URL
2. Now, you will see a button right under the theme image called “Get Extension Key”. You need to click “Get Extension Key” and agree to extension license agreement.
3. After you select agree checkbox and click “Get Extension Key” you will see the Magento extension key right there itself (displayed in the box). You need to paste this extension key in your store’s Magento connect tab. Keep it safe.
4. Copy this Magento extension key. E.g. It will look like “magento-community/Magik_Autocomplete”
5. In order to install this theme into your Magento store you need to login to your store admin panel and go to System->Magento Connect->Magento Connect Manager. Magento connect manager will ask you to login again. You need to use your store admin login credentials to get past the login screen.
6. Soon after you see “Theme successfully installed” message go toSystem->Configuration->Design->Themes and provide the theme name in Default field (which will change your default theme to this new theme) and click “Save Config” button at the top right corner of your screen.
7. A Magento theme revolves around different columns in your theme layout. In case your store home page doesn’t load properly and shows weird design then go to CMS->Manage Pages. You will notice that there are two different layouts for the home page (may be more depending upon how many themes you have tried in the past). Based on your new theme layout disable all the other home page layouts. You can easily disable/enable the layouts by clicking “Enabled” or “Disabled” links provided in the status field.
8. Check your home page if the store is looking just like your new theme, you are done. If you still see problems chances are that you haven’t disabled the correct home page layout. Repeat step 7 until you see a correct store home page (not required if you have only two home page layouts showing in your “Manage Pages” section.
This was the easiest and fastest way of installing a Magento theme using Magento Connect manager.
Many Magento theme sites don’t publish their theme template in Magento connect (sometimes their themes do not pass through Magento connect guidelines). These themes are provided directly by the theme owner sites. If you are interested in downloading a Magento theme from such sites then following are the steps required to install a Magento theme within your existing Magento installation.



This blog would serve as a thorough introduction for developers to the structure
of Magento, as well as provide you with enough examples that you can take any of
your coding ideas to fruition. Developers will learn how to write custom modules
for Magento for redistribution or for simply deploying on a corporate installation of
Magento.