I have a collection of products.
$_products = Mage::getModel('catalog/product')->getCollection();
In the admin panel in the catalog-> Category Management-> Product Category, I have a position for each product. How can I sort $ _products by position?
, new products "position". , . , , "" . , 'position' (product).
$category_id.
//Load the category model $category = Mage::getModel('catalog/category')->load($category_id) ->getProductCollection() ->addAttributeToSort('position', 'ASC'); $products_list = $category->getData();
, $category_id
, ,
$category = Mage::getModel('catalog/category')->load($categoryId); $collection = Mage::getResourceModel('catalog/product_collection'); $collection->addCategoryFilter($category); $collection->addAttributeToSort('position', 'ASC');
Source: https://habr.com/ru/post/1610083/More articles:Removing rows from table 1 based on rows in table 2 - sql-serverHow to add this condition to it and make it optimal? - c ++Is it possible to create an instance of a template if there is a nested type (not available) using a method that cannot be compiled? - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1610081/jenkins-is-unable-to-access-svn-repository&usg=ALkJrhhZ9qJq6JB8JwfQM9XLs4DRFigFJQPhpStorm - rearrangement - intellij-ideaCreating a structure that requires (depends on) another structure - iosDynamically initialize instance with javascript ES6 class - javascriptCentering PickerIOS in real life - iosWhere should I do django checks for objects and fields? - pythonCreate a .war file using maven. Missing files and directories - javaAll Articles