根据自定义属性对magento产品集合进行排序
我在magento中创建了一个自定义属性(其代码是sort\u order\u product),它存储数字,如1,2,3,4,5。。。我想获取根据sort\u order\u product排序的产品,我正在使用query获取产品根据自定义属性对magento产品集合进行排序,magento,sorting,product,Magento,Sorting,Product,我在magento中创建了一个自定义属性(其代码是sort\u order\u product),它存储数字,如1,2,3,4,5。。。我想获取根据sort\u order\u product排序的产品,我正在使用query获取产品 $collection = Mage::getModel('catalog/product') ->getCollection() ->joinField('category_id', 'catalog
$collection = Mage::getModel('catalog/product')
->getCollection()
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
->addAttributeToSelect('*')
->addAttributeToFilter('category_id', array('in' => $categoryIds))
->setOrder('sort_order_product', 'ASC');
但这并没有达到预期的效果。请让我知道我的错误。
提前感谢。您可以从管理员处执行以下步骤: 进入目录->属性->管理属性,然后单击排序\u订单\u产品进行编辑,然后从编辑屏幕中选择 产品清单中使用的集合=是 用于产品列表中的排序=是 并保存属性并清除缓存。 如果需要,请重新索引数据 现在按如下方式筛选集合:
$collection = Mage::getModel('catalog/product')
->getCollection()
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
->addAttributeToSelect('*')
->addAttributeToFilter('category_id', array('in' => $categoryIds))
->addAttributeToSort('sort_order_product', 'ASC');
在将“为商店所有者输入验证”设置为“整数”后,此操作起作用。我已经完成了这些步骤,但它也没有按照自定义属性的排序顺序提供产品列表。请确保在存储表自定义属性的数据库中,属性为整数类型?我需要在哪个表中检查自定义属性属性?有9个表的eav_属性作为前缀/后缀。我们的属性是整数类型,因此它应该位于表目录_产品_实体_int中。要更好地理解,请参阅