Monday, September 3, 2012

Mass Importing of Product using magento faster way

I was willing to write on some best practices to mass import product in lillte time . then i come to know
about magmi and i got second thought why not just reveal magento's best kept secret of mass import

so here you go download this from http://sourceforge.net/projects/magmi/
the setup and usage is fairly easy and straight forward.

Thursday, August 9, 2012

adding link to magento top menu using layout update


Add link to Magento Top Menu using Layout XML update
in your custom module's  layout.xml default handle add this


      <reference name="root">
<reference name="top.links">
<action method="addLink" translate="label title">
<label>About Us</label>
<url>about</url> <!-- can use full url also -->
<title>About Us</title>
<prepare>true</prepare> <!-- set true if adding base url param -->
<urlParams helper="core/url/getHomeUrl"/>
</action>
  </reference>
</reference>

Using IF-ELSE OR CASE-WHEN in Magento Collection - Expression based field by addExpressionAttributeToSelect

Using IF-ELSE OR CASE-WHEN  in Magento Collection - Expression based temporary column field  by addExpressionAttributeToSelect

Magento addExpressionAttributeToSelect  method can be used to create temporary column in
collections

$_collection Mage::getResourceModel('sales/order_collection')
        ->
addExpressionAttributeToSelect('your_temp_column''CASE order_id WHEN 1 THEN one ELSE TWO END ''');

on printing sql query using getselect
echo $_collection->getSelect() ;


 the magento will create query something like this  SELECT (CASE order_id WHEN 1 THEN one ELSE TWO END) AS your_temp_column

The temproary column can be used for sorting and filtering also , please note for filtering
you need to use 'having'  instead of builtin addAttributeToFilter method.
$_collection->getSelect()->having('your_temp_column = "one" '); 

hope this helps




Friday, December 10, 2010

Adding TInyMCE Editor in Magento Custom Module

I've created an custom module from module creator but i couldnot displayed tinymce wysiwyg editor in admin page ?

though modulecreator guys has added default field of "content" for editor:

$fieldset->addField('contentdesc', 'editor', array(
'name' => 'contentdesc',
'label' => Mage::helper('getthelooks')->__('Description'),
'title' => Mage::helper('getthelooks')->__('Description'),
'style' => 'width:500px; height:300px;',
'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
'wysiwyg' => true,
'required' => true,
));

but even i change wysiwyg to true it didnt worked. module creator has forgot that to enable wysiwyg we also needed js for that

so here is complete simple layout xml file :





1










js_cssprototype/windows/themes/default.css
js_cssprototype/windows/themes/magento.css










change getthelooks to your custom module name and enjoy!

Product grid Magento

$this->getLayout()->createBlock('adminhtml/catalog_product_grid', 'product.grid')->toHtml()

GET ATTRIBUTE VALUE MAGENTO

if($_product->getResource()->getAttribute('webexcusive')->getFrontend()->getValue($_product) == 'Yes') {

Tuesday, December 7, 2010

Magento Print your Static BLOCK

getLayout()->createBlock('cms/block')->setBlockId('BLOCK IDENTIFIER')->toHtml() ?>