我正在建立一个产品集合,它将从multiselect属性中找到结果。
(将finset添加到集合中的相关代码-调整为显示真实ID值)
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'measurement');
$value = array('finset' => array('237',
'236',
'235',
'234',
'233',));
$collection->addAttributeToFilter($attribute, $value);
产生的sql(添加了可见性过滤器)是这样的:
SELECT DISTINCT
e . *,
at_measurement.value AS measurement,
at_visibility.value AS visibility
FROM
catalog_product_entity AS e
INNER JOIN
catalog_product_entity_varchar AS at_measurement ON (at_measurement.entity_id = e.entity_id) AND (at_measurement.attribute_id = '983') AND (at_measurement.store_id = 0)
INNER JOIN
catalog_product_entity_int AS at_visibility ON (at_visibility.entity_id = e.entity_id) AND (at_visibility.attribute_id = '526') AND (at_visibility.store_id = 0)
WHERE
(e.attribute_set_id IN ('74')) AND (FIND_IN_SET('237',
'236',
'235',
'234',
'233',
at_measurement.value)) AND (at_visibility.value IN ('2' , '4'))
GROUP BY e.entity_id
问题是我得到一个SQL错误:
"SQLSTATE[42000]: Syntax error or access violation: 1582 Incorrect parameter count in the call to native function 'FIND_IN_SET'"
并且我(认为)我明白为什么:一些多选值只有一个选项,因此没有逗号分隔的值可以使用FINSET
我是否正确为什么会产生此错误?如何编写此收集对象以解决此问题?
如果不是以上情况,我想念什么?
在mysql工作台中运行sql的结果减去find_in_set子句:
1
的重复:magento.stackexchange.com/questions/14109/...
—
ProxiBlue