Thursday, 21 January 2016

What are blocks in Magento

There are two types of blocks: those that automatically render their children and those that don't. Knowing which type you're using will help you in debugging.

Magento blocks are essentially models that contain logic for your view templates. Mind you - this is not business logic, but it is logic related to the display of the information you're presenting. This is by definition presentational logic. If you're familiar with Zend Framework's Zend_Layout you could draw a comparison between custom view objects and layout helpers.

The template file assigned to a block object can execute code as if it is local to that object. That is, $this corresponds directly to the block class.

Layout actions are a thing that people use.

Two types of blocks

There are two types of blocks at the end of the day - those that render automatically and those that don't. Take notes because this is on the Magento Certification exam!!

Auto-rendered blocks


When defined in a layout, any block of type core/text_list will automatically render all its children. While core/text will automatically render itself it really only should contain text and therefore is not useful for layout purposes (though some clever things can be achieved with them).



Other blocks


Any other block type will need to be rendered manually. Provide the block an alias which can then be passed to getChildHtml, returning the content which you then echo.

for more >>

Wednesday, 20 January 2016

Importance of Magento Config xml

The config is the beating heart of the Magento System. It describes, in whole, almost any module, model, class, template, etc. than you'll need to access. It's a level of abstraction that most PHP developers aren't used to working with, and while it adds development time in the form of confusion and head scratching, it also allows you an unprecedented amount of flexibility as far as overriding default system behaviors go.



Path of magento config xml
app -> etc -> config.xml


The other one is local.xml at the same place, it store the database access setting.

Friday, 15 January 2016

Benefits of Magneto



  • Security is strong other than others
  • Admin Dashboard for Report Overview, Abandoned Shopping Cart Report
  • Search Engine Optimization; Google Site Map,   URL Rewrites give full control of URL's,   Meta-information for products and categories
  • Advertising tools
  • Control multiple websites and stores from one Administration Pane
  • Multi-Lingual, Support for Multiple Currencies
  • Shipping to multiple addresses in one order
  • Multiple shipments per order
  • Free Shipping
  • View, edit, create and fulfill orders from admin panel.
  • Create one or multiple invoices, shipments and credit memos per order to allow for split fulfillment

Thursday, 24 December 2015

How to implement mail system in your custom magento module


First Add new Template in Magento Admin > System > Transactional Email > Add New Template.
For Customer Registration load default registration Template from Local, modify as requirement then save it.

Use below code in your save function of module controller where you need.




$customer = Mage::getModel('customer/customer')->load($customer_id);

$templateId = 9; /* get template ID from magento admin > System > tramsactional Emails */
$sender = Array('name' => Mage::getStoreConfig('trans_email/ident_sales/name'),
'email' => Mage::getStoreConfig('trans_email/ident_sales/email'));

$password = '123Q3!34'; /* generate random password */
$email = $customer->getEmail();
$customer_name = $customer->getFirstname().' '.$customer->getLastname();

$emailName = $customer->getFirstname();
$vars = Array('customer_name'=>ucfirst($customer->getFirstname().' '.$customer->getLastname()),'customer_password'=>$password, 'customer_email'=>$customer->getEmail(),);
/* Note : variables should be  same as in Template */

$storeId = Mage::app()->getStore()->getId();
$translate = Mage::getSingleton('core/translate');

$mail = Mage::getModel('core/email_template');

$mail->addBcc($BCCMail);
$mail->sendTransactional($templateId, $sender, $email, $emailName, $vars, $storeId);

Saturday, 5 December 2015

Resources to install Magento 2

Resource :

  • Apache 2.2 or 2.4
  • PHP 5.6.x or 5.5.x (PHP 5.4 is not supported)
  • MySQL 5.6.x
  • Cron must be enable in server
  • Must enable server rewrites in Apache web server


server permissions :

UNIX systems require root privileges to install and configure software like a web server, PHP, and so on. If you need to install this software, make sure you have root access.

You should not install the Magento software in the web server docroot as the root user because the web server might not be able to interact with those files.

You’ll also need root privileges to create the Magento file system owner and add that owner to the web server’s group. You’ll use the Magento file system owner to run any commands from the command line and to set up the Magento cron job, which schedules tasks for you.


Note : I recommend changing the default Admin URL from admin to something else

How to disable “save address book” in checkout process?

Go to file "checkout/onepage/billing.phtml" Remove bellow code at line 30

and remove if condition at line 38
Also Remove below code at Line 173 :

Note : Must have a backup of billing.phtml before editing.

Thursday, 3 December 2015

How to validate my radio button fields using magento?

If you are using magento form validation add class(magento-checkbox-validation) in your radio inputs(of same group):
class="magento-checkbox-validation" OR use "validate-one-required" on
 the last radio/checkbox in the group


And if you are writing your custom script then add this function in script :

 function validateRadioIsSelected()
{
 var options = $$('input.Classname');
    for( i in options ) {
        if( options[i].checked == true ) {
            return true;
        }
    }
    return false;
}

if above function return true, it means your radio is selected