I want to save the product position based on the category. I have checked and no help available related to this.

So, please help me in saving product position based on category programmatically in Magento.

  • Could you please elaborate your question, try adding an example
    – Dexter
    Jun 30 '17 at 10:42
  • yes, needed more info to understand the exact outcomes Jun 30 '17 at 10:44
  • What version Magento you are using? Jun 30 '17 at 12:52

To save product position in category programmatically in magento, Use below code:

$categoryIds = $_product->getCategoryIds(); 
$api = Mage::getSingleton('catalog/category_api');
foreach ($categoryIds as $categoryId) {
    $api->assignProduct($categoryId, $productId, $productPosition);

Note: if you are saving product data then use this code after $_product->save();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.