Converting an array to a collection in Magento

前端 未结 4 893
天命终不由人
天命终不由人 2021-01-14 19:08

I have an array object that is an output of a magento fetchall from DB and i want this to be converted to an object of a Collections class so that i can implement pagination

4条回答
  •  忘掉有多难
    2021-01-14 20:08

    In order to convert an array to a collection object:
    1> Create an instance of Varien_Db_Collection

    $collection = new Varien_Data_Collection();
    

    2> Create an instance of Varien_Object and set the array data

    $rowObj = new Varien_Object();
    $rowObj->setData($row);
    

    3> Finally add the Varien_Object to Collection instance

    $collection->addItem($rowObj);
    

    4> Now $collection is a collection object.

提交回复
热议问题