Magento mass-assign products to category

前端 未结 4 1631
忘了有多久
忘了有多久 2021-01-14 06:58

As the title says,i need to mass-assign products to a category and from the admin i can only edit one product at a time; i dont know why it just doesnt work to mass add them

4条回答
  •  逝去的感伤
    2021-01-14 08:02

    I managed to resolve the problem with the following code :

    $write = Mage::getSingleton('core/resource')->getConnection('core_write');
    $x = 1171;
    $y = 2000;
    $categoryID = 4;
    $productPosition = 0;
    while($x <= $y) {
    $write->query("REPLACE INTO `catalog_category_product` (`category_id`, `product_id`,  `position`) VALUES ($categoryID, $x++, $productPosition)");
    }
    echo "The job is done";
    ?>
    

    I hope the code is clear for everyone,if it's not,reply and i'll try to explain it.

    @nachito : here it is.

提交回复
热议问题