Wednesday, 4 June 2014

Sending Transactional E-Mails:

Here is the way to go…….

<pre>$email = Mage::getModel('core/email_template');
$email->sendTransactional(
some_email_template', // template
 array('name' => 'Your Company', 'email' => 'contact@yourcompany.com'), // sender details    'joe@joebloggs.com',  // recipient email
 'Joe Bloggs',                                                          // recipient name
                            array('customerName' => 'Joe Bloggs'),                                 // merge vars
                            Mage::app()->getStore()->getStoreId()                                  // store id
                        );
 
reference: http://jaseir.com/magento/sending-transactional-e-mails/

Resizing A Product Image:

Here is the way to go…….
  
<pre>$helper = Mage::helper('catalog/image');
$helper->init($product, 'image');
$helper->resize(216, 161);
?></pre>

reference: http://jaseir.com/magento/resizing-a-product-image/

Adding A Layout Handle From A Controller:

Here is the way to go…….

<pre>$update = $this->getLayout()->getUpdate();
$update->addHandle('default');
$this->addActionLayoutHandles();
$update->addHandle('your_handle');
$this->loadLayoutUpdates();
$this->generateLayoutXml();
$this->generateLayoutBlocks();
$this->_isLayoutLoaded = true;
 
reference: http://jaseir.com/magento/adding-a-layout-handle-from-a-controller/

Add comment to form input in admin:

Here is the way to go…….

<pre>$afterElementHtml = '<p><small>' . ' this is the hint! ' . '</small></p>';
$linkFieldset->addField('field_name', 'text', array(
'after_element_html' => $afterElementHtml,
));
 
reference: http://jaseir.com/magento/add-comment-to-form-input-in-admin/

Category Product Collection:

<pre>$cat = Mage::getModel('catalog/category')->load(1);
$coll = Mage::getResourceModel('catalog/product_collection');
$coll->addCategoryFilter($cat);</pre>
 
reference: http://jaseir.com/magento/category-product-collection/

Adding BreadCrumbs Via code (usually in a controller):

Here is the way to go…….

Via code (usually in a controller):
$crumbs = Mage::app()->getLayout->getBlock('breadcrumbs');
$crumbs->addCrumb('home', array(
    'label' => 'Home',
    'title' => 'Go to Home Page',
    'link' => Mage::getUrl('')
));
 
Via Layout XML:


Home



What is code pool?

it is a concept to pull the code in magento structured format.
 magento
     |_app
         |_code
              |_community
              |_core
              |_local
 
reference: http://jaseir.com/magento/what-is-code-pool/