本文整理汇总了PHP中StockAvailable::copyStockAvailableFromShopToShop方法的典型用法代码示例。如果您正苦于以下问题:PHP StockAvailable::copyStockAvailableFromShopToShop方法的具体用法?PHP StockAvailable::copyStockAvailableFromShopToShop怎么用?PHP StockAvailable::copyStockAvailableFromShopToShop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StockAvailable
的用法示例。
在下文中一共展示了StockAvailable::copyStockAvailableFromShopToShop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processAdd
/**
* Object creation
*/
public function processAdd()
{
if (!Tools::getValue('categoryBox') || !in_array(Tools::getValue('id_category'), Tools::getValue('categoryBox'))) {
$this->errors[] = $this->l('You need to select at least the root category.');
}
if (Tools::isSubmit('id_category_default')) {
$_POST['id_category'] = (int) Tools::getValue('id_category_default');
}
/* Checking fields validity */
$this->validateRules();
if (!count($this->errors)) {
$object = new $this->className();
$this->copyFromPost($object, $this->table);
$this->beforeAdd($object);
if (!$object->add()) {
$this->errors[] = Tools::displayError('An error occurred while creating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
} else {
if (($_POST[$this->identifier] = $object->id) && $this->postImage($object->id) && !count($this->errors) && $this->_redirect) {
$parent_id = (int) Tools::getValue('id_parent', 1);
$this->afterAdd($object);
$this->updateAssoShop($object->id);
// Save and stay on same form
if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay')) {
$this->redirect_after = self::$currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=3&update' . $this->table . '&token=' . $this->token;
}
// Save and back to parent
if (Tools::isSubmit('submitAdd' . $this->table . 'AndBackToParent')) {
$this->redirect_after = self::$currentIndex . '&' . $this->identifier . '=' . $parent_id . '&conf=3&token=' . $this->token;
}
// Default behavior (save and back)
if (empty($this->redirect_after)) {
$this->redirect_after = self::$currentIndex . ($parent_id ? '&' . $this->identifier . '=' . $object->id : '') . '&conf=3&token=' . $this->token;
}
}
}
}
$this->errors = array_unique($this->errors);
if (count($this->errors) > 0) {
$this->display = 'add';
return;
}
// specific import for stock
if (isset($import_data['stock_available']) && isset($import_data['product']) && Tools::isSubmit('useImportData')) {
$id_src_shop = (int) Tools::getValue('importFromShop');
if ($object->getGroup()->share_stock == false) {
StockAvailable::copyStockAvailableFromShopToShop($id_src_shop, $object->id);
}
}
$categories = Tools::getValue('categoryBox');
array_unshift($categories, Configuration::get('PS_ROOT_CATEGORY'));
Category::updateFromShop($categories, $object->id);
Search::indexation(true);
return $object;
}