3

Looking over the magento 1.5 schema I cannot seem to figure out how a product_id relates to an entity_id.

In all my test cases I can verify that the product_id and entity_id are equal (the same int). But I am guessing that somewhere this is a relationship and even though they are equal in my test cases, it's likely this is only a coincidence and not something I should depend on.

In what tables or relationships can I find what this link is so that I can write a reliable query.

I'm just looking for something like this... tho it probably won't be this simple.

select entity_id from <wherever> where product_id = 1234
RThomas
  • 10,702
  • 2
  • 48
  • 61
  • "Write a reliable query", I must know more. – benmarks Apr 03 '12 at 02:54
  • I was trying to update one of my custom attributes based on the is_in_stock field in the inventory table. The attributes are stored by entity_id but the in stock status is stored by product_id. So, until I verified that these are the same I figured I was going to have to do my updates via subquery. But, alas, it was way easier than I thought. – RThomas Apr 03 '12 at 04:13
  • In short I saved myself 2 hours of manual labor by spending 2 hours researching an update query that ran in several milliseconds. All in all a fair trade :) since I learned something new. – RThomas Apr 03 '12 at 04:35
  • Sure. The FK for products will always have to be `catalog_product_entity.entity_id`; nut now you know that with certainty! – benmarks Apr 03 '12 at 13:46
  • Most of the time they are the same, but when you use the Schedule New Update feature in the background, they become inconsistent. – Tokey Tu Jan 07 '19 at 09:57

1 Answers1

8

As per Magento forum post by a Magento Team member entity_id on the EAV side is in fact the same as the product_id on the catalog product end. So, there you go.

RThomas
  • 10,702
  • 2
  • 48
  • 61