Question

En ce qui concerne la réponse de Vinai ici https://magento.stackexchange.com/a/5775/199 J'ai une question de suivi:

Comment puis-je obtenir le tableau de ProductPosition lors de l'utilisation des tables de catégorie plat?

Dans ma configuration du système que j'utilise ces paramètres:

Catalog -> Frontend -> Use Flat Catalog Category = yes
Catalog -> Frontend -> Use Flat Catalog Product  = yes

Quand j'utilise getProductsPosition() je reçois ce qui suit:

Fatal error: Call to undefined method  Mage_Catalog_Model_Resource_Category_Flat::getProductsPosition() in [...]/app/code/core/Mage/Catalog/Model/Category.php on line 318

Toutes les idées?

Merci à l'avance:)

Était-ce utile?

La solution

This should work.

$categoryId = '46'; //replace with your own
$category = Mage::getModel('catalog/category')->load($categoryId);
$positions = Mage::getResourceModel('catalog/category')->getProductsPosition($category);

This ignores the 'Flat categories' flag. It goes directly to the category resource model.

You can even skip the category loading for performance. and just pass as parameter an object that has an id parameter.

$categoryId = '46'; //replace with your own
$category = new Varien_Object(array('id'=>$categoryId));
$positions = Mage::getResourceModel('catalog/category')->getProductsPosition($category);
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top