本文整理汇总了PHP中StockAvailable::save方法的典型用法代码示例。如果您正苦于以下问题:PHP StockAvailable::save方法的具体用法?PHP StockAvailable::save怎么用?PHP StockAvailable::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockAvailable
的用法示例。
在下文中一共展示了StockAvailable::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upsert
private function upsert($line) {
$product = DB::getInstance()->getValue("SELECT `id_product` FROM `" . _DB_PREFIX_ . "product` WHERE `reference` LIKE '{$line['reference']}'");
$product = new Product($product);
$product->reference = $line['reference'];
$product->name = array(
'1' => $line['name'],
'2' => $line['name'],
'3' => $line['name']
);
$product->description = array(
'1' => $line['description'],
'2' => $line['description'],
'3' => $line['description']
);
$product->description_short = array(
'1' => $line['description_short'],
'2' => $line['description_short'],
'3' => $line['description_short']
);
$product->link_rewrite = array(
'1' => Tools::link_rewrite($line['name']),
'2' => Tools::link_rewrite($line['name']),
'3' => Tools::link_rewrite($line['name'])
);
$product->available_now = array(
'1' => "Есть в наличии",
'2' => "Есть в наличии",
'3' => "Есть в наличии"
);
$product->id_category_default = $line['category'];
$product->quantity = (int)$line['count'];
$product->advanced_stock_management = 1; //использовать Advanced Stock management
$product->depends_on_stock = 1; //1 - доступное количество на основе ASM. 0 - указывается вручную
$product->out_of_stock = 1; //2 - как в Preferences product. 1 - allow (Как в Preferences - не дает заказать товар на сайте)
$product->price = $line['price'];
$product->weight = $line['weight'] / 1000;
$product->id_tax_rules_group = $line['id_tax'];
$product->save();
$product->updateCategories(array($line['category']));
$product->deleteFeatures();
if ($line['author']) {
$id_feature_value = FeatureValue::addFeatureValueImport(9, $line['author'], null, Configuration::get('PS_LANG_DEFAULT'));
Product::addFeatureProductImport($product->id, 9, $id_feature_value);
}
if ($line['year']) {
$id_feature_value = FeatureValue::addFeatureValueImport(10, $line['year'], null, Configuration::get('PS_LANG_DEFAULT'));
Product::addFeatureProductImport($product->id, 10, $id_feature_value);
}
if ($line['paperback']) {
Product::addFeatureProductImport($product->id, 11, 1); //1 - id значения "переплёт" у харакатеристики "Переплёт"
}
if ($line['pages']) {
$id_feature_value = FeatureValue::addFeatureValueImport(12, $line['pages'], null, Configuration::get('PS_LANG_DEFAULT'), true);
Product::addFeatureProductImport($product->id, 12, $id_feature_value);
}
/*
if ($line['weight']) {
$id_feature_value = FeatureValue::addFeatureValueImport(4, $line['weight'], null, Configuration::get('PS_LANG_DEFAULT'), true);
Product::addFeatureProductImport($product->id, 4, $id_feature_value);
}
*/
if ($line['isbn']) {
$id_feature_value = FeatureValue::addFeatureValueImport(13, $line['isbn'], null, Configuration::get('PS_LANG_DEFAULT'), true);
Product::addFeatureProductImport($product->id, 13, $id_feature_value);
}
if ($line['publishing']) {
$id_feature_value = FeatureValue::addFeatureValueImport(14, $line['publishing'], null, Configuration::get('PS_LANG_DEFAULT'), true);
Product::addFeatureProductImport($product->id, 14, $id_feature_value);
}
$location = WarehouseProductLocation::getIdByProductAndWarehouse($product->id, 0, $line['warehouse']);
$location = new WarehouseProductLocation($location);
$location->id_product = $product->id;
$location->id_product_attribute = 0;
$location->id_warehouse = $line['warehouse'];
$location->save();
$stock = DB::getInstance()->getValue("SELECT `id_stock` FROM `" . _DB_PREFIX_ . "stock` WHERE `id_product` = {$product->id} AND `id_warehouse` = {$line['warehouse']}");
$stock = new Stock($stock);
$stock->id_product = $product->id;
$stock->id_product_attribute = 0;
$stock->id_warehouse = $line['warehouse'];
$stock->physical_quantity = $line['count'];
$stock->usable_quantity = $line['count'];
$stock->price_te = 0;
$stock->save();
$available = DB::getInstance()->getValue("SELECT `id_stock_available` FROM `". _DB_PREFIX_ . "stock_available` WHERE `id_product` = {$product->id} AND `id_shop` = " . Context::getContext()->shop->id);
//.........这里部分代码省略.........