Example #1
0
 public static function duplicateSpecificPrices($oldProductId, $productId)
 {
     foreach (SpecificPrice::getIdsByProductId((int) $oldProductId) as $data) {
         $specificPrice = new SpecificPrice((int) $data['id_specific_price']);
         if (!$specificPrice->duplicate((int) $productId)) {
             return false;
         }
     }
     return true;
 }
Example #2
0
 $target_path = $target_path . basename($_FILES['products']['name']);
 if (move_uploaded_file($_FILES['products']['tmp_name'], $target_path)) {
     $f = fopen($target_path, 'r');
     if ($f) {
         $count = 0;
         while ($line = fgetcsv($f)) {
             if (!is_numeric($line[0])) {
                 continue;
             }
             $id_product = (int) $line[0];
             $product = new Product($id_product, true, 1);
             $newPrice = (double) $line[1];
             $mrp = $product->getPriceWithoutReduct();
             $product = new Order($id_order);
             SpecificPrice::deleteByProductId($id_product);
             $specificPriceIDs = SpecificPrice::getIdsByProductId($id_product);
             if (count($specificPriceIDs) > 0) {
                 $specificPrice = new SpecificPrice((int) $specificPriceIDs[0]['id_specific_price']);
                 //delete discount if the prices are equal update otherwise
                 if (round($mrp) > round($newPrice)) {
                     $specificPrice->reduction_type = "amount";
                     $specificPrice->reduction = $mrp - $newPrice;
                     $specificPrice->update();
                 } else {
                     SpecificPrice::deleteByProductId($id_product);
                 }
             } else {
                 if (round($mrp) > round($newPrice)) {
                     $specificPrice = new SpecificPrice();
                     $specificPrice->id_product = $id_product;
                     $specificPrice->reduction_type = "amount";