本文整理汇总了PHP中ProductSupplier::getProductSupplierReference方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductSupplier::getProductSupplierReference方法的具体用法?PHP ProductSupplier::getProductSupplierReference怎么用?PHP ProductSupplier::getProductSupplierReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProductSupplier
的用法示例。
在下文中一共展示了ProductSupplier::getProductSupplierReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
//.........这里部分代码省略.........
示例2: 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);
}
}
}
示例3: 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'];
}