below example if i want to over right catalog helper class of core top my custom made class
Search This Blog
Thursday, January 19, 2012
Extrending helper class in magento or creating magento helper object or over riding magneto helper class or object
In the config file of the class e.g catalog.xml
below example if i want to over right catalog helper class of core top my custom made class
Mymodule_Catalog_Helper_Myclass // for Myclass.php in catalog
below example if i want to over right catalog helper class of core top my custom made class
Wednesday, January 18, 2012
Save single,one,few,array of attributes or single attribute or attributes without the entire whole product or saving a product without sql queries
Save single,one,few,array of attributes or single attribute or attributes without the entire whole product or saving a product without sql queries
$pidArray[]=array(1=>"181");
Mage::getSingleton('catalog/product_action')
->updateAttributes($pidArray, array('name' => 'name of product'), 0);
$pidArray[]=array(1=>"181");
Mage::getSingleton('catalog/product_action')
->updateAttributes($pidArray, array('name' => 'name of product'), 0);
Thursday, January 12, 2012
magento select multiple coloumn with like attribute from a table using magento query colelction
magento select multiple coloumn with like attribute from a table using magento query colelction
If I want to select a value from 2 or more columns i will use the below code in magento collection
$collection = Mage::getModel('module/module')->getCollection()->addAttributeToSelect('*')->addFieldToFilter(array(0=>'col1',1=>'col2'),array(0=>array('like' => '%'.$cond.'%'),1=>array('like' => '%'.$cond.'%')));
The result
SELECT `main_table`.`*` FROM `table` AS `main_table` WHERE (((col1 like '%cond%') or (col2 like '%cond%')))
If I want to select a value from 2 or more columns i will use the below code in magento collection
$collection = Mage::getModel('module/module')->getCollection()->addAttributeToSelect('*')->addFieldToFilter(array(0=>'col1',1=>'col2'),array(0=>array('like' => '%'.$cond.'%'),1=>array('like' => '%'.$cond.'%')));
The result
SELECT `main_table`.`*` FROM `table` AS `main_table` WHERE (((col1 like '%cond%') or (col2 like '%cond%')))
Subscribe to:
Posts (Atom)