2013-10-29 28 views
0

我有一個數組填充了一些不是來自magento的對象。我已經從第三方軟件提取它們,並且我正在使用magento網格顯示它們。網格人口是完整的。但是,當我嘗試向其集合中添加尋呼機時,它會引發異常。這裏是異常文本自定義集合中的傳呼機錯誤magento

Magento Error

我看到的一些文章,有Magento的收集和PHP普通陣列之間的差異。我是magento的新手,所以我需要幫助。我也曾嘗試將其轉換爲Magento的集合作爲在

Convert an array to a collection

提出,但它不工作either.Any幫助將得到高度讚賞。

Regards

回答

2

請嘗試下面的代碼。

protected $collection; 
public $collection1; 
public $rowObj; 
protected function _construct() 
{ 
$currentPage = (empty($_REQUEST['p'])) ? 1 : $_REQUEST['p']; 
$setLimit = (empty($_REQUEST['limit'])) ? 9 : $_REQUEST['limit']; 
$collection1 = new Varien_Data_Collection(); 
$rowObj = new Varien_Object(); 
$this->collection = array_merge($this->getPreviousLead(), $this->getLeadsData()); 
$this->collection = array_merge($this->collection, $this->getContactsData()); 
$this->collection = array_merge($this->collection, $this->getUpdateLeads()); 
$this->collection->setPage($currentPage, $setLimit); 
$rowObj->setData($this->collection); 

$collection1->addItem($rowObj); 

} 

希望這會對你有用!

乾杯!

+0

感謝您的快速響應。我沒有完全使用資源模型從數據庫中獲取值。我使用像 $ this-> getCollectionFromMagento(); 和 $ this-> getCollectionFromSugarCrm(); $ collection = array_merge($ this-> getCollectionFromMagento(),$ this-> getCollectionFromSugarCrm()); 我該如何使用這個集合來添加尋呼機呢? –

+0

你可以在這裏粘貼你的收藏代碼嗎? –

+0

這是 保護$收集; public $ collection1; public $ rowObj; protected function _construct(){ $ collection1 = new Varien_Data_Collection(); $ rowObj = new Varien_Object(); $ this-> collection = array_merge($ this-> getPreviousLead(),$ this-> getLeadsData()); $ this-> collection = array_merge($ this-> collection,$ this-> getContactsData()); $ this-> collection = array_merge($ this-> collection,$ this-> getUpdateLeads()); $ rowObj-> setData($ this-> collection); $ collection1-> addItem($ rowObj); } –