• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ProductSupplier类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ProductSupplier的典型用法代码示例。如果您正苦于以下问题:PHP ProductSupplier类的具体用法?PHP ProductSupplier怎么用?PHP ProductSupplier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ProductSupplier类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: delete

 /**
  * @see ObjectModel::delete()
  */
 public function delete()
 {
     $res = parent::delete();
     if ($res && $this->id_product_attribute == 0) {
         $items = ProductSupplier::getSupplierCollection($this->id_product, false);
         foreach ($items as $item) {
             if ($item->id_product_attribute > 0) {
                 $item->delete();
             }
         }
     }
     return $res;
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:16,代码来源:ProductSupplier.php


示例2: setDetailProductPrice

 protected function setDetailProductPrice(Order $order, Cart $cart, $product)
 {
     $this->setContext((int) $product['id_shop']);
     $specific_price = $null = null;
     Product::getPriceStatic((int) $product['id_product'], true, (int) $product['id_product_attribute'], 6, null, false, true, array($product['cart_quantity'], $product['cart_quantity_fractional']), false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, $this->context);
     $this->specificPrice = $specific_price;
     $this->original_product_price = Product::getPriceStatic($product['id_product'], false, (int) $product['id_product_attribute'], 6, null, false, false, 1, false, null, null, null, $null, true, true, $this->context);
     $this->product_price = $this->original_product_price;
     $this->unit_price_tax_incl = (double) $product['price_wt'];
     $this->unit_price_tax_excl = (double) $product['price'];
     $this->total_price_tax_incl = (double) $product['total_wt'];
     $this->total_price_tax_excl = (double) $product['total'];
     $this->purchase_supplier_price = (double) $product['wholesale_price'];
     if ($product['id_supplier'] > 0 && ($supplier_price = ProductSupplier::getProductPrice((int) $product['id_supplier'], $product['id_product'], $product['id_product_attribute'], true)) > 0) {
         $this->purchase_supplier_price = (double) $supplier_price;
     }
     $this->setSpecificPrice($order, $product);
     $this->group_reduction = (double) Group::getReduction((int) $order->id_customer);
     $shop_id = $this->context->shop->id;
     $quantity_discount = SpecificPrice::getQuantityDiscount((int) $product['id_product'], $shop_id, (int) $cart->id_currency, (int) $this->vat_address->id_country, (int) $this->customer->id_default_group, (int) PP::resolveQty($product['cart_quantity'], $product['cart_quantity_fractional']), false, null, null, $null, true, true, $this->context);
     $unit_price = Product::getPriceStatic((int) $product['id_product'], true, $product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null, 2, null, false, true, 1, false, (int) $order->id_customer, null, (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}, $null, true, true, $this->context);
     $this->product_quantity_discount = 0.0;
     if ($quantity_discount) {
         $this->product_quantity_discount = $unit_price;
         if (Product::getTaxCalculationMethod((int) $order->id_customer) == PS_TAX_EXC) {
             $this->product_quantity_discount = Tools::ps_round($unit_price, 2);
         }
         if (isset($this->tax_calculator)) {
             $this->product_quantity_discount -= $this->tax_calculator->addTaxes($quantity_discount['price']);
         }
     }
     $this->discount_quantity_applied = $this->specificPrice && $this->specificPrice['from_quantity'] > PP::getSpecificPriceFromQty((int) $product['id_product']) ? 1 : 0;
     $this->id_cart_product = (int) $product['id_cart_product'];
     $this->product_quantity_fractional = (double) $product['cart_quantity_fractional'];
     $ppropertiessmartprice_hook3 = null;
 }
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:36,代码来源:OrderDetail.php


示例3: supplyOrdersDetailsImportOne

    protected function supplyOrdersDetailsImportOne($info, &$products, &$reset, $force_ids, $current_line, $validateOnly = false)
    {
        // sets default values if needed
        AdminImportController::setDefaultValues($info);
        // gets the supply order
        if (array_key_exists('supply_order_reference', $info) && pSQL($info['supply_order_reference']) && SupplyOrder::exists(pSQL($info['supply_order_reference']))) {
            $supply_order = SupplyOrder::getSupplyOrderByReference(pSQL($info['supply_order_reference']));
        } else {
            $this->errors[] = sprintf($this->l('Supply Order (%s) could not be loaded (at line %d).'), $info['supply_order_reference'], $current_line + 1);
        }
        if (empty($this->errors)) {
            // sets parameters
            $id_product = (int) $info['id_product'];
            if (!$info['id_product_attribute']) {
                $info['id_product_attribute'] = 0;
            }
            $id_product_attribute = (int) $info['id_product_attribute'];
            $unit_price_te = (double) $info['unit_price_te'];
            $quantity_expected = (int) $info['quantity_expected'];
            $discount_rate = (double) $info['discount_rate'];
            $tax_rate = (double) $info['tax_rate'];
            // checks if one product/attribute is there only once
            if (isset($products[$id_product][$id_product_attribute])) {
                $this->errors[] = sprintf($this->l('Product/Attribute (%d/%d) cannot be added twice (at line %d).'), $id_product, $id_product_attribute, $current_line + 1);
            } else {
                $products[$id_product][$id_product_attribute] = $quantity_expected;
            }
            // checks parameters
            if (false === ($supplier_reference = ProductSupplier::getProductSupplierReference($id_product, $id_product_attribute, $supply_order->id_supplier))) {
                $this->errors[] = sprintf($this->l('Product (%d/%d) is not available for this order (at line %d).'), $id_product, $id_product_attribute, $current_line + 1);
            }
            if ($unit_price_te < 0) {
                $this->errors[] = sprintf($this->l('Unit Price (tax excl.) (%d) is not valid (at line %d).'), $unit_price_te, $current_line + 1);
            }
            if ($quantity_expected < 0) {
                $this->errors[] = sprintf($this->l('Quantity Expected (%d) is not valid (at line %d).'), $quantity_expected, $current_line + 1);
            }
            if ($discount_rate < 0 || $discount_rate > 100) {
                $this->errors[] = sprintf($this->l('Discount rate (%d) is not valid (at line %d). %s.'), $discount_rate, $current_line + 1, $this->l('Format: Between 0 and 100'));
            }
            if ($tax_rate < 0 || $tax_rate > 100) {
                $this->errors[] = sprintf($this->l('Quantity Expected (%d) is not valid (at line %d).'), $tax_rate, $current_line + 1, $this->l('Format: Between 0 and 100'));
            }
            // if no errors, sets supply order details
            if (empty($this->errors)) {
                // resets order if needed
                if (!$validateOnly && $reset) {
                    $supply_order->resetProducts();
                    $reset = false;
                }
                // creates new product
                $supply_order_detail = new SupplyOrderDetail();
                AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supply_order_detail);
                // sets parameters
                $supply_order_detail->id_supply_order = $supply_order->id;
                $currency = new Currency($supply_order->id_ref_currency);
                $supply_order_detail->id_currency = $currency->id;
                $supply_order_detail->exchange_rate = $currency->conversion_rate;
                $supply_order_detail->supplier_reference = $supplier_reference;
                $supply_order_detail->name = Product::getProductName($id_product, $id_product_attribute, $supply_order->id_lang);
                // gets ean13 / ref / upc
                $query = new DbQuery();
                $query->select('
					IFNULL(pa.reference, IFNULL(p.reference, \'\')) as reference,
					IFNULL(pa.ean13, IFNULL(p.ean13, \'\')) as ean13,
					IFNULL(pa.upc, IFNULL(p.upc, \'\')) as upc
				');
                $query->from('product', 'p');
                $query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product AND id_product_attribute = ' . (int) $id_product_attribute);
                $query->where('p.id_product = ' . (int) $id_product);
                $query->where('p.is_virtual = 0 AND p.cache_is_pack = 0');
                $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
                $product_infos = $res['0'];
                $supply_order_detail->reference = $product_infos['reference'];
                $supply_order_detail->ean13 = $product_infos['ean13'];
                $supply_order_detail->upc = $product_infos['upc'];
                $supply_order_detail->force_id = (bool) $force_ids;
                if (!$validateOnly) {
                    $supply_order_detail->add();
                    $supply_order->update();
                }
                unset($supply_order_detail);
            }
        }
    }
开发者ID:M03G,项目名称:PrestaShop,代码行数:85,代码来源:AdminImportController.php


示例4: ajaxProcessSearchProduct

    /**
     * method call when ajax request is made for search product to add to the order
     * @TODO - Update this method to retreive the reference, ean13, upc corresponding to a product attribute
     */
    public function ajaxProcessSearchProduct()
    {
        // Get the search pattern
        $pattern = pSQL(Tools::getValue('q', false));
        if (!$pattern || $pattern == '' || strlen($pattern) < 1) {
            die;
        }
        // get supplier id
        $id_supplier = (int) Tools::getValue('id_supplier', false);
        // gets the currency
        $id_currency = (int) Tools::getValue('id_currency', false);
        // get lang from context
        $id_lang = (int) Context::getContext()->language->id;
        $query = new DbQuery();
        $query->select('
			CONCAT(p.id_product, \'_\', IFNULL(pa.id_product_attribute, \'0\')) as id,
			ps.product_supplier_reference as supplier_reference,
			IFNULL(pa.reference, IFNULL(p.reference, \'\')) as reference,
			IFNULL(pa.ean13, IFNULL(p.ean13, \'\')) as ean13,
			IFNULL(pa.upc, IFNULL(p.upc, \'\')) as upc,
			md5(CONCAT(\'' . _COOKIE_KEY_ . '\', p.id_product, \'_\', IFNULL(pa.id_product_attribute, \'0\'))) as checksum,
			IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(DISTINCT agl.name, \' - \', al.name order by agl.name SEPARATOR \', \')), pl.name) as name
		');
        $query->from('product', 'p');
        $query->innerJoin('product_lang', 'pl', 'pl.id_product = p.id_product AND pl.id_lang = ' . $id_lang);
        $query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product');
        $query->leftJoin('product_attribute_combination', 'pac', 'pac.id_product_attribute = pa.id_product_attribute');
        $query->leftJoin('attribute', 'atr', 'atr.id_attribute = pac.id_attribute');
        $query->leftJoin('attribute_lang', 'al', 'al.id_attribute = atr.id_attribute AND al.id_lang = ' . $id_lang);
        $query->leftJoin('attribute_group_lang', 'agl', 'agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = ' . $id_lang);
        $query->leftJoin('product_supplier', 'ps', 'ps.id_product = p.id_product AND ps.id_product_attribute = IFNULL(pa.id_product_attribute, 0)');
        $query->where('(pl.name LIKE \'%' . $pattern . '%\' OR p.reference LIKE \'%' . $pattern . '%\' OR ps.product_supplier_reference LIKE \'%' . $pattern . '%\')');
        $query->where('p.id_product NOT IN (SELECT pd.id_product FROM `' . _DB_PREFIX_ . 'product_download` pd WHERE (pd.id_product = p.id_product))');
        $query->where('p.is_virtual = 0 AND p.cache_is_pack = 0');
        if ($id_supplier) {
            $query->where('ps.id_supplier = ' . $id_supplier . ' OR p.id_supplier = ' . $id_supplier);
        }
        $query->groupBy('p.id_product, pa.id_product_attribute');
        $items = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
        foreach ($items as &$item) {
            $ids = explode('_', $item['id']);
            $prices = ProductSupplier::getProductSupplierPrice($ids[0], $ids[1], $id_supplier, true);
            if (count($prices)) {
                $item['unit_price_te'] = Tools::convertPriceFull($prices['product_supplier_price_te'], new Currency((int) $prices['id_currency']), new Currency($id_currency));
            }
        }
        if ($items) {
            die(Tools::jsonEncode($items));
        }
        die(1);
    }
开发者ID:zangles,项目名称:lennyba,代码行数:55,代码来源:AdminSupplyOrdersController.php


示例5: addSupplierReference

 /**
  * Sets Supplier Reference
  *
  * @param int $id_supplier
  * @param int $id_product_attribute
  * @param string $supplier_reference
  * @param float $price
  * @param int $id_currency
  */
 public function addSupplierReference($id_supplier, $id_product_attribute, $supplier_reference = null, $price = null, $id_currency = null)
 {
     //in some case we need to add price without supplier reference
     if ($supplier_reference === null) {
         $supplier_reference = '';
     }
     //Try to set the default supplier reference
     if ($id_supplier > 0) {
         $id_product_supplier = (int) ProductSupplier::getIdByProductAndSupplier($this->id, $id_product_attribute, $id_supplier);
         if (!$id_product_supplier) {
             //create new record
             $product_supplier_entity = new ProductSupplier();
             $product_supplier_entity->id_product = (int) $this->id;
             $product_supplier_entity->id_product_attribute = (int) $id_product_attribute;
             $product_supplier_entity->id_supplier = (int) $id_supplier;
             $product_supplier_entity->product_supplier_reference = pSQL($supplier_reference);
             $product_supplier_entity->product_supplier_price_te = (int) $price;
             $product_supplier_entity->id_currency = (int) $id_currency;
             $product_supplier_entity->save();
         } else {
             $product_supplier = new ProductSupplier((int) $id_product_supplier);
             $product_supplier->product_supplier_reference = pSQL($supplier_reference);
             $product_supplier->update();
         }
     }
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:35,代码来源:Product.php


示例6: addSupplierReference

 /**
  * Sets or updates Supplier Reference
  *
  * @param int $id_supplier
  * @param int $id_product_attribute
  * @param string $supplier_reference
  * @param float $price
  * @param int $id_currency
  */
 public function addSupplierReference($id_supplier, $id_product_attribute, $supplier_reference = null, $price = null, $id_currency = null)
 {
     //in some case we need to add price without supplier reference
     if ($supplier_reference === null) {
         $supplier_reference = '';
     }
     //Try to set the default supplier reference
     if ($id_supplier > 0 && $this->id > 0) {
         $id_product_supplier = (int) ProductSupplier::getIdByProductAndSupplier($this->id, $id_product_attribute, $id_supplier);
         $product_supplier = new ProductSupplier($id_product_supplier);
         if (!$id_product_supplier) {
             $product_supplier->id_product = (int) $this->id;
             $product_supplier->id_product_attribute = (int) $id_product_attribute;
             $product_supplier->id_supplier = (int) $id_supplier;
         }
         $product_supplier->product_supplier_reference = pSQL($supplier_reference);
         $product_supplier->product_supplier_price_te = !is_null($price) ? (double) $price : (double) $product_supplier->product_supplier_price_te;
         $product_supplier->id_currency = !is_null($id_currency) ? (int) $id_currency : (int) $product_supplier->id_currency;
         $product_supplier->save();
     }
 }
开发者ID:yewed,项目名称:share,代码行数:30,代码来源:Product.php


示例7: productImport


//.........这里部分代码省略.........
                }
                if ($product->getType() == Product::PTYPE_VIRTUAL) {
                    StockAvailable::setProductOutOfStock((int) $product->id, 1);
                } else {
                    StockAvailable::setProductOutOfStock((int) $product->id, (int) $product->out_of_stock);
                }
            }
            $shops = array();
            $product_shop = explode($this->multiple_value_separator, $product->shop);
            foreach ($product_shop as $shop) {
                if (empty($shop)) {
                    continue;
                }
                $shop = trim($shop);
                if (!empty($shop) && !is_numeric($shop)) {
                    $shop = Shop::getIdByName($shop);
                }
                if (in_array($shop, $shop_ids)) {
                    $shops[] = $shop;
                } else {
                    $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Shop is not valid'));
                }
            }
            if (empty($shops)) {
                $shops = Shop::getContextListShopID();
            }
            // If both failed, mysql error
            if (!$res) {
                $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
            } else {
                // Product supplier
                if (isset($product->id) && $product->id && isset($product->id_supplier) && property_exists($product, 'supplier_reference')) {
                    $id_product_supplier = (int) ProductSupplier::getIdByProductAndSupplier((int) $product->id, 0, (int) $product->id_supplier);
                    if ($id_product_supplier) {
                        $product_supplier = new ProductSupplier($id_product_supplier);
                    } else {
                        $product_supplier = new ProductSupplier();
                    }
                    $product_supplier->id_product = (int) $product->id;
                    $product_supplier->id_product_attribute = 0;
                    $product_supplier->id_supplier = (int) $product->id_supplier;
                    $product_supplier->product_supplier_price_te = $product->wholesale_price;
                    $product_supplier->product_supplier_reference = $product->supplier_reference;
                    $product_supplier->save();
                }
                // SpecificPrice (only the basic reduction feature is supported by the import)
                if (!Shop::isFeatureActive()) {
                    $info['shop'] = 1;
                } elseif (!isset($info['shop']) || empty($info['shop'])) {
                    $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
                }
                // Get shops for each attributes
                $info['shop'] = explode($this->multiple_value_separator, $info['shop']);
                $id_shop_list = array();
                foreach ($info['shop'] as $shop) {
                    if (!empty($shop) && !is_numeric($shop)) {
                        $id_shop_list[] = (int) Shop::getIdByName($shop);
                    } elseif (!empty($shop)) {
                        $id_shop_list[] = $shop;
                    }
                }
                if (isset($info['reduction_price']) && $info['reduction_price'] > 0 || isset($info['reduction_percent']) && $info['reduction_percent'] > 0) {
                    foreach ($id_shop_list as $id_shop) {
                        $specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
                        if (is_array($specific_price) && isset($specific_price['id_specific_price'])) {
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:67,代码来源:AdminImportController.php


示例8: supplyOrdersDetailsImport

    public function supplyOrdersDetailsImport()
    {
        // opens CSV & sets locale
        $this->receiveTab();
        $handle = $this->openCsvFile();
        AdminImportController::setLocale();
        $products = array();
        $reset = true;
        // main loop, for each supply orders details to import
        for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); ++$current_line) {
            // if convert requested
            if (Tools::getValue('convert')) {
                $line = $this->utf8EncodeArray($line);
            }
            $info = AdminImportController::getMaskedRow($line);
            // sets default values if needed
            AdminImportController::setDefaultValues($info);
            // gets the supply order
            if (array_key_exists('supply_order_reference', $info) && pSQL($info['supply_order_reference']) && SupplyOrder::exists(pSQL($info['supply_order_reference']))) {
                $supply_order = SupplyOrder::getSupplyOrderByReference(pSQL($info['supply_order_reference']));
            } else {
                $this->errors[] = sprintf($this->l('Supply Order (%s) could not be loaded (at line %d).'), (int) $info['supply_order_reference'], $current_line + 1);
            }
            if (empty($this->errors)) {
                // sets parameters
                $id_product = (int) $info['id_product'];
                if (!$info['id_product_attribute']) {
                    $info['id_product_attribute'] = 0;
                }
                $id_product_attribute = (int) $info['id_product_attribute'];
                $unit_price_te = (double) $info['unit_price_te'];
                $quantity_expected = (int) $info['quantity_expected'];
                $discount_rate = (double) $info['discount_rate'];
                $tax_rate = (double) $info['tax_rate'];
                // checks if one product is there only once
                if (isset($product['id_product'])) {
                    if ($product['id_product'] == $id_product_attribute) {
                        $this->errors[] = sprintf($this->l('Product (%d/%D) cannot be added twice (at line %d).'), $id_product, $id_product_attribute, $current_line + 1);
                    } else {
                        $product['id_product'] = $id_product_attribute;
                    }
                } else {
                    $product['id_product'] = 0;
                }
                // checks parameters
                if (false === ($supplier_reference = ProductSupplier::getProductSupplierReference($id_product, $id_product_attribute, $supply_order->id_supplier))) {
                    $this->errors[] = sprintf($this->l('Product (%d/%d) is not available for this order (at line %d).'), $id_product, $id_product_attribute, $current_line + 1);
                }
                if ($unit_price_te < 0) {
                    $this->errors[] = sprintf($this->l('Unit Price (tax excl.) (%d) is not valid (at line %d).'), $unit_price_te, $current_line + 1);
                }
                if ($quantity_expected < 0) {
                    $this->errors[] = sprintf($this->l('Quantity Expected (%d) is not valid (at line %d).'), $quantity_expected, $current_line + 1);
                }
                if ($discount_rate < 0 || $discount_rate > 100) {
                    $this->errors[] = sprintf($this->l('Discount rate (%d) is not valid (at line %d). %s.'), $discount_rate, $current_line + 1, $this->l('Format: Between 0 and 100'));
                }
                if ($tax_rate < 0 || $tax_rate > 100) {
                    $this->errors[] = sprintf($this->l('Quantity Expected (%d) is not valid (at line %d).'), $tax_rate, $current_line + 1, $this->l('Format: Between 0 and 100'));
                }
                // if no errors, sets supply order details
                if (empty($this->errors)) {
                    // resets order if needed
                    if ($reset) {
                        $supply_order->resetProducts();
                        $reset = false;
                    }
                    // creates new product
                    $supply_order_detail = new SupplyOrderDetail();
                    AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supply_order_detail);
                    // sets parameters
                    $supply_order_detail->id_supply_order = $supply_order->id;
                    $currency = new Currency($supply_order->id_ref_currency);
                    $supply_order_detail->id_currency = $currency->id;
                    $supply_order_detail->exchange_rate = $currency->conversion_rate;
                    $supply_order_detail->supplier_reference = $supplier_reference;
                    $supply_order_detail->name = Product::getProductName($id_product, $id_product_attribute, $supply_order->id_lang);
                    // gets ean13 / ref / upc
                    $query = new DbQuery();
                    $query->select('
						IFNULL(pa.reference, IFNULL(p.reference, \'\')) as reference,
						IFNULL(pa.ean13, IFNULL(p.ean13, \'\')) as ean13,
						IFNULL(pa.upc, IFNULL(p.upc, \'\')) as upc
					');
                    $query->from('product', 'p');
                    $query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product AND id_product_attribute = ' . (int) $id_product_attribute);
                    $query->where('p.id_product = ' . (int) $id_product);
                    $query->where('p.is_virtual = 0 AND p.cache_is_pack = 0');
                    $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
                    $product_infos = $res['0'];
                    $supply_order_detail->reference = $product_infos['reference'];
                    $supply_order_detail->ean13 = $product_infos['ean13'];
                    $supply_order_detail->upc = $product_infos['upc'];
                    $supply_order_detail->add();
                    $supply_order->update();
                    unset($supply_order_detail);
                }
            }
        }
        // closes
//.........这里部分代码省略.........
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:101,代码来源:AdminImportController.php


示例9: getItemXML


//.........这里部分代码省略.........
     } else {
         if ($this->module_conf['quantity'] == 1 && $product['quantity'] > 0) {
             $xml_googleshopping .= '<g:quantity>' . $product['quantity'] . '</g:quantity>' . "\n";
         }
         $xml_googleshopping .= '<g:availability>' . $this->categories_values[$product['category_default']]['gcat_avail'] . '</g:availability>' . "\n";
     }
     // Price(s)
     $currency = new Currency((int) $id_curr);
     $use_tax = $product['tax_included'] ? true : false;
     $no_tax = !$use_tax ? true : false;
     $product['price'] = (double) $p->getPriceStatic($product['id_product'], $use_tax, $combination) * $currency->conversion_rate;
     $product['price_without_reduct'] = (double) $p->getPriceWithoutReduct($no_tax, $combination) * $currency->conversion_rate;
     $product['price'] = number_format(round($product['price'], 2, PHP_ROUND_HALF_DOWN), 2, '.', ' ');
     $product['price_without_reduct'] = number_format(round($product['price_without_reduct'], 2, PHP_ROUND_HALF_DOWN), 2, '.', ' ');
     if ((double) $product['price'] < (double) $product['price_without_reduct']) {
         $xml_googleshopping .= '<g:price>' . $product['price_without_reduct'] . ' ' . $currency->iso_code . '</g:price>' . "\n";
         $xml_googleshopping .= '<g:sale_price>' . $product['price'] . ' ' . $currency->iso_code . '</g:sale_price>' . "\n";
     } else {
         $xml_googleshopping .= '<g:price>' . $product['price'] . ' ' . $currency->iso_code . '</g:price>' . "\n";
     }
     $identifier_exists = 0;
     // GTIN (EAN, UPC, JAN, ISBN)
     if (!empty($product['ean13'])) {
         $xml_googleshopping .= '<g:gtin>' . $product['ean13'] . '</g:gtin>' . "\n";
         $identifier_exists++;
     }
     // Brand
     if ($this->module_conf['no_brand'] != 0 && !empty($product['id_manufacturer'])) {
         $xml_googleshopping .= '<g:brand><![CDATA[' . htmlspecialchars(Manufacturer::getNameById((int) $product['id_manufacturer']), self::REPLACE_FLAGS, self::CHARSET, false) . ']]></g:brand>' . "\n";
         $identifier_exists++;
     }
     // MPN
     if (empty($product['supplier_reference'])) {
         $product['supplier_reference'] = ProductSupplier::getProductSupplierReference($product['id_product'], 0, $product['id_supplier']);
     }
     if ($this->module_conf['mpn_type'] == 'reference' && !empty($product['reference'])) {
         $xml_googleshopping .= '<g:mpn><![CDATA[' . $product['reference'] . ']]></g:mpn>' . "\n";
         $identifier_exists++;
     } else {
         if ($this->module_conf['mpn_type'] == 'supplier_reference' && !empty($product['supplier_reference'])) {
             $xml_googleshopping .= '<g:mpn><![CDATA[' . $product['supplier_reference'] . ']]></g:mpn>' . "\n";
             $identifier_exists++;
         }
     }
     // Tag "identifier_exists"
     if ($this->module_conf['id_exists_tag'] && $identifier_exists < 2) {
         $xml_googleshopping .= '<g:identifier_exists>FALSE</g:identifier_exists>' . "\n";
     }
     // Product gender and age_group attributes association
     $product_features = $this->getProductFeatures($product['id_product'], $id_lang, $id_shop);
     $product['gender'] = $this->categories_values[$product['category_default']]['gcat_gender'];
     $product['age_group'] = $this->categories_values[$product['category_default']]['gcat_age_group'];
     foreach ($product_features as $feature) {
         switch ($feature['id_feature']) {
             case $this->module_conf['gender']:
                 $product['gender'] = $feature['value'];
                 continue 2;
             case $this->module_conf['age_group']:
                 $product['age_group'] = $feature['value'];
                 continue 2;
         }
         if (!$product['color']) {
             foreach ($this->module_conf['color[]'] as $id => $v) {
                 if ($v == $feature['id_feature']) {
                     $product['color'] = $feature['value'];
                 }
开发者ID:ecommercebox,项目名称:gshoppingflux,代码行数:67,代码来源:gshoppingflux.php


示例10: importProducts

 protected function importProducts()
 {
     $this->truncateTables(array('product', 'product_lang', 'product_shop', 'product_sale', 'product_supplier', 'product_tag', 'feature_product', 'category_product', 'product_carrier', 'compare_product', 'product_attachment', 'product_country_tax', 'product_download', 'product_group_reduction_cache', 'scene_products', 'warehouse_product_location', 'customization', 'customization_field', 'customization_field_lang', 'supply_order_detail', 'attribute_impact', 'pack'));
     $handle = $this->openCsvFile('products.csv');
     $languages = Language::getLanguages(false);
     for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
         $res = false;
         $product = new Product((int) $line[0]);
         $product->id = (int) $line[0];
         $product->active = $line[1];
         foreach ($languages as $lang) {
             $product->name[$lang['id_lang']] = $line['2'];
         }
         $categories = explode(',', $line[3]);
         $product->id_category_default = $categories[0] ? $categories[0] : Configuration::get('PS_HOME_CATEGORY');
         if (isset($categories) && $categories && count($categories)) {
             $product->addToCategories($categories);
         }
         if (isset($line[4])) {
             $product->price_tex = $line[4];
         }
         if (isset($line[5])) {
             $product->price_tin = $line[5];
         }
         $product->id_tax_rules_group = trim($line[6]) ? $line[6] : 0;
         $product->wholesale_price = trim($line[7]) ? $line[7] : 0;
         $product->on_sale = trim($line[8]) ? $line[8] : 0;
         if (trim($line[13])) {
             $product->reference = $line[13];
         }
         if (trim($line[14])) {
             $product->supplier_reference = trim($line[14]);
         }
         if (trim($line[15])) {
             $product->id_supplier = (int) $line[15];
         }
         if (isset($product->id) && $product->id && isset($product->id_supplier) && property_exists($product, 'supplier_reference')) {
             $id_product_supplier = (int) ProductSupplier::getIdByProductAndSupplier((int) $product->id, 0, (int) $product->id_supplier);
             if ($id_product_supplier) {
                 $product_supplier = new ProductSupplier($id_product_supplier);
             } else {
                 $product_supplier = new ProductSupplier();
             }
             $product_supplier->id_product = (int) $product->id;
             $product_supplier->id_product_attribute = 0;
             $product_supplier->id_supplier = (int) $product->id_supplier;
             $product_supplier->product_supplier_price_te = $product->wholesale_price;
             $product_supplier->product_supplier_reference = $product->supplier_reference;
             $product_supplier->save();
         }
         if (trim($line[16])) {
             $product->id_manufacturer = $line[16];
         }
         if (!Tools::isEmpty(trim($line[17]))) {
             $product->ean13 = $line[17];
         }
         if (trim($line[18])) {
             $product->upc = $line[18];
         }
         if (trim($line[19])) {
             $product->ecotax = $line[19];
         }
         $product->width = $line[20];
         $product->height = $line[21];
         $product->depth = $line[22];
         $product->weight = $line[23];
         if ($line[24]) {
             StockAvailable::setQuantity((int) $product->id, 0, (int) $line[24], (int) $this->context->shop->id);
         }
         $product->minimal_quantity = $line[25];
         $product->visibility = $line[26];
         $product->additional_shipping_cost = $line[27];
         if (trim($line[28])) {
             $product->unity = $line[28];
         }
         if (trim($line[29])) {
             $product->unit_price = $line[29];
         }
         foreach ($languages as $lang) {
             $product->description_short[$lang['id_lang']] = $line[30];
             $product->description[$lang['id_lang']] = $line[31];
         }
         if ($line[32]) {
             foreach ($languages as $lang) {
                 Tag::addTags($lang['id_lang'], $product->id, $line[32]);
             }
         }
         foreach ($languages as $lang) {
             $product->meta_title[$lang['id_lang']] = $line[33];
             $product->meta_keywords[$lang['id_lang']] = $line[34];
             $product->meta_description[$lang['id_lang']] = $line[35];
             $product->link_rewrite[$lang['id_lang']] = $line[36];
             $product->available_now[$lang['id_lang']] = $line[37];
             $product->available_later[$lang['id_lang']] = $line[38];
         }
         $product->available_for_order = $line[39];
         $product->available_date = $line[40];
         $product->date_add = $line[41];
         $product->show_price = $line[42];
         // Features import
//.........这里部分代码省略.........
开发者ID:evgrishin,项目名称:se1614,代码行数:101,代码来源:AdminSampleDataInstallImport.php



注:本文中的ProductSupplier类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Producto类代码示例发布时间:2022-05-23
下一篇:
PHP ProductSale类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap