<?php define('MAGENTO_ROOT', getcwd()); include_once "app/Mage.php"; ini_set('display_errors', 1); error_reporting(E_ALL | E_STRICT); Mage::init(); Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); umask(0); Mage::app('admin'); set_time_limit(0); ini_set('memory_limit', '2048M'); $categoryId = Mage::app()->getRequest()->getParam('catid'); $category = Mage::getModel('catalog/category')->load($categoryId); $allProducts = $category->getProductsPosition(); foreach ($category->getChildrenCategories() as $child) { $childProducts = $child->getProductsPosition(); foreach($childProducts as $productId=>$position) { if(!array_key_exists($productId,$allProducts)) { $allProducts[$productId] = $position; } } } $category->setPostedProducts($allProducts)->save(); echo "Product Assigned successfully"; ?>
Categories: Magento
0 Comments