Merge branch 'develop' into gli-2505
This commit is contained in:
@@ -688,33 +688,52 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
$limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT');
|
||||
if ($limit <= 0) {
|
||||
$limit = Configuration::PS_SHORT_DESC_LIMIT;
|
||||
}
|
||||
$className = 'Product';
|
||||
foreach (Language::getLanguages(true) as $language) {
|
||||
if (Tools::strlen(strip_tags($product->name[$language['id_lang']])) > $limit) {
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('This %1$s field in %2$s is too long: %3$d chars max (current count %4$d).'),
|
||||
call_user_func(array($className, 'displayFieldName'), 'description_short'),
|
||||
$language['name'],
|
||||
$limit,
|
||||
Tools::strlen(strip_tags($product->name[$language['id_lang']]))
|
||||
);
|
||||
}
|
||||
}
|
||||
unset($product->id);
|
||||
unset($product->id_product);
|
||||
$product->indexed = 0;
|
||||
$product->active = 0;
|
||||
if ($product->add()
|
||||
&& Category::duplicateProductCategories($id_product_old, $product->id)
|
||||
&& ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false
|
||||
&& GroupReduction::duplicateReduction($id_product_old, $product->id)
|
||||
// && Product::duplicateFeatures($id_product_old, $product->id)
|
||||
&& Product::duplicateTags($id_product_old, $product->id)) {
|
||||
if ($product->hasAttributes()) {
|
||||
Product::updateDefaultAttribute($product->id);
|
||||
} else {
|
||||
Product::duplicateSpecificPrices($id_product_old, $product->id);
|
||||
}
|
||||
|
||||
if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while copying images.');
|
||||
} else {
|
||||
Hook::exec('actionProductAdd', array('id_product' => (int)$product->id, 'product' => $product));
|
||||
if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) {
|
||||
Search::indexation(false, $product->id);
|
||||
if (!$this->errors) {
|
||||
if ($product->add()
|
||||
&& Category::duplicateProductCategories($id_product_old, $product->id)
|
||||
&& ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false
|
||||
&& GroupReduction::duplicateReduction($id_product_old, $product->id)
|
||||
// && Product::duplicateFeatures($id_product_old, $product->id)
|
||||
&& Product::duplicateTags($id_product_old, $product->id)
|
||||
) {
|
||||
if ($product->hasAttributes()) {
|
||||
Product::updateDefaultAttribute($product->id);
|
||||
} else {
|
||||
Product::duplicateSpecificPrices($id_product_old, $product->id);
|
||||
}
|
||||
$this->redirect_after = self::$currentIndex.(Tools::getIsset('id_category') ? '&id_category='.(int)Tools::getValue('id_category') : '').'&conf=19&token='.$this->token;
|
||||
|
||||
if (!Tools::getValue('noimage') && !Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while copying images.');
|
||||
} else {
|
||||
Hook::exec('actionProductAdd', array('id_product' => (int)$product->id, 'product' => $product));
|
||||
if (in_array($product->visibility, array('both', 'search')) && Configuration::get('PS_SEARCH_INDEXATION')) {
|
||||
Search::indexation(false, $product->id);
|
||||
}
|
||||
$this->redirect_after = self::$currentIndex.(Tools::getIsset('id_category') ? '&id_category='.(int)Tools::getValue('id_category') : '').'&conf=19&token='.$this->token;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating an object.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating an object.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1441,8 +1460,7 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
'ajaxfileupload',
|
||||
'date',
|
||||
'tagify',
|
||||
'select2',
|
||||
'validate'
|
||||
'select2'
|
||||
));
|
||||
|
||||
$this->addJS(array(
|
||||
@@ -2193,15 +2211,15 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
}
|
||||
|
||||
// Check description short size without html
|
||||
$limit = (int)Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT');
|
||||
$limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT');
|
||||
if ($limit <= 0) {
|
||||
$limit = 400;
|
||||
$limit = Configuration::PS_SHORT_DESC_LIMIT;
|
||||
}
|
||||
foreach ($languages as $language) {
|
||||
if ($this->isProductFieldUpdated('description_short', $language['id_lang']) && ($value = Tools::getValue('description_short_'.$language['id_lang']))) {
|
||||
if (Tools::strlen(strip_tags($value)) > $limit) {
|
||||
$this->errors[] = sprintf(
|
||||
Tools::displayError('This %1$s field (%2$s) is too long: %3$d chars max (current count %4$d).'),
|
||||
Tools::displayError('This %1$s field in %2$s is too long: %3$d chars max (current count %4$d).'),
|
||||
call_user_func(array($className, 'displayFieldName'), 'description_short'),
|
||||
$language['name'],
|
||||
$limit,
|
||||
@@ -3560,7 +3578,7 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
'token' => $this->token,
|
||||
'currency' => $currency,
|
||||
'link' => $this->context->link,
|
||||
'PS_PRODUCT_SHORT_DESC_LIMIT' => Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') ? Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') : 400
|
||||
'PS_SHORT_DESC_LIMIT' => Configuration::get('PS_SHORT_DESC_LIMIT') ? Configuration::get('PS_SHORT_DESC_LIMIT') : Configuration::PS_SHORT_DESC_LIMIT
|
||||
));
|
||||
$data->assign($this->tpl_form_vars);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user