diff --git a/admin-dev/tabs/AdminAttributes.php b/admin-dev/tabs/AdminAttributes.php index 3e8e20f42..140b2bf0f 100644 --- a/admin-dev/tabs/AdminAttributes.php +++ b/admin-dev/tabs/AdminAttributes.php @@ -177,7 +177,7 @@ class AdminAttributes extends AdminTab } // clean \n\r characters foreach ($_POST as $key => $value) - if (preg_match('/^name_/Ui', $key)) + if (stripos($key, 'name_') !== false) $_POST[$key] = str_replace ('\n', '', str_replace('\r', '', $value)); parent::postProcess(); } diff --git a/admin-dev/tabs/AdminImport.php b/admin-dev/tabs/AdminImport.php index f311ad6b6..46afaecef 100644 --- a/admin-dev/tabs/AdminImport.php +++ b/admin-dev/tabs/AdminImport.php @@ -179,7 +179,7 @@ class AdminImport extends AdminTab 'label' => $this->l('Delete existing images (0 = no, 1 = yes)'), 'help' => $this->l('If you do not specify this column and you specify the column images, all images of the product will be replaced by those specified in the import file') ), - 'features' => array('label' => $this->l('Feature(Name:Position)'), + 'features' => array('label' => $this->l('Feature(Name:Value:Position)'), 'help' => $this->l('Position of the feature.')), 'online_only' => array('label' => $this->l('Only available online')), 'condition' => array('label' => $this->l('Condition')), @@ -764,7 +764,7 @@ class AdminImport extends AdminTab $product->date_add = pSQL($datas['date_add']); $res = $product->update(); } // Else If id product AND id product already in base, trying to update - else if ($product->id AND Product::existsInDatabase((int)($product->id), 'product')) + elseif ($product->id AND Product::existsInDatabase((int)($product->id), 'product')) { $datas = Db::getInstance()->getRow('SELECT `date_add` FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)($product->id)); $product->date_add = pSQL($datas['date_add']); @@ -962,7 +962,7 @@ class AdminImport extends AdminTab $this->_errors[] = ($fieldError !== true ? $fieldError : '').($langFieldError !== true ? $langFieldError : '').mysql_error(); } } - else if (isset($info['image_position']) && $info['image_position']) + elseif (isset($info['image_position']) && $info['image_position']) { $images = $product->getImages($defaultLanguage); @@ -1837,4 +1837,4 @@ class AdminImport extends AdminTab { $this->_warnings[] = $product_name.(isset($product_id) ? ' (ID '.$product_id.')' : '').' '.Tools::displayError($message); } -} +} \ No newline at end of file diff --git a/admin-dev/tabs/AdminProducts.php b/admin-dev/tabs/AdminProducts.php index 693d68f3d..93917b6df 100644 --- a/admin-dev/tabs/AdminProducts.php +++ b/admin-dev/tabs/AdminProducts.php @@ -3463,7 +3463,7 @@ class AdminProducts extends AdminTab
'.$this->l('The available date when this product is out of stock').'
+ \''.$product_attribute['quantity'].'\', \''.($attrImage ? $attrImage->id : 0).'\', Array('.$jsList.'), \''.$id_product_attribute.'\', \''.$product_attribute['default_on'].'\', \''.$product_attribute['ecotax'].'\', \''.$product_attribute['location'].'\', \''.$product_attribute['upc'].'\', \''.$product_attribute['minimal_quantity'].'\', \''.pSQL($available_date).'\'); calcImpactPriceTI();" />
'.(!$product_attribute['default_on'] ? '
' : '').'
diff --git a/classes/Attribute.php b/classes/Attribute.php
index f81fb3968..6d06d1118 100644
--- a/classes/Attribute.php
+++ b/classes/Attribute.php
@@ -306,14 +306,14 @@ class AttributeCore extends ObjectModel
$sql .= '
ORDER BY `position`';
$result = Db::getInstance()->ExecuteS($sql);
- $sizeof = sizeof($result);
- for ($i = 0; $i < $sizeof; $i++)
+ $i = 0;
+ foreach ($result as $value)
$return = Db::getInstance()->Execute('
UPDATE `'._DB_PREFIX_.'attribute`
- SET `position` = '.(int)$i.'
+ SET `position` = '.(int)$i++.'
WHERE `id_attribute_group` = '.(int)$id_attribute_group.'
- AND `id_attribute` = '.(int)$result[$i]['id_attribute']);
+ AND `id_attribute` = '.(int)$value['id_attribute']);
return $return;
}
@@ -327,11 +327,11 @@ class AttributeCore extends ObjectModel
*/
public static function getHigherPosition($id_attribute_group)
{
- $sql = 'SELECT `position`
+ $sql = 'SELECT MAX(`position`)
FROM `'._DB_PREFIX_.'attribute`
- WHERE id_attribute_group = '.(int)$id_attribute_group.'
- ORDER BY position DESC';
- return ((DB::getInstance()->getValue($sql)!==false)) ? DB::getInstance()->getValue($sql) : -1;
+ WHERE id_attribute_group = '.(int)$id_attribute_group;
+ $position = DB::getInstance()->getValue($sql);
+ return ($position !== false) ? $position : -1;
}
}
diff --git a/classes/AttributeGroup.php b/classes/AttributeGroup.php
index f3fceaf42..9311b97be 100644
--- a/classes/AttributeGroup.php
+++ b/classes/AttributeGroup.php
@@ -262,17 +262,17 @@ class AttributeGroupCore extends ObjectModel
$return = true;
$sql = '
- SELECT *
+ SELECT `id_attribute_group`
FROM `'._DB_PREFIX_.'attribute_group`
ORDER BY `position`';
$result = Db::getInstance()->ExecuteS($sql);
- $sizeof = sizeof($result);
- for ($i = 0; $i < $sizeof; $i++)
+ $i = 0;
+ foreach ($result as $value)
$return = Db::getInstance()->Execute('
UPDATE `'._DB_PREFIX_.'attribute_group`
- SET `position` = '.(int)$i.'
- WHERE `id_attribute_group` = '.(int)$result[$i]['id_attribute_group']);
+ SET `position` = '.(int)$i++.'
+ WHERE `id_attribute_group` = '.(int)$value['id_attribute_group']);
return $return;
}
@@ -285,10 +285,10 @@ class AttributeGroupCore extends ObjectModel
*/
public static function getHigherPosition()
{
- $sql = 'SELECT `position`
- FROM `'._DB_PREFIX_.'attribute_group`
- ORDER BY position DESC';
- return ((DB::getInstance()->getValue($sql)!==false)) ? DB::getInstance()->getValue($sql) : -1;
+ $sql = 'SELECT MAX(`position`)
+ FROM `'._DB_PREFIX_.'attribute_group`';
+ $position = DB::getInstance()->getValue($sql);
+ return ($position !== false) ? $position : -1;
}
}
diff --git a/classes/Feature.php b/classes/Feature.php
index b9922d738..76cc899ea 100644
--- a/classes/Feature.php
+++ b/classes/Feature.php
@@ -285,17 +285,17 @@ class FeatureCore extends ObjectModel
$return = true;
$sql = '
- SELECT *
+ SELECT `id_feature`
FROM `'._DB_PREFIX_.'feature`
ORDER BY `position`';
$result = Db::getInstance()->ExecuteS($sql);
- $sizeof = sizeof($result);
- for ($i = 0; $i < $sizeof; $i++)
+ $i = 0;
+ foreach ($result as $value)
$return = Db::getInstance()->Execute('
UPDATE `'._DB_PREFIX_.'feature`
- SET `position` = '.(int)$i.'
- WHERE `id_feature` = '.(int)$result[$i]['id_feature']);
+ SET `position` = '.(int)$i++.'
+ WHERE `id_feature` = '.(int)$value['id_feature']);
return $return;
}
@@ -308,10 +308,10 @@ class FeatureCore extends ObjectModel
*/
public static function getHigherPosition()
{
- $sql = 'SELECT `position`
- FROM `'._DB_PREFIX_.'feature`
- ORDER BY position DESC';
- return ((DB::getInstance()->getValue($sql)!==false)) ? DB::getInstance()->getValue($sql) : -1;
+ $sql = 'SELECT MAX(`position`)
+ FROM `'._DB_PREFIX_.'feature`;
+ $position = DB::getInstance()->getValue($sql);
+ return ($position !== false) ? $position : -1;
}
}
diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php
index 3555fefb9..9574841c1 100644
--- a/controllers/front/CartController.php
+++ b/controllers/front/CartController.php
@@ -52,8 +52,8 @@ class CartControllerCore extends FrontController
$result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']);
// Display reduced price (or not) without quantity discount
if (Tools::getIsset('getproductprice'))
- foreach ($result['summary']['products'] as $key => $product)
- $result['summary']['products'][$key]['price_without_quantity_discount'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute']);
+ foreach ($result['summary']['products'] as $key => &$product)
+ $product['price_without_quantity_discount'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute']);
die(Tools::jsonEncode($result));
}
else
diff --git a/controllers/front/ParentOrderController.php b/controllers/front/ParentOrderController.php
index 20b609ace..3ed46dfcd 100644
--- a/controllers/front/ParentOrderController.php
+++ b/controllers/front/ParentOrderController.php
@@ -257,11 +257,10 @@ class ParentOrderControllerCore extends FrontController
}
$this->context->smarty->assign('free_ship', $total_free_ship);
}
- foreach ($summary['products'] AS $key => $product)
+ foreach ($summary['products'] AS $key => &$product)
{
- $summary['products'][$key]['quantity'] = $product['cart_quantity'];// for compatibility with 1.2 themes
- $std_product = new Product($summary['products'][$key]['id_product']);
- $summary['products'][$key]['price_without_specific_price'] = $std_product->getPrice(!Product::getTaxCalculationMethod(), $summary['products'][$key]['id_product_attribute']);
+ $product['quantity'] = $product['cart_quantity'];// for compatibility with 1.2 themes
+ $product['price_without_specific_price'] = Product::getPriceStatic($product['id_product'], !Product::getTaxCalculationMethod(), $product['id_product_attribute']);
}
$this->context->smarty->assign($summary);
diff --git a/js/attributesBack.js b/js/attributesBack.js
index 19b427b75..e34d2a1c9 100644
--- a/js/attributesBack.js
+++ b/js/attributesBack.js
@@ -34,7 +34,7 @@ function fillCombinaison(wholesale_price, price_impact, weight_impact, unit_impa
$('#attribute_quantity').html(quantity);
$('#attribute_quantity').show();
$('#attr_qty_stock').show();
- if(available_date!=undefined)
+ if(available_date != undefined)
getE('available_date').value = available_date;
else
getE('available_date').value = '0000-00-00';
diff --git a/themes/prestashop/product.tpl b/themes/prestashop/product.tpl
index d263996ad..632498f34 100644
--- a/themes/prestashop/product.tpl
+++ b/themes/prestashop/product.tpl
@@ -170,7 +170,7 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
{if isset($images) && count($images) > 3}{l s='Next'}{/if}
{/if}
- {if isset($images) && count($images) > 1}{/if} + {if isset($images) && count($images) > 1}
{/if}
reference}style="display: none;"{/if}> +
reference}style="display: none"{/if}> {$product->reference|escape:'htmlall':'UTF-8'}
-quantity <= 0) OR $virtual OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}> +
quantity <= 0) OR $virtual OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if}> minimal_quantity > 1}onkeyup="checkMinimalQuantity({$product->minimal_quantity});"{/if} />
-minimal_quantity <= 1 OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}> +
minimal_quantity <= 1 OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if}> {l s='You must add '}{$product->minimal_quantity}{l s=' as a minimum quantity to buy this product.'}
{if $product->minimal_quantity > 1} @@ -343,7 +343,7 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus {/if} -quantity <= 0 && !$product->available_later && $allow_oosp) OR ($product->quantity > 0 && !$product->available_now) OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}> +
quantity <= 0 && !$product->available_later && $allow_oosp) OR ($product->quantity > 0 && !$product->available_now) OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if}>
{l s='Availability:'}
quantity <= 0} class="warning_inline"{/if}>
{if $product->quantity <= 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->available_now}{/if}
@@ -351,32 +351,32 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
{if ($product->available_date && $product->available_date != 0) && ($product->available_date|date_format:"%Y-%m-%d" >= $smarty.now|date_format:"%Y-%m-%d") && $product->quantity <= 0}
{l s='Restocking:'}{$product->available_date|date_format:"%d-%m-%Y"}
{else}
-
+
{/if}
quantity <= 0} style="display: none;"{/if}> +
quantity <= 0} style="display: none"{/if}> {$product->quantity|intval} - quantity > 1} style="display: none;"{/if} id="quantityAvailableTxt">{l s='item in stock'} - quantity == 1} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'} + quantity > 1} style="display: none"{/if} id="quantityAvailableTxt">{l s='item in stock'} + quantity == 1} style="display: none"{/if} id="quantityAvailableTxtMultiple">{l s='items in stock'}
{/if} {if !$allow_oosp} -quantity > 0} style="display: none;"{/if}> +
quantity > 0} style="display: none"{/if}> {$HOOK_PRODUCT_OOS}
{/if} -quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if} >{l s='Warning: Last items in stock!'}
+quantity > $last_qties OR $product->quantity <= 0) OR $allow_oosp OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none"{/if} >{l s='Warning: Last items in stock!'}
{if $product->online_only}{l s='Online only'}
{/if} -quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE} style="display: none;"{/if} id="add_to_cart" class="buttons_bottom_block">
+quantity <= 0) OR !$product->available_for_order OR (isset($restricted_country_mode) AND $restricted_country_mode) OR $PS_CATALOG_MODE} style="display: none"{/if} id="add_to_cart" class="buttons_bottom_block">
{if isset($HOOK_PRODUCT_ACTIONS) && $HOOK_PRODUCT_ACTIONS}{$HOOK_PRODUCT_ACTIONS}{/if}