mysql - Dispaly records from database in magento -
i using code in grid.php display records single tabel 'paypal_payment_transaction':
protected function _preparecollection() { $db = mage::getsingleton('core/resource')->getconnection('core_write'); $query = "select transaction_id,txn_id,additional_information,created_at,user_id,reference_txn `paypal_payment_transaction` limit 0 , 30"; $result = $db->query($query); // count of affected rows $affected_rows = $result->rowcount(); $orders = $result->fetchall($sql); foreach($orders $order) { echo "<pre>"; print_r($order); } } i need query in magento way: may this
protected function _preparecollection() { $collection = mage::getresourcemodel('sales/order_collection') query select record tabel 'paypal_payment_transaction' ; $this->setcollection($collection); parent::_preparecollection(); return $this; } so can display in grid accordingly i.e. in :
protected function _preparecolumns() { ------------------- ------------------ }
try -
protected function _preparecollection() { $collection = mage::getmodel('paypal/payment_transaction')->getcollection(); $this->setcollection($collection); parent::_preparecollection(); return $this; }
Comments
Post a Comment