/** * Copies products. * * @author Alexander Girin * @param integer $newParentCatId the new category id, to which products * are copied * @param array $catsprods the array of copied products and respective categories to which the products need to be copied * @return */ function copyProducts($catsprods) { // copy results $_copy_result = array(); $parentCategoriesList = array(); $current_language = modApiFunc('MultiLang', 'getLanguage'); modApiFunc('MultiLang', 'setLanguage', modApiFunc('MultiLang', 'getDefaultLanguage')); foreach ($catsprods as $pId => $newParentCatId) { $prd = new CProductInfo($pId); $new_pId = $prd->clone_to_category($newParentCatId); $parentCategoriesList = array_merge($parentCategoriesList, $prd->getCategoriesIDs()); //$prd->getProductTagValue('categoryid'); $prd = null; // adding copy result $_copy_result[$pId] = $new_pId; } modApiFunc('MultiLang', 'setLanguage', $current_language); // saving copy results to session modApiFunc("Session", "set", "CopyProductsResult", $_copy_result); modApiFunc('EventsManager', 'throwEvent', 'ProductsCopied', array('PRODUCT_ID_LIST' => $_copy_result, 'SOURCE_CATEGORY_LIST' => $parentCategoriesList, 'TARGET_CATEGORY_ID' => $newParentCatId)); }