Posted by: james | September 29, 2009

Important Notes On Magento..

to add new tab in right hand side add system.xml and in that add either tab or section. and to display in that any thing you have to use group tag in xml file and also use all the fields.. please reffer any default system.xml and also check another thing from there also….

to get input type like text or dropdown use getFrontendInout() and to get simple data from any input type use getData but if you use select or multiselect then you have to use getAttributeText()..

in system tab in configuration tab all data will be stored directly in table core_config_data…

use getStoreConfig(‘path’) to get directly all the data… and then overwrite view file for product or whatever file related to your module and then apply logic and all that.. and also you can check that if you give input type yes/no then in database it will store that value as either 1 or 0….

whenever you use either backend model or something like _beforesave or aftersave method or afterload or method which has an observer.. then in that method always at the end use syntax like  return parent::_beforesave means method name and all that..please see the deafult methods….

getcollection will call method like select * from tablename..
ex.
$op1 = Mage::getModel(‘bundle/selection’);
$collection1 = $op1->getCollection();
here it will retrive all the data and now if you want to use where condition on some field then call addFieldToFilter function and in that pass column name as argument.

ex.
$op1 = Mage::getModel(‘bundle/selection’);
$collection1 = $op1->getCollection();
$collection1->addFieldToFilter(‘option_id’,$optionIds[0]);

now here option_id will be in where condition. now to see select query use getSelect method.
ex.
$op1 = Mage::getModel(‘bundle/selection’);
$collection1 = $op1->getCollection();
echo $collection1->getSelect()->where(‘option_id = ‘,8);

so now here it will print select query and in some cases this function faild to call because it might think that passed argument is attribute and it thrwos error but we pass here field so it throws error.
so to solve it we have to call directly where on select query means first of all get all cokllection and on that call getSelect function so you will get whole select query and now on that call where function.

ex.
require_once(‘C:/www/magento/app/Mage.php’);
Mage::app(‘admin’);

$op1 = Mage::getModel(‘bundle/selection’);
$collection1 = $op1->getCollection();
echo $collection1->getSelect()->where(‘option_id = ‘,8);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: