【问题标题】:Pager error in custom collection magento自定义集合 magento 中的寻呼机错误
【发布时间】:2013-11-08 15:40:06
【问题描述】:

我有一个数组,其中填充了一些不是来自 magento 的对象。我从 3rd 方软件中获取了它们,并在 magento 网格中显示它们。网格填充完成。但是,当我尝试将寻呼机添加到其集合中时,它会引发异常。这是异常文本

我在一些文章上看到magento集合和php中的普通数组是有区别的。我是 magento 的新手,所以我需要帮助。我还尝试按照

中的建议将其转换为 magento 集合

Convert an array to a collection

但它也不起作用。任何帮助将不胜感激。

问候

【问题讨论】:

    标签: php arrays magento exception pager


    【解决方案1】:

    请尝试以下代码。

    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); 
    
    }
    

    希望这对你有用!

    干杯!

    【讨论】:

    • 感谢您的快速回复。我没有完全使用资源模型从数据库中获取值。我正在使用 $this->getCollectionFromMagento();和 $this->getCollectionFromSugarCrm(); $collection=array_merge($this->getCollectionFromMagento(),$this->getCollectionFromSugarCrm());如何使用此集合在其中添加寻呼机?
    • 这里是受保护的 $collection;公共 $collection1;公共 $rowObj;受保护的函数_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); }
    • 我仍然面临我在上述答案中添加的异常。你能看看吗。
    猜你喜欢
    • 2015-07-21
    • 2013-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多