Questions tagged «collection-filtering»


3
使用LIKE过滤结果
考虑以下三个“干草堆”字符串: 一种) foo bar b) welcome to foo bar industries C) foo barer 现在我的“针”: foo bar (呵呵) 我希望我的过滤器使我的针头与干草堆字符串a和b匹配,但不与c匹配。我试过了: $collection->addAttributeToFilter('name', array('like' => '%'.$needle.'%')); 但以上与c匹配。 我也尝试过: $collection->addAttributeToFilter('name', array('like' => '% '.$needle.' %')); // Note the spaces 以上仅与b匹配。 任何帮助深表感谢。

2
在集合中使用group子句时,网格分页不起作用
我在产品网格上工作,但是其分页或产品计数不起作用(因为它显示的计数错误)。由于我的_preparecollection块的功能如下。我在集合中添加了类别过滤器代码,因此我必须使用group子句来防止相同ID已存在的错误。 protected function _prepareCollection() { $store = $this->_getStore(); $collection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('sku') ->addAttributeToSelect('name') ->addAttributeToSelect('attribute_set_id') ->addAttributeToSelect('type_id') ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left'); $collection->addAttributeToFilter('category_id', array('in' => array(4,10))) ->distinct(true); $collection->getSelect()->group('e.entity_id'); if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) { $collection->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left'); } $collection->joinField('position', 'catalog/category_product', 'position', 'product_id=entity_id', null, 'left'); $collection->joinField('websites', 'catalog/product_website', 'website_id', 'product_id=entity_id', null, 'left'); if …

2
如何收集可以发货的订单?
我需要尚未发货或部分发货的订单。我正在使用以下代码来获取可以发货的订单。 foreach ($orderIds as $orderId) { $order = Mage::getModel('sales/order')->load($orderId); if ($order->canShip()) { echo "Shipping Pending"; } } 但是我不想使用foreach。我需要下面的东西。 Mage::getModel('sales/order')->getCollection() ->addFieldToFilter('status','can_ship');
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.