خرید بک لینک

Vote count: 0

I'm trying to all products from 1 category into another in Magento? Has anyone been able to do this using a script? We have over 6000 products and doing it 1 by 1 or through the import seems to be causing me an issue... haha

I've tried this script but it doesn't want to work, we're ruing 1.9.2.4.

<?php
require_once ( "app/Mage.php" );
umask(0);

// Initialize Magento
Mage::app();

$category = Mage::getModel('catalog/category');
$category->load('24'); // Category i want to copy?
$collection = $category->getProductCollection();
$collection->addAttributeToSelect('*');
foreach ($collection as $product) {
       $product->getId();
       $categories = $product->getCategoryIds();
       $categories[] = 29; // Category id I want to copy too?
       $product->setCategoryIds($categories);
       $product->save();
}
?>

Can anyone shed any light on it?

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 31 فروردين 1395 ساعت: 4:23

صفحه بندی