且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Magento 将产品批量分配到类别

更新时间:2022-06-25 16:49:40

我设法用以下代码解决了这个问题:

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 : 在这里.

@nachito : here it is.