属性选择magento查询
我正在尝试在 magento 中获取此查询。
从目录中选择merk,option_id.......按option_id分组
到目前为止我有这个,但不幸的是它没有显示option_id值,而且我不知道如何按它们分组...
我希望有人愿意帮助我 [代码]
<?php
function getMenuWatches(){
$collection = Mage::getModel("catalog/product")->getCollection();
$collection->addAttributeToFilter("attribute_set_id", 26);
$collection->addAttributeToSelect("option_id , merk");
return $collection;
}
$collection=getMenuWatches();
//print_r($collection);
foreach ($collection as $product){
echo $product->getOptionId();
$product->getMerk();
echo $product->getId('merk');
echo $product->getAttributeText('merk')."<br/>";
}
?>
[/code]
i am trying to get this query in magento.
Select merk, option_id from catalog ....... group by option_id
Sofar i have this but it aint showing the option_id value unfortunately and also i dont know how to group by them...
i hope someone is willing to help me
[code]
<?php
function getMenuWatches(){
$collection = Mage::getModel("catalog/product")->getCollection();
$collection->addAttributeToFilter("attribute_set_id", 26);
$collection->addAttributeToSelect("option_id , merk");
return $collection;
}
$collection=getMenuWatches();
//print_r($collection);
foreach ($collection as $product){
echo $product->getOptionId();
$product->getMerk();
echo $product->getId('merk');
echo $product->getAttributeText('merk')."<br/>";
}
?>
[/code]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
具有多个选择的属性存储为逗号分隔值。
因此,您只需要在 select 对象中添加“merk”属性:
当您迭代集合时,您可以通过调用属性值来检索选项 id:
检索值后,您需要检索每个选项 id 的选项标签
要过滤您可以使用的多个值之一:
Attributes with multiple choices are stored as comma separated values.
So you just need add "merk" attribute in select object:
and when you are iterating the collection, you may retrieve options id by calling your attribute value:
After retrieving of the values you need to retrieve option label for each option id
To filter by one of the multiple values you may use: