join - How To Use Magento Collections to Run Query, Get Results, and Print Them -


i new programming, php, magento, , of all, sql. please forgive me if somehow dumb question.

i trying use magento collections select 2 different columns in 2 different tables , join them. these 2 columns contain product numbers follow same conventions , goal , display product numbers field (lets call 'product_id') contains field b ('item_nr') does not.

here function far, located in model called controller action.

public function importcompare() {      $orderlistcollect = mage::getmodel('personal_orderlist/orderlist')->getcollection()         ->addfieldtoselect('product_id')         ->addfieldtofilter('b.item_nr', null)         ->getselect()         ->joinleft( array('b'=>$this->gettable('catalog/product')),   'main_table.product_id = b.item_nr', array('b.item_nr'));      echo $orderlistcollect; } 

by echoing variable, following query.

select `main_table`.`product_id`, `b`.`erp_item_nr`         `mag1personal_orderlist` `main_table`         left join `` `b` on main_table.product_id = b.item_nr         (b.item_nr = '') 

this looks close want, big problem i have no idea how retrieve information should derive query , echo it. i've tried use variety of collection manipulation methods no avail. easy use them out of order well?

any here appreciated.

collections use interfaces php's standard library implement for each-able behaviors.

if sounded greek, give try.

foreach($orderlistcollect $item) {     $data = $item->getdata();     var_dump($data);      $sku = $item->getsku();     var_dump($sku);      $sku = $item->getdata('sku');     var_dump($sku); } 

if you're interested in learning how with own php objects, object iteration section of manual place start. however, there's no need dive deep on — just treat collection array of objects, , you'll fine.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -