Magento 捆绑项目按父 ID 过滤
我正在尝试获取选择的集合,但根据父产品的 ID 进行过滤。该集合包含一个属性 parent_product_id
但显然这不起作用...不考虑过滤器。
这就是我到目前为止所拥有的:
$children = Mage::getResourceModel('bundle/selection_collection')
->addAttributeToSelect(array('product_id', 'selection_price_value'))
->setStoreId(Mage::app()->getStore()->getId())
->addAttributeToFilter('parent_product_id',$item->getProductId());
它返回所有选择的集合,因此没有过滤器。有什么方法可以只获取一种特定捆绑产品的选择吗?请注意,我使用此方法是有原因的......它应该仅基于父 ID。
I'm trying to get a collection of selections but filtered on the parent product's id. The collection contains an attribute parent_product_id
but apparently this isn't working... The filter is not taken into account.
This is what I have so far:
$children = Mage::getResourceModel('bundle/selection_collection')
->addAttributeToSelect(array('product_id', 'selection_price_value'))
->setStoreId(Mage::app()->getStore()->getId())
->addAttributeToFilter('parent_product_id',$item->getProductId());
It returns a collection of all selections, so without filter. Is there some way to get only the selections of one specific bundled product? Please note I am using this method for a reason... It should be only based on the parent id.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议检查该集合是如何构造查询的:
检查您的过滤器是否确实存在(在 WHERE 子句中)并针对您的数据库运行提取的 SQL 查询(如果您有 shell 访问权限,则在 PhpMyAdmin 或 mysql-client 中)。您应该看到问题的根源。
您还可以尝试一种脏方法,并弄乱集合的
Zend_Select
对象:I would suggest to check how the query is constructed by the collection:
Check if your filter is really there (in the WHERE clause) and run the extracted SQL Query against your database (in PhpMyAdmin or mysql-client if you have shell access). You should see the source of the problem.
You could also try a dirty method, and mess whit the
Zend_Select
object of the collection:尝试以下操作:
某些字段是属性,其他字段只是该表中的字段。
查看此文件中的一些示例:
/app/code/core/Mage/Bundle/Model/Product/Type.php
Try the following:
Some fields are attributes, others are just fields within that table.
Look at this file for some samples:
/app/code/core/Mage/Bundle/Model/Product/Type.php