Merge branch 'develop' into gli-2206
This commit is contained in:
@@ -655,33 +655,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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1408,8 +1427,7 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
'ajaxfileupload',
|
||||
'date',
|
||||
'tagify',
|
||||
'select2',
|
||||
'validate'
|
||||
'select2'
|
||||
));
|
||||
|
||||
$this->addJS(array(
|
||||
@@ -2160,15 +2178,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,
|
||||
@@ -3527,7 +3545,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);
|
||||
|
||||
|
||||
@@ -82,16 +82,6 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
1 => $this->l('Cart summary')
|
||||
)
|
||||
),*/
|
||||
'PS_PRODUCT_SHORT_DESC_LIMIT' => array(
|
||||
'title' => $this->l('Max size of short description'),
|
||||
'hint' => $this->l('Set the maximum size of room type short description (in characters).'),
|
||||
'validation' => 'isUnsignedInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
'suffix' => $this->l('characters'),
|
||||
'class' => 'fixed-width-xl',
|
||||
'desc' => $this->l('If set to 0, the maximum limit will be 400 characters.')
|
||||
),
|
||||
/*'PS_QTY_DISCOUNT_ON_COMBINATION' => array(
|
||||
'title' => $this->l('Quantity discounts based on'),
|
||||
'hint' => $this->l('How to calculate quantity discounts.'),
|
||||
|
||||
@@ -185,6 +185,16 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
'type' => 'text',
|
||||
'class' => 'fixed-width-xxl'
|
||||
),
|
||||
'PS_SHORT_DESC_LIMIT' => array(
|
||||
'title' => $this->l('Short description Max Size'),
|
||||
'hint' => $this->l('Set the maximum size of room type, services and hotel short description (in characters).'),
|
||||
'validation' => 'isUnsignedInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
'suffix' => $this->l('characters'),
|
||||
'class' => 'fixed-width-xl',
|
||||
'desc' => sprintf($this->l('If set to 0, the maximum limit will be %d characters.'), Configuration::PS_SHORT_DESC_LIMIT)
|
||||
),
|
||||
// 'PS_DISPLAY_SUPPLIERS' => array(
|
||||
// 'title' => $this->l('Display suppliers and manufacturers'),
|
||||
// 'desc' => $this->l('Enable suppliers and manufacturers pages on your front office even when their respective modules are disabled.'),
|
||||
|
||||
@@ -813,10 +813,24 @@ class AdminProductsControllerCore extends AdminController
|
||||
$id_hotel_new = Tools::getValue('id_hotel');
|
||||
$obj_hotel_room_type = new HotelRoomType();
|
||||
$room_type_info = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($id_product_old);
|
||||
$limit = (int)Configuration::get('PS_SHORT_DESC_LIMIT');
|
||||
if ($limit <= 0) {
|
||||
$limit = Configuration::PS_SHORT_DESC_LIMIT;
|
||||
}
|
||||
$className = 'Product';
|
||||
if ($room_type_info && $room_type_info['id_hotel'] == $id_hotel_new) {
|
||||
foreach (Language::getLanguages(true) as $language) {
|
||||
$product->name[$language['id_lang']] = $product->name[$language['id_lang']].
|
||||
' - '.$this->l('Duplicate');
|
||||
if (Tools::strlen(strip_tags($product->description_short[$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->description_short[$language['id_lang']]))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,66 +842,69 @@ class AdminProductsControllerCore extends AdminController
|
||||
foreach (Language::getLanguages(true) as $language) {
|
||||
$product->link_rewrite[$language['id_lang']] = Tools::str2url($product->name[$language['id_lang']]);
|
||||
}
|
||||
if ($product->add()
|
||||
// && Category::duplicateProductCategories($id_product_old, $product->id)
|
||||
&& Product::duplicateSuppliers($id_product_old, $product->id)
|
||||
&& ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false
|
||||
&& GroupReduction::duplicateReduction($id_product_old, $product->id)
|
||||
&& Product::duplicateAccessories($id_product_old, $product->id)
|
||||
&& Product::duplicateFeatures($id_product_old, $product->id)
|
||||
&& Pack::duplicate($id_product_old, $product->id)
|
||||
&& Product::duplicateCustomizationFields($id_product_old, $product->id)
|
||||
&& Product::duplicateTags($id_product_old, $product->id)
|
||||
&& Product::duplicateDownload($id_product_old, $product->id)
|
||||
) {
|
||||
$obj_hotel_room_type = new HotelRoomType();
|
||||
$room_type_info = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($id_product_old);
|
||||
$id_room_type_old = $room_type_info['id'];
|
||||
if (!$id_hotel_new) {
|
||||
$id_hotel_new = $room_type_info['id_hotel'];
|
||||
}
|
||||
|
||||
if ($product->hasAttributes()) {
|
||||
Product::updateDefaultAttribute($product->id);
|
||||
} else {
|
||||
Product::duplicateSpecificPrices($id_product_old, $product->id);
|
||||
}
|
||||
if (!$this->errors) {
|
||||
if ($product->add()
|
||||
// && Category::duplicateProductCategories($id_product_old, $product->id)
|
||||
&& Product::duplicateSuppliers($id_product_old, $product->id)
|
||||
&& ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false
|
||||
&& GroupReduction::duplicateReduction($id_product_old, $product->id)
|
||||
&& Product::duplicateAccessories($id_product_old, $product->id)
|
||||
&& Product::duplicateFeatures($id_product_old, $product->id)
|
||||
&& Pack::duplicate($id_product_old, $product->id)
|
||||
&& Product::duplicateCustomizationFields($id_product_old, $product->id)
|
||||
&& Product::duplicateTags($id_product_old, $product->id)
|
||||
&& Product::duplicateDownload($id_product_old, $product->id)
|
||||
) {
|
||||
$obj_hotel_room_type = new HotelRoomType();
|
||||
$room_type_info = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($id_product_old);
|
||||
$id_room_type_old = $room_type_info['id'];
|
||||
if (!$id_hotel_new) {
|
||||
$id_hotel_new = $room_type_info['id_hotel'];
|
||||
}
|
||||
|
||||
$id_room_type_new = HotelRoomType::duplicateRoomType(
|
||||
$id_product_old,
|
||||
$product->id,
|
||||
$id_hotel_new,
|
||||
true
|
||||
);
|
||||
if ($id_room_type_new) {
|
||||
if (!HotelRoomType::duplicateRooms(
|
||||
if ($product->hasAttributes()) {
|
||||
Product::updateDefaultAttribute($product->id);
|
||||
} else {
|
||||
Product::duplicateSpecificPrices($id_product_old, $product->id);
|
||||
}
|
||||
|
||||
$id_room_type_new = HotelRoomType::duplicateRoomType(
|
||||
$id_product_old,
|
||||
$id_room_type_new,
|
||||
$product->id,
|
||||
$id_hotel_new
|
||||
)) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while duplicating rooms.');
|
||||
$id_hotel_new,
|
||||
true
|
||||
);
|
||||
if ($id_room_type_new) {
|
||||
if (!HotelRoomType::duplicateRooms(
|
||||
$id_product_old,
|
||||
$id_room_type_new,
|
||||
$product->id,
|
||||
$id_hotel_new
|
||||
)) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while duplicating rooms.');
|
||||
}
|
||||
if (!HotelRoomTypeDemand::duplicateRoomTypeDemands($id_product_old, $product->id)) {
|
||||
$this->errors[] = Tools::displayError(
|
||||
'An error occurred while duplicating additional facilities.'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while duplicating room type.');
|
||||
}
|
||||
if (!HotelRoomTypeDemand::duplicateRoomTypeDemands($id_product_old, $product->id)) {
|
||||
$this->errors[] = Tools::displayError(
|
||||
'An error occurred while duplicating additional facilities.'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while duplicating room type.');
|
||||
}
|
||||
|
||||
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 (!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;
|
||||
}
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1503,8 +1520,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
'ajaxfileupload',
|
||||
'date',
|
||||
'tagify',
|
||||
'select2',
|
||||
'validate'
|
||||
'select2'
|
||||
));
|
||||
|
||||
$this->addJS(array(
|
||||
@@ -2172,15 +2188,15 @@ class AdminProductsControllerCore 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,
|
||||
@@ -4371,7 +4387,7 @@ class AdminProductsControllerCore 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,
|
||||
'category_position' => Tools::getValue('category_position', $product->getPositionInCategory()),
|
||||
));
|
||||
$data->assign($this->tpl_form_vars);
|
||||
|
||||
Reference in New Issue
Block a user