Skip to main content
2 of 3
edited title
Moose
  • 7.5k
  • 7
  • 49
  • 92

How to fetch values from 2 tables based on the first table's values

I have developed a custom module which includes three DB tables. I need to fetch values from one table and then based on that value fetch values from second table.

For ex below is the table description:

**deal_offers** : entity_id | deal_name | deal_discount

**deal_products** : deal_id | product_id

In my observer, I am getting product_id value. Now for say product_id, what I want to achieve is

  1. First, fetch deal_id value from table deal_products, using the value of product_id

  2. Next, fetch deal_discount value, using deal_id which is the entity_id in table deal_offers

I have defined <entities> in my config.xml for these two tables, but not getting success in achieving the desired result using Mage::getModel('module/model') method in my observer.

Please Help

Thanks Thanks

Jordan
  • 233
  • 2
  • 8