1

http://www.magentocommerce.com/boards/viewthread/760042/

My model object when passed to get_class appears to be ok.

2013-12-09T11:04:27-05:00 DEBUG (7):  get_class() Checkerboard_Workorder_Model_Workorderlineitem 

The Object itself looks good too.

2013-12-09T11:04:27-05:00 DEBUG (7): workorderlineitem -> Checkerboard_Workorder_Model_Workorderlineitem Object 
( 
[_eventPrefix:protected] => core_abstract 
[_eventObject:protected] => object 
[_resourceName:protected] => workorder/workorderlineitem 
[_resource:protected] => 
[_resourceCollectionName:protected] => workorder/workorderlineitem_collection 
[_cacheTag:protected] => 
[_dataSaveAllowed:protected] => 1 
[_isObjectNew:protected] => 
[_data:protected] => Array 
( 
[workorder_id] => 6 
[udrop_ship_item_id] => 25 
[order_item_id] => 100 
[created_timestamp] => 1386605067 
) 

[_hasDataChanges:protected] => 1 
[_origData:protected] => 
[_idFieldName:protected] => 
[_isDeleted:protected] => 
[_oldFieldsMap:protected] => Array 
( 
) 

[_syncFieldsMap:protected] => Array 
( 
) 

) 

But when I call save on the object the following exception is raised:


Can’t retrieve entity config: workorder/workorderlineitem 
#0 /var/www/html/app/code/core/Mage/Core/Model/Resource.php(272): Mage::throwException(’Can’t retrieve ...’) 
#1 /var/www/html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(284): Mage_Core_Model_Resource->getTableName(’workorder/worko...’) 
#2 /var/www/html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(247): Mage_Core_Model_Resource_Db_Abstract->getTable(’workorderlineit...’) 
#3 /var/www/html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(586): Mage_Core_Model_Resource_Db_Abstract->getMainTable() 
#4 /var/www/html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(449): Mage_Core_Model_Resource_Db_Abstract->_prepareDataForSave(Object(Checkerboard_Workorder_Model_Workorderlineitem)) 
#5 /var/www/html/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Checkerboard_Workorder_Model_Workorderlineitem)) 
#6 /var/www/html/app/code/local/Checkerboard/Workorder/Model/Observer.php(125): Mage_Core_Model_Abstract->save() 
#7 /var/www/html/app/code/community/Unirgy/DropshipPo/Helper/Data.php(96): Checkerboard_Workorder_Model_Observer::createWorkorders(Array) 
#8 /var/www/html/app/code/community/Unirgy/DropshipPo/controllers/Adminhtml/PoController.php(80): Unirgy_DropshipPo_Helper_Data->sendVendorNotification(Object(Unirgy_DropshipPo_Model_Po)) 
#9 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Unirgy_DropshipPo_Adminhtml_PoController->resendUdposAction() 
#10 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch(’resendUdpos’) 
#11 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) 
#12 /var/www/html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() 
#13 /var/www/html/app/Mage.php(683): Mage_Core_Model_App->run(Array) 
#14 /var/www/html/index.php(93): Mage::run(’’, ‘store’) 
#15 {main} 

I am really confused by this, as everything looks to be ok in all of my code.

The official Magento forum has a link to download all of my code.


As requested the model section of my code.

       <models>
            <workorder>
                <class>Checkerboard_Workorder_Model</class>
                <resourceModel>workorder_mysql4</resourceModel>
            </workorder>

            <workorder_mysql4>
                <class>Checkerboard_Workorder_Model_Mysql4</class>
                <entities>
                    <workorder>
                        <table>workorder</table>
                    </workorder>
                </entities>
            </workorder_mysql4>


            <workorderlineitem>
                <class>Checkerboard_Workorderlineitem_Model</class>
                <resourceModel>workorderlineitem_mysql4</resourceModel>
            </workorderlineitem>

            <workorderlineitem_mysql4>
                <class>Checkerboard_Workorderlineitem_Mysql4</class>
                <entities>
                    <workorderlineitem>
                        <table>workorder_lineitem</table>
                    </workorderlineitem>
                </entities>
            </workorderlineitem_mysql4>

            <picklistitem>
                <class>Checkerboard_Picklistitem_Model</class>
                <resourceModel>picklistitem_mysql4</resourceModel>
            </picklistitem>

            <picklistitem_mysql4>
                <class>Checkerboard_Picklistitem_Model_Mysql4</class>
                <entities>
                    <picklistitem>
                        <table>picklist_items</table>
                    </picklistitem>
                </entities>
            </picklistitem_mysql4>

            <picklistproduct>
                <model>Checkerboard_Picklistproduct_Model</model>
                <resourceModel>picklistproduct_mysql4</resourceModel>
            </picklistproduct>
            <picklistproduct_mysql4>
                <class>Checkerboard_Picklistproduct_Model_Mysql4</class>
                <entities>
                    <picklistproduct>
                        <table>picklist_products</table>
                    </picklistproduct>
                </entities>
            </picklistproduct_mysql4>
        </models>


// Model/Workorderlineitem.php

/**
 * Workorderlineitem object model.
 * @author Chris Pinto
 */
class Checkerboard_Workorder_Model_Workorderlineitem extends Mage_Core_Model_Abstract {
    protected function _construct() {
        $this->_init('workorder/workorderlineitem');
    }
}


// Model/Mysql4/Workorderlineitem.php


/**
 * Workorderlineitem object Mysql4 resource model.
 * @author Christopher Pinto
 */
class Checkerboard_Workorder_Model_Mysql4_Workorderlineitem extends Mage_Core_Model_Mysql4_Abstract {
    protected function _construct() {
        $this->_init('workorder/workorderlineitem', 'entity_id');
    }
}



// Model/Mysql4/Workorderlineitem/Collection.php/**
 * Workorderlineitem object Mysql4 resource model collection.
 * @author Christopher Pinto
 */
class Checkerboard_Workorder_Model_Mysql4_Workorderlineitem_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
    protected function _construct() {
        $this->_init('workorder/workorderlineitem');
    }
}
2
  • You'll find better help here if you post relevant code here instead a link to some zip file on another site. Did you find the following post? stackoverflow.com/questions/17786371/…
    – pspahn
    Commented Dec 9, 2013 at 20:48
  • I saw that post last week and it did not help with my problem. Commented Dec 9, 2013 at 21:50

1 Answer 1

4

Your table name configuration you specified in the resource model's call to _init() can't be resolved in the configuration XML.
Update your post with the XML section under global/models to get more detailed information.

UPDATE: I don't know the primary key column name for your take, so I'll just use id here. Substitute with your PK column name.

All in all your code is quite unusual because you

  1. have declared multiple model class groups in one module config.xml
  2. have a workorderlineitem and a workorder module, but also have a workorderlineitem model within your workorder module

So assuming all this is on purpose and you know what you are doing, your _construct() method of your resource model declaration for your workorder/workorderlineitem model should look like this:

protected function _construct()
{
    $this->_init('workorder/workorderlineitem', 'id');
}

That would resolve to the table name workorder. That is, also assuming your resource model extends Mage_Core_Model_Resource_Db_Abstract, which it should.

To get more information, add your model and resource model classes (just the class declaration and the __construct/_construct methods.

UPDATE 2: The resource model code you added explains the issue. You use the following code to initialize the resource model:

$this->_init('workorder/workorderlineitem', 'entity_id');

But in your config XML you declare

...
<workorder_mysql4>
    <entities>
         <workorder><table>workorder</table></workorder>
    </entities>
</workorder_mysql4>

...

The part after the slash is mapped to a node within the <entities> node, which means you have to either use $this->_init('workorder/workorder', 'entity_id'); in your resource model, or .../workorder_mysql4/entities/workorderlineitem/table in the config XML.

5
  • I added the config section as you requested. Commented Dec 9, 2013 at 21:15
  • I added the code sections that you have requested. Thanks for helping. Commented Dec 9, 2013 at 21:44
  • Answered the question in Update 2.
    – Vinai
    Commented Dec 9, 2013 at 21:50
  • You need to revisit some Magento basics. You do not need to have several class groups for different models. You can have as many model/resource/collection triplets as you want within a single module.
    – Vinai
    Commented Dec 9, 2013 at 23:08
  • Thank you! Thank you! Thank you! I have it all working now! Commented Dec 10, 2013 at 14:36

Your Answer

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

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