开发者

FK and M2M realtions in Magento

How can I use fk and m2m relations in mag开发者_如何学Pythonento? I read about EAV and I understand the benefits but I don't understand how to approach common problems in relational databases.

For example, I have products that should match several type of cars. Each car has make,model,year. With regular tables I'll have a Car table and I'll have m2m relation from each product to this table. Then, I can filter by car and reference the user's car in the order.

How can I implement cars and relate them to products in magento and how can I save the user's car in the order?

Thanks


The ORM Provided by Magento's Framework does not support many to many relationships. If you need to provide this type of functionality for additional Magento functionality you'll need to use a different ORM system, or write your SQL queries manually.

If you want to stick to the Magento core files, I'd investigate the Zend_Db* files that come bundled in lib.

Remember, while there's a lot of cool Framework features in Magento, it wasn't built to be a general purpose development framework. It was built to service the needs of Varien/Magento Inc in building an Ecommerce Platform.


I've created a custom DB table and manage the m2m relation myself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜