I have a model called Warehouses and another called Warehouse Products which is associated. The issue I'm having is that Warehouse Products doesn't save, despite it's save() function being wrapped in a try-catch which produces no issues.

try {
    $session->addSuccess($this->__('The product has been saved.'));

} catch (Mage_Core_Exception $e) {
} catch (Exception $e) {
    $session->addError($this->__('An error occurred while saving this product.'));

If I use the model to return the table, I get the following:

// Can't retrieve entity config

This obviously suggests there's something amiss with my setup -


The resources section:


My files are laid out as below:

- Resource
    - Warehouse
        - Product
            - Collection.php
        - Collection.php
        - Product.php
    - Warehouse.php
- Warehouse
    - Product.php
- Warehouse.php

Is there something else I need to do?


Here's some further code
Warehouse > Product.php

class CompanyName_InventoryManagement_Model_Warehouse_Product extends Mage_Core_Model_Abstract
    protected function _construct()

Resource > Warehouse > Product.php

class CompanyName_InventoryManagement_Model_Resource_Warehouse_Product extends Mage_Core_Model_Mysql4_Abstract
    protected function _construct()
        $this->_init('inventorymanagement/warehouse_product', 'id');

Resource > Warehouse > Product > Collection.php

class CompanyName_InventoryManagement_Model_Resource_Warehouse_Product_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
    protected function _construct()
  • $model what is the value of this ? Commented Sep 3, 2014 at 14:14
  • Mage::getSingleton('inventorymanagement/warehouse_product'); which is valid, i.e. I can use this to read from the database successfully if I use getCollection()
    – Dan Hanly
    Commented Sep 3, 2014 at 14:18
  • you have values in that table too? but can't access the table ? Commented Sep 3, 2014 at 14:21
  • I manually added to the database to test, yes.
    – Dan Hanly
    Commented Sep 3, 2014 at 14:22
  • getCollection() is working. So most probably issue lies in setup resources. Can we have a look on your resource files? please show relevant config.xml part and files Commented Sep 3, 2014 at 14:24

1 Answer 1


I've figured it out.

Prior to the $model->save(); I had this:

$model = Mage::getModel('inventorymanagement/warehouse_product');
$product = $postData['warehouse_product'];
if (isset($product['id'])) {
$product['product_id'] = str_replace('product/', '', $product['product_id']);

The issue was that as $product['id'] was set as a hidden field on the form, then it was always set; thus the isset check was true. It was saving, but because the $model->load() was happening, it wasn't saving anywhere in particular.

For Addition methods, I removed this check completely along with the load statement, then I simply ran this unset($product['id']); prior to setting the data.

All working great!

  • Please mark this as accepted.
    – Marius
    Commented Nov 11, 2014 at 9:04

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.