gpt4 book ai didi

Magento addFieldToFilter 允许 NULL

转载 作者:行者123 更新时间:2023-12-04 02:30:18 32 4
gpt4 key购买 nike

使用 Magento 收集方法 addFieldToFilter 时是否可以允许按 NULL 值进行过滤?我想选择集合中具有自定义属性的所有产品,即使没有为该属性分配任何值。

最佳答案

您不需要使用 addFieldToFilter .

现在解决办法:
属性名称被称为 code在 magento 中,您只需要使用下面的代码来获取所有具有特定属性的产品作为数组


$prodsArray=Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('custom_attribute_code')
->getItems();

you can also specify certain conditions for attribute's value in addAttributeToFilter in the second parameter of addAttributeToFilter.

you can find this method in this file (for further study):

app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php

关于Magento addFieldToFilter 允许 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1768127/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com