/** * Set brand of a specific product. This fnction will update brand for all families of the given products. * However, it will return only total successful products from the give products (updated familes are not included). * Updated products will also be automatically included in next catalog upload. * @param Int $products_id Product ID * @param Int $brand_id Brand ID * @return Int Total products updated */ function updateProductBrand($products_id, $brand_id) { use_class('products_family'); $pids = explode(',', $products_id); $n_pid = count($pids); $n_pid_success = 0; $break_the_rules = true; foreach ($pids as $products_id) { $obj_family = new products_family(null, $products_id); $is_family_locked = $obj_family->productIsFamilyLocked($products_id); if (!$is_family_locked || $break_the_rules) { $mother_is_locked = $obj_family->mother > 0 ? $obj_family->productIsFamilyLocked($obj_family->mother) : false; if (!$mother_is_locked || $break_the_rules) { $members = $obj_family->retrieveMembers(); $sda = array('products_brand_id' => $brand_id); $products_ids = is_array($members) && count($members) > 0 ? implode(',', $members) : $products_id; tep_db_perform('products', $sda, 'update', "products_id IN ({$products_ids})"); //refresh family search key to all members //we stop it since brand is already excluded from family search key // $pids_m = explode(',', $products_ids); // foreach($pids_m as $pid_m) $obj_family->refreshFamilyMatchKey($pid_m); use_class('products_minierp'); $class_pm = new products_minierp(); $class_pm->autoUpdateSalesPartnerCatalog($products_id); $n_pid_success++; } } } return $n_pid_success; }
$label_image = 'Main Image 1 (Default)'; $png_uploaded = true; } elseif ($products_clear_image != '') { $label_image = 'mi2'; $hidden_input = '<input type="hidden" name="pci_id" value="' . $pei_id . '"/>'; } elseif ($products_pure_image != '') { $label_image = 'mi3'; } else { $label_image = "Additional Image {$img_no}"; $hidden_input = '<input type="hidden" name="pei_id" value="' . $pei_id . '"/>'; $add_button = '<div style="margin:5px 0 5px 0;"><input id="rdo-ami-' . $pei_id . '" class="rdo_ami" type="radio" name="alternate-main-image" value="' . $pei_id . '" /> <label for="rdo-ami-' . $pei_id . '" class="red bold">Use as Zalando main image</label></div>'; } $result = webImage($filename, IMAGE_SIZE_THUMBNAIL_2, '', 'Product', 'img-border'); $product_image = webImageSource($filename, IMAGE_SIZE_BIG_1); if (!$png_uploaded) { $class_pm->autoUpdateSalesPartnerCatalog($products_id, true); $boximgpng = 'boximg-' . $img_name . '_png'; $img_png = $old_image_filename != '' ? false : ''; $boximg = createBoxImage($label_image, $img_name, $filename, $product_image, $img_png, '', $hidden_input, $add_button); } else { $class_pm->autoUpdateSalesPartnerCatalog($products_id); $boximgpng = 'boximg-' . $img_name; $boximg = createBoxImagePNG($label_image, $img_name, $filename, $product_image); } } $result = array(); $result['error'] = $err_images_size; $result['boxid'] = "boximg-{$img_name}"; $result['boxidpng'] = $boximgpng; $result['boximg'] = $boximg; $result['pngupload'] = $png_uploaded;