コード例 #1
0
 /**
  * For a given product and supplier, gets the product supplier data
  *
  * @param int $id_product
  * @param int $id_product_attribute
  * @param int $id_supplier
  * @return array
  */
 public function getProductSupplierData($id_product, $id_product_attribute, $id_supplier)
 {
     return \ProductSupplierCore::getProductSupplierData($id_product, $id_product_attribute, $id_supplier);
 }
コード例 #2
0
 public static function getWholesalePrice($id_product, $id_product_attribute = 0, $id_supplier = 0)
 {
     // If there's a supplier
     if (!empty($id_supplier)) {
         // Fetch supplier's price first
         $prices = ProductSupplierCore::getProductSupplierPrice($id_product, $id_product_attribute, $id_supplier, true);
         if (isset($prices['product_supplier_price_te'])) {
             $price = $prices['product_supplier_price_te'];
         }
     }
     // If no price for this supplier, or supplier's price null, we look for the price of the product or variation
     if (empty($price) || $price == '0.000000') {
         // If no variation, look for product's price
         if ($id_product_attribute == 0) {
             $query = new DbQuery();
             $query->select('wholesale_price');
             $query->from('product');
             $query->where('id_product = ' . (int) $id_product);
             $price = Db::getInstance()->getValue($query);
         } else {
             $query = new DbQuery();
             $query->select('p.wholesale_price as wholesale_price_product, pa.wholesale_price as wholesale_price_product_attribute');
             $query->from('product_attribute', 'pa');
             $query->where('pa.id_product = ' . (int) $id_product);
             $query->where('pa.id_product_attribute = ' . (int) $id_product_attribute);
             $query->innerJoin('product', 'p', ' p.id_product = pa.id_product');
             $prices = Db::getInstance()->getRow($query);
             // If variation's price
             if (!empty($prices['wholesale_price_product_attribute']) and $prices['wholesale_price_product_attribute'] != '0.000000') {
                 $price = $prices['wholesale_price_product_attribute'];
             } elseif (!empty($prices['wholesale_price_product']) and $prices['wholesale_price_product'] != '0.000000') {
                 $price = $prices['wholesale_price_product'];
             } else {
                 $price = '0.00000';
             }
         }
     }
     return $price;
 }