How does Magento key a product group to a product in the database

大城市里の小女人 提交于 2020-01-15 15:28:38

问题


From a SQL Query I need to know how does magento key the related products to the actual product itself. I read a lot of useful tips on how to do with with php

$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSort('name', 'ASC');

But I need to know how to identity these groups to a id with mysql.


回答1:


For a related product Magento uses catalog_product_link table.

In it you have product id, related product and link type.

To see all link types you can check the catalog_product_link_type table.

SELECT link.link_id, link.product_id, link.linked_product_id, link.link_type_id, type.code 
FROM catalog_product_link link 
  LEFT JOIN catalog_product_link_type type ON link.link_type_id = type.link_type_id
WHERE 
  code = 'super' -- grouped products
  AND linked_product_id IN (123456) -- child simple product(s)
;

More extensive information can be found with this link: online Database Diagram Tool dedicated to Magento eCommerce CE Edition



来源:https://stackoverflow.com/questions/9425959/how-does-magento-key-a-product-group-to-a-product-in-the-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!