There are a few things to fix up here, but here are a few tips.
i. Table models work a little better if their names are pluralized. They sound better in the magic methods (e.g. $product_set = findProducts() instead of findModel_Product())
ii. The reference map is the important one and allows for those nifty magic selection methods (e.g. findParentX()) to work. It belongs in the dependent table, which is the product
table here because it references the product_manufacturer
.
// in Model_Product
protected $_referenceMap = array(
// rule name
'Manufacturer' => array(
'columns' => 'manufacturer_id', // this column
'refTableClass' => 'Model_Manufacturer', // references that table object
'refColumns' => 'id' // and references that column
)
);
iii. Move dependent tables entry to your product_manufacturers
table model, if you'd like: it's used only to replicate ON DELETE/UPDATE CASCADE
database commands, though. (Leave it for now)
// in manufacturer table model
protected $_dependentTables = array('Model_Product');
Fetching
To get a product's manufacturer, do this:
$manufacturer = $product_row->findParentManufacturer();
To get a manufacturer's products, do this:
$product_set = $manufacturer_row->findProducts(); // Well, findModel_Product(), which is why you should rename your table ;)
For other magic methods originating from each single row, dig into the source code for Zend_Db_Table_Row_Abstract
(especially public function __call
).