Tuesday 28 January 2014

Magento: Difference between Mage::getSingleton() and Mage::getModel()

You may be in thinking sometime what is the difference between magento getSingleton and getModel method so here is a explanation of the difference The Mage::getModel(‘module/model’) create a instance of model object each time method is got called this approach is resource consuming require separate memory for each object instance.

1. Mage::getModel('catalog/product'), it will create new instance of the object product each time.

2. e.g.
$obj1 = Mage::getModel('catalog/product');
$obj2 = Mage::getModel('catalog/product');
Then $obj1 is a one instance of product and $obj is another instance of product.


While Mage::getSingleton(‘catalog/product’) will create reference of an existing object if any reference is not exists then this method will create an instance using Mage::getModel() and returns reference to it.
So, if
$obj1 = Mage::getSingleton(‘catalog/product’);
$obj2 = Mage::getSingleton(‘catalog/product’);

Then $obj1 and $obj2 both refer to the same instance of product.

Saturday 25 January 2014

Fixed: PHP Warning - POST Content Length exceeds the limit in XAMPP

When upload a any database file ex:filename.sql, I get this error: "PHP Warning: POST Content-Length of xxx bytes exceeds the limit of 8388608 bytes in Unknown on line 0". This is because you exceeded the limit of uploading files. 

1. Edit your server folder php/php.ini

You have find post_max_size and upload_max_filesize, then change the default number to 30M or what ever you want.

if you edit php.ini file in notepad++ 
so please press a crtl+g and to line number 770.
where is place post_max_size = 8M and replace a post_max_size = 30M

and again press a crtl+g and to line number 922.
upload_max_filesize = 2M and replace a upload_max_filesize = 30M


After changing your php.ini file close, 
Restart your web server (for local hosting) or try to upload your file again.