Magento:自定义模块:如何管理多个表 [英] Magento: Custom Module: How to Manage with Multiple tables
问题描述
我正在研究magento自定义模块[由模块创建者创建]. 需要创建一个子表,以通过主/外键引用维护与默认/父表的关系.
I am working on magento custom module [created by module creator]. There is a requirement to create a Child table which maintains the relation to the default/parent table by means of primary/foreign key references.
父子表之间存在一对多关系.
There is a one-to-many relation from parent-to-child table.
我需要具有Grid界面和Edit界面才能更新/保存所有相关数据.
I need to have the Grid interface and Edit interface to update/save all relevant data.
请提供给我管理该模块的方法.
Please, provide me the way to manage this module.
我刚刚尝试了默认数据收集的join子句,如下所示:
I have just tried the join clause on default data collection as below:
==============================
===============================
在受保护的函数_prepareCollection()中,位于"\ app \ code \ local \ Klimaire \ WarrantyRegProd \ Block \ Adminhtml \ WarrantyRegProd \"中
In protected function _prepareCollection() At "\app\code\local\Klimaire\WarrantyRegProd\Block\Adminhtml\WarrantyRegProd\"
$ collection-> getSelect()-> joinLeft('warrantyregprod_child','main_table.warrantyregprod_id =保修regprod_child.warrantyregprodID','warrantyregprod_child.prodcode');
$collection->getSelect()->joinLeft('warrantyregprod_child','main_table.warrantyregprod_id = warrantyregprod_child.warrantyregprodID', 'warrantyregprod_child.prodcode');
==============================
===============================
推荐答案
您要的是Magento的一个非常高级的方面(自定义Admin代码和功能).我建议您接受在线或面对面的培训,因为这在stackoverflow答案中很难描述(我接受了培训,说实话,这是一个10步的过程,大约需要一个小时才能复制/粘贴演示代码-自定义工作可能需要4到6个小时才能完成).您的问题也有些不完整-如果您遇到特定于sql的问题,则需要更多信息.您也不希望从块中调用select语句-这些语句应由模型管理,并且还应从模型中调用集合.
What you are asking for is a very advanced aspect of Magento (custom Admin code and functionality). I would suggest you go through online or in-person training as this is far to complex to describe in a stackoverflow answer (I went through training, and this is honestly a 10-step process that takes about an hour just to copy/paste demo code -- custom work will probably be anywhere from 4-6 hours to complete). Your question is also somewhat incomplete -- need more info if you are having sql-specific problems. You also never want to call select statements from a Block - these should be managed by Models, and you should also call your collections from your Models.
这篇关于Magento:自定义模块:如何管理多个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!