1

I want to extend Mage_Sales_Model_Resource_Order_Shipment_Item_Collection because it doesn't come with a getIntervals() function.

So I created following files:

MyModule/Modulename/Model/Mysql4/Shipping/Collection:

class MyModule_Modulename_Model_Mysql4_Shipping_Collection 
extends Mage_Core_Model_Mysql4_Collection_Abstract {

public function _construct() {
    parent::_construct();
    $this->_init('sales/order_shipment_item_collection');
}

MyModule/Modulename/etc/config.xml

<global>
    <models>
        <modulename>
            <class>MyModule_Modulename_Model</class>
            <resourceModel>modulename_mysql4</resourceModel>
        </modulename>
        <modulename_mysql4>
            <class>MyModule_Modulename_Model_Mysql4</class>
        </modulename_mysql4>
    </models>
</global>

In my order grid I want to call the collection with

$collection = Mage::getResourceModel('modulename/mymodule_modulename_shipping_collection');

But the collection is empty and I can't figure out why. Can anyone point me in the right direction, please?

1 Answer 1

1

I want to extend Mage_Sales_Model_Resource_Order_Shipment_Item_Collection

But you didn't. You extended Mage_Core_Model_Mysql4_Collection_Abstract. The _init() parameter is used to determine the model which belongs to the collection, you cannot use it to extend another collection.

So change the class to

class MyModule_Modulename_Model_Mysql4_Shipping_Collection extends Mage_Sales_Model_Resource_Order_Shipment_Item_Collection
{
    // add your getInterval() method here
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.