From 1508a8a5d78a6a5778c84d1af576cb343e4f9f95 Mon Sep 17 00:00:00 2001 From: Quentin Montant Date: Wed, 20 Nov 2013 11:31:02 +0100 Subject: [PATCH 1/4] "---
" string is now removed correctly from the end of customization data text --- classes/PaymentModule.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 69520408e..031b719bf 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -369,7 +369,9 @@ abstract class PaymentModuleCore extends Module $customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])).'
'; $customization_text .= '---
'; } - $customization_text = rtrim($customization_text, '---
'); + if(substr($customization_text, -9) == '---
'){ + $customization_text = substr($customization_text, 0, -9); + } $customization_quantity = (int)$product['customization_quantity']; $products_list .= From 0410378bd3b7c61e33e4ae226a7f6393af423fe4 Mon Sep 17 00:00:00 2001 From: Quentin Montant Date: Wed, 20 Nov 2013 13:30:47 +0100 Subject: [PATCH 2/4] "---
" string is now removed correctly from the end of customization data text --- classes/PaymentModule.php | 5 ++--- classes/Tools.php | 16 +++++++++++++++- modules/mailalerts/mailalerts.php | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php index 031b719bf..a78796d41 100644 --- a/classes/PaymentModule.php +++ b/classes/PaymentModule.php @@ -369,9 +369,8 @@ abstract class PaymentModuleCore extends Module $customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])).'
'; $customization_text .= '---
'; } - if(substr($customization_text, -9) == '---
'){ - $customization_text = substr($customization_text, 0, -9); - } + + $customization_text = Tools::rtrimString($customization_text, '---
'); $customization_quantity = (int)$product['customization_quantity']; $products_list .= diff --git a/classes/Tools.php b/classes/Tools.php index 6e6ac3151..a3a2df9ac 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -2739,6 +2739,20 @@ exit; } return $fileAttachment; } + + /** + * Delete a substring from another one starting from the right + * @param string $str + * @param string $str_search + * @return string + */ + public static function rtrimString($str, $str_search) + { + $length_str = strlen($str_search); + if (strlen($str) >= $length_str && substr($str, -$length_str) == $str_search) + $str = substr($str, 0, -$length_str); + return $str; + } } /** @@ -2765,4 +2779,4 @@ function cmpPriceDesc($a, $b) elseif ((float)$a['price_tmp'] > (float)$b['price_tmp']) return -1; return 0; -} +} \ No newline at end of file diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php index 8dddab040..93f6011d3 100644 --- a/modules/mailalerts/mailalerts.php +++ b/modules/mailalerts/mailalerts.php @@ -318,7 +318,7 @@ class MailAlerts extends Module $customization_text .= '---
'; } - $customization_text = rtrim($customization_text, '---
'); + $customization_text = Tools::rtrimString($customization_text, '---
'); } $items_table .= From 0ff7163cba105afb91d5eb181a6bf3cb654dff3c Mon Sep 17 00:00:00 2001 From: Priyank Bolia Date: Wed, 20 Nov 2013 20:56:35 +0530 Subject: [PATCH 3/4] Adding a position order by clause. Adding a position order by clause. This way you can manage how the featured products will display on home page. You can manage the order from the PrestaShop backend, and thus you have full control on the display in the frontend. --- modules/homefeatured/homefeatured.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/homefeatured/homefeatured.php b/modules/homefeatured/homefeatured.php index 5d7ec5b57..a0e91af28 100644 --- a/modules/homefeatured/homefeatured.php +++ b/modules/homefeatured/homefeatured.php @@ -120,7 +120,7 @@ class HomeFeatured extends Module { $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id); $nb = (int)Configuration::get('HOME_FEATURED_NBR'); - $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8)); + $products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), "position"); $this->smarty->assign(array( 'products' => $products, From 5f47526ed2fd8d2d6ef82ba1507ae655b122af12 Mon Sep 17 00:00:00 2001 From: Fabio Chelly Date: Thu, 21 Nov 2013 12:13:30 +0100 Subject: [PATCH 4/4] [-] FO : Fixed bug #PSCFV-11076 --- classes/ProductSale.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/ProductSale.php b/classes/ProductSale.php index eef056ade..527f21c7b 100644 --- a/classes/ProductSale.php +++ b/classes/ProductSale.php @@ -85,6 +85,7 @@ class ProductSaleCore foreach ($products as $product) $ids[$product['id_product']] = 1; $ids = array_keys($ids); + $ids = array_filter($ids); sort($ids); $ids = count($ids) > 0 ? implode(',', $ids) : 'NULL'; @@ -157,6 +158,7 @@ class ProductSaleCore $ids[$product['id_product']] = 1; $ids = array_keys($ids); sort($ids); + $ids = array_filter($ids); $ids = count($ids) > 0 ? implode(',', $ids) : 'NULL'; //Main query