我尝试将过滤器应用于报价项集合,我使用此
获取集合$items_collection = Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection();
$items_collection->addFieldToFilter('product_id', $_product->getId());
当我打印出选择查询时,查询是正确的
$items_collection->getSelect()
但是当我遍历集合时,它正在获取所有项目,它没有应用过滤器,有人知道为什么吗?
foreach ($items_collection as $item) {
// Do things....
}
答案 0 :(得分:1)
试试这个。使用getModel而不是getSingleton。
Traceback (most recent call last):
File "script.py", line 42, in <module>
print("all_feature:\n\t{0} {1} {2}".format("".join(map(str,gen1)),check(gen1,tr_d,tr_l,te_d,te_l),len(gen1)))
File "script.py", line 31, in check
al_data=np.array([al[mask] for al in tr_d])
File "script.py", line 31, in <listcomp>
al_data=np.array([al[mask] for al in tr_d])
TypeError: only integer scalar arrays can be converted to a scalar index