├── LICENSE ├── README.md ├── advancedfeaturesvalues.php ├── blocklayered-ajax.php ├── config.xml ├── index.php ├── logo.gif ├── logo.png ├── override ├── classes │ ├── FeatureValue.php │ ├── Product.php │ └── index.php ├── controllers │ ├── admin │ │ ├── AdminFeaturesController.php │ │ ├── AdminProductsController.php │ │ └── index.php │ └── index.php ├── index.php └── modules │ ├── blocklayered │ ├── blocklayered.php │ └── index.php │ └── index.php ├── translations └── fr.php ├── upgrade ├── index.php └── install-1.0.3.php └── views ├── index.php ├── js ├── blocklayered.js └── index.php └── templates ├── admin ├── index.php └── products │ ├── features.tpl │ └── index.php └── index.php /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Advanced Features Values for Prestashop 2 | This is a module for Prestashop 1.5.3+. 3 | 4 | ### Multiple feature values 5 | This allows the selection of multiple values for product features, instead of just one. This is compatible with the default product page display, showing all selected values in the Features table, and with the blocklayered module, which will display all selected values in the facet navigation. 6 | 7 | ### Feature values ordering 8 | This allows the ordering of the features values. This is compatible with the default product page display, showing all selected values in the Features table in the correct order. 9 | 10 | ### Install 11 | Download and copy the *advancedfeaturesvalues* folder into the */modules* folder of your Prestashop installation. 12 | 13 | **Important**: be sure to remove the *-master* suffix after downloading the archive from GitHub. 14 | 15 | ### Changelog 16 | * 1.0.10: Bug fixes. 17 | * 1.0.9: Bug fixes. 18 | * 1.0.8: Allows concatenation of features values up to 4096 chars instead of the default 1024 limit. 19 | * 1.0.7: Bug fixes. 20 | * 1.0.6: Fix manual ordering in feature values admin. 21 | * 1.0.5: Bug fixes and French localization. 22 | * 1.0.4: Conform the Prestashop module Validator. 23 | * 1.0.3: Correct ordering in the blocklayered filters after selecting a value and an Ajax request. 24 | * 1.0.2: Makes the blocklayered filters reflect the features valures ordering. (PS 1.6.0.11+) 25 | * 1.0.1: Clear caches on (un)install. 26 | * 1.0.0: Initial commit. -------------------------------------------------------------------------------- /advancedfeaturesvalues.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | if (!defined('_PS_VERSION_')) 28 | exit; 29 | 30 | class AdvancedFeaturesValues extends Module 31 | { 32 | public function __construct() 33 | { 34 | $this->name = 'advancedfeaturesvalues'; 35 | $this->tab = 'administration'; 36 | $this->version = '1.0.10'; 37 | $this->author = 'Jérôme Danthinne'; 38 | $this->need_instance = 0; 39 | $this->ps_versions_compliancy = array('min' => '1.5.3', 'max' => _PS_VERSION_); 40 | $this->bootstrap = true; 41 | 42 | parent::__construct(); 43 | 44 | $this->displayName = $this->l('Advanced Features Values'); 45 | $this->description = $this->l('Allows multiple values selection per feature, and features values ordering.'); 46 | $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); 47 | } 48 | 49 | public function install() 50 | { 51 | if (!parent::install() || !$this->registerHook('header')) 52 | return false; 53 | $this->_clearCache('*'); 54 | unlink(_PS_CACHE_DIR_.'class_index.php'); 55 | 56 | // Alter DB PRIMARY KEY to allow multiple values 57 | if (!Db::getInstance()->execute(' 58 | ALTER TABLE '._DB_PREFIX_.'feature_product DROP PRIMARY KEY; 59 | ALTER TABLE '._DB_PREFIX_.'feature_product ADD PRIMARY KEY (id_feature, id_product, id_feature_value);')) 60 | return false; 61 | // Add position field to feature_value 62 | if (!Db::getInstance()->execute(' 63 | ALTER TABLE '._DB_PREFIX_.'feature_value ADD position INT UNSIGNED NOT NULL DEFAULT 0;')) 64 | return false; 65 | $features = Db::getInstance()->executeS(' 66 | SELECT GROUP_CONCAT(id_feature_value ORDER BY id_feature_value) AS id_feature_value,id_feature 67 | FROM '._DB_PREFIX_.'feature_value GROUP BY id_feature;'); 68 | foreach ($features as $feature) 69 | { 70 | $values = explode(',', $feature['id_feature_value']); 71 | foreach ($values as $position => $value) 72 | { 73 | if (!Db::getInstance()->execute(' 74 | UPDATE '._DB_PREFIX_.'feature_value SET position = '.$position.' WHERE id_feature_value = '.$value.';')) 75 | return false; 76 | } 77 | } 78 | 79 | return true; 80 | } 81 | 82 | public function uninstall() 83 | { 84 | if (!parent::uninstall()) 85 | return false; 86 | $this->_clearCache('*'); 87 | unlink(_PS_CACHE_DIR_.'class_index.php'); 88 | 89 | // Remove multiple values from DB and restore PRIMARY KEY 90 | if (!Db::getInstance()->execute(' 91 | CREATE TABLE '._DB_PREFIX_.'feature_product_tmp as 92 | SELECT * FROM '._DB_PREFIX_.'feature_product WHERE 1 GROUP BY id_feature,id_product; 93 | TRUNCATE '._DB_PREFIX_.'feature_product; 94 | ALTER TABLE '._DB_PREFIX_.'feature_product DROP PRIMARY KEY; 95 | ALTER TABLE '._DB_PREFIX_.'feature_product ADD PRIMARY KEY (id_feature, id_product); 96 | INSERT INTO '._DB_PREFIX_.'feature_product 97 | SELECT * FROM '._DB_PREFIX_.'feature_product_tmp; 98 | DROP TABLE '._DB_PREFIX_.'feature_product_tmp')) 99 | return false; 100 | // Remove position field from feature_value 101 | if (!Db::getInstance()->execute(' 102 | ALTER TABLE '._DB_PREFIX_.'feature_value DROP position;')) 103 | return false; 104 | 105 | return true; 106 | } 107 | 108 | public function hookHeader() 109 | { 110 | if ((isset($this->context->controller->display_column_left) && !$this->context->controller->display_column_left) 111 | && (isset($this->context->controller->display_column_right) && !$this->context->controller->display_column_right)) 112 | return false; 113 | 114 | if (Tools::getValue('id_category', Tools::getValue('id_category_layered', Configuration::get('PS_HOME_CATEGORY'))) == Configuration::get('PS_HOME_CATEGORY')) 115 | return; 116 | 117 | $this->context->controller->addJS(($this->_path).'views/js/blocklayered.js'); 118 | } 119 | } -------------------------------------------------------------------------------- /blocklayered-ajax.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2015 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registred Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | include(dirname(__FILE__).'/../../config/config.inc.php'); 28 | include(dirname(__FILE__).'/../../init.php'); 29 | include(dirname(__FILE__).'/../blocklayered/blocklayered.php'); 30 | include(dirname(__FILE__).'/override/modules/blocklayered/blocklayered.php'); 31 | 32 | Context::getContext()->controller->php_self = 'category'; 33 | $block_layered = new BlockLayeredOverride(); 34 | echo $block_layered->ajaxCall(); -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | advancedfeaturesvalues 4 | 5 | 6 | 7 | 8 | 9 | 10 | 0 11 | 0 12 | 13 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdanthinne/advancedfeaturesvalues/41d04f7878e48a3a1428b8858f6dfb4c471b5cf9/logo.gif -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdanthinne/advancedfeaturesvalues/41d04f7878e48a3a1428b8858f6dfb4c471b5cf9/logo.png -------------------------------------------------------------------------------- /override/classes/FeatureValue.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | class FeatureValue extends FeatureValueCore 28 | { 29 | public $position; 30 | 31 | public static $definition = array( 32 | 'table' => 'feature_value', 33 | 'primary' => 'id_feature_value', 34 | 'multilang' => true, 35 | 'fields' => array( 36 | 'id_feature' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 37 | 'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), 38 | 'custom' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 39 | 'value' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255), 40 | ), 41 | ); 42 | 43 | public static function getFeatureValuesWithLang($id_lang, $id_feature, $custom = false) 44 | { 45 | return Db::getInstance()->executeS(' 46 | SELECT * 47 | FROM `'._DB_PREFIX_.'feature_value` v 48 | LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` vl 49 | ON (v.`id_feature_value` = vl.`id_feature_value` AND vl.`id_lang` = '.(int)$id_lang.') 50 | WHERE v.`id_feature` = '.(int)$id_feature.' 51 | '.(!$custom ? 'AND (v.`custom` IS NULL OR v.`custom` = 0)' : '').' 52 | ORDER BY v.`position` ASC 53 | ', true, false); 54 | } 55 | 56 | public function add($autodate = true, $null_values = false) 57 | { 58 | if ($this->position <= 0) 59 | $this->position = FeatureValue::getHigherPosition($this->id_feature) + 1; 60 | 61 | $return = parent::add($autodate, $null_values); 62 | if ($return) 63 | Hook::exec('actionFeatureValueSave', array('id_feature_value' => $this->id)); 64 | return $return; 65 | } 66 | 67 | public function delete() 68 | { 69 | /* Also delete related products */ 70 | Db::getInstance()->execute(' 71 | DELETE FROM `'._DB_PREFIX_.'feature_product` 72 | WHERE `id_feature_value` = '.(int)$this->id 73 | ); 74 | $return = parent::delete(); 75 | 76 | if ($return) 77 | Hook::exec('actionFeatureValueDelete', array('id_feature_value' => $this->id)); 78 | 79 | /* Reinitializing position */ 80 | $this->cleanPositions($this->id_feature); 81 | 82 | return $return; 83 | } 84 | 85 | /** 86 | * Move a feature value 87 | * @param boolean $way Up (1) or Down (0) 88 | * @param integer $position 89 | * @return boolean Update result 90 | */ 91 | public function updatePosition($way, $position, $id_feature_value = null) 92 | { 93 | if (!$res = Db::getInstance()->executeS(' 94 | SELECT `position`, `id_feature_value`, `id_feature` 95 | FROM `'._DB_PREFIX_.'feature_value` 96 | WHERE `id_feature_value` = '.((int)$id_feature_value ? $id_feature_value : $this->id).' 97 | ORDER BY `position` ASC' 98 | )) 99 | return false; 100 | 101 | foreach ($res as $feature) 102 | if ((int)$feature['id_feature_value'] == (int)$this->id) 103 | $moved_feature = $feature; 104 | 105 | if (!isset($moved_feature) || !isset($position)) 106 | return false; 107 | 108 | // < and > statements rather than BETWEEN operator 109 | // since BETWEEN is treated differently according to databases 110 | return (Db::getInstance()->execute(' 111 | UPDATE `'._DB_PREFIX_.'feature_value` 112 | SET `position` = `position` '.($way ? '- 1' : '+ 1').' 113 | WHERE `id_feature` = '.(int)$moved_feature['id_feature'].' 114 | AND `position` 115 | '.($way 116 | ? '> '.(int)$moved_feature['position'].' AND `position` <= '.(int)$position 117 | : '< '.(int)$moved_feature['position'].' AND `position` >= '.(int)$position)) 118 | && Db::getInstance()->execute(' 119 | UPDATE `'._DB_PREFIX_.'feature_value` 120 | SET `position` = '.(int)$position.' 121 | WHERE `id_feature_value` = '.(int)$moved_feature['id_feature_value'])); 122 | } 123 | 124 | /** 125 | * Reorder feature position 126 | * Call it after deleting a feature value. 127 | * @param integer $id_feature 128 | * @return bool $return 129 | */ 130 | public static function cleanPositions($id_feature) 131 | { 132 | //Reordering positions to remove "holes" in them (after delete for instance) 133 | $sql = 'SELECT id_feature_value FROM '._DB_PREFIX_.'feature_value 134 | WHERE id_feature = '.(int)$id_feature.' ORDER BY position'; 135 | $db = Db::getInstance(); 136 | $r = $db->executeS($sql, false); 137 | $current_position = 0; 138 | while ($line = $db->nextRow($r)) 139 | { 140 | $sql = 'UPDATE '._DB_PREFIX_.'feature_value SET position = '.(int)$current_position.' WHERE id_feature_value = '.(int)$line['id_feature_value']; 141 | $db->execute($sql); 142 | $current_position++; 143 | } 144 | } 145 | 146 | /** 147 | * getHigherPosition 148 | * 149 | * Get the higher feature value position 150 | * @param integer $id_feature 151 | * @return integer $position 152 | */ 153 | public static function getHigherPosition($id_feature) 154 | { 155 | $sql = 'SELECT MAX(`position`) 156 | FROM `'._DB_PREFIX_.'feature_value` WHERE `id_feature` = '.(int)$id_feature; 157 | $position = DB::getInstance()->getValue($sql); 158 | if (is_numeric($position)) 159 | $higher_position = $position; 160 | else 161 | $higher_position = -1; 162 | return $higher_position; 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /override/classes/Product.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | class Product extends ProductCore 28 | { 29 | public function addFeaturesToDB($id_feature, $id_value, $cust = 0) 30 | { 31 | if ($cust) 32 | { 33 | $row = array('id_feature' => (int)$id_feature, 'custom' => 1); 34 | Db::getInstance()->insert('feature_value', $row); 35 | $id_value = Db::getInstance()->Insert_ID(); 36 | } 37 | $row = array('id_feature' => (int)$id_feature, 'id_product' => (int)$this->id, 'id_feature_value' => (int)$id_value); 38 | Db::getInstance()->insert('feature_product', $row); 39 | SpecificPriceRule::applyAllRules(array((int)$this->id)); 40 | if ($id_value) 41 | return ($id_value); 42 | } 43 | 44 | public static function getFrontFeaturesStatic($id_lang, $id_product) 45 | { 46 | if (!Feature::isFeatureActive()) 47 | return array(); 48 | if (!array_key_exists($id_product.'-'.$id_lang, self::$_frontFeaturesCache)) 49 | { 50 | if (Module::isInstalled('blocklayered') && Module::isEnabled('blocklayered')) { 51 | Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('SET @@group_concat_max_len = 4096'); 52 | self::$_frontFeaturesCache[$id_product.'-'.$id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' 53 | SELECT `name`, GROUP_CONCAT(value ORDER BY `fv`.`position` SEPARATOR ", ") AS `value`, `pf`.`id_feature`, `liflv`.`url_name`, `liflv`.`meta_title` 54 | FROM `'._DB_PREFIX_.'feature_product` `pf` 55 | LEFT JOIN `'._DB_PREFIX_.'feature_lang` `fl` ON (`fl`.`id_feature` = `pf`.`id_feature` AND `fl`.`id_lang` = '.(int)$id_lang.') 56 | LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` `fvl` ON (`fvl`.`id_feature_value` = `pf`.`id_feature_value` AND `fvl`.`id_lang` = '.(int)$id_lang.') 57 | LEFT JOIN `'._DB_PREFIX_.'feature` `f` ON (`f`.`id_feature` = `pf`.`id_feature` AND `fl`.`id_lang` = '.(int)$id_lang.') 58 | LEFT JOIN '._DB_PREFIX_.'feature_value `fv` ON `fv`.`id_feature_value` = `pf`.`id_feature_value` 59 | LEFT JOIN `'._DB_PREFIX_.'layered_indexable_feature_lang_value` `liflv` ON (`f`.`id_feature` = `liflv`.`id_feature` AND `liflv`.`id_lang` = '.(int)$id_lang.') 60 | '.Shop::addSqlAssociation('feature', 'f').' 61 | WHERE pf.`id_product` = '.(int)$id_product.' 62 | GROUP BY `name`, pf.`id_feature` 63 | ORDER BY f.`position` ASC' 64 | ); 65 | } else { 66 | Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('SET @@group_concat_max_len = 4096'); 67 | self::$_frontFeaturesCache[$id_product.'-'.$id_lang] = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' 68 | SELECT `name`, GROUP_CONCAT(value ORDER BY `fv`.`position` SEPARATOR ", ") AS `value`, `pf`.`id_feature` 69 | FROM '._DB_PREFIX_.'feature_product `pf` 70 | LEFT JOIN '._DB_PREFIX_.'feature_lang `fl` ON (`fl`.`id_feature` = `pf`.`id_feature` AND `fl`.`id_lang` = '.(int)$id_lang.') 71 | LEFT JOIN '._DB_PREFIX_.'feature_value_lang `fvl` ON (`fvl`.`id_feature_value` = `pf`.`id_feature_value` AND `fvl`.`id_lang` = '.(int)$id_lang.') 72 | LEFT JOIN '._DB_PREFIX_.'feature `f` ON `f`.`id_feature` = `pf`.`id_feature` 73 | LEFT JOIN '._DB_PREFIX_.'feature_value `fv` ON `fv`.`id_feature_value` = `pf`.`id_feature_value` 74 | '.Shop::addSqlAssociation('feature', 'f').' 75 | WHERE pf.id_product = '.(int)$id_product.' 76 | GROUP BY `name`, pf.`id_feature` 77 | ORDER BY f.`position` ASC' 78 | ); 79 | } 80 | } 81 | return self::$_frontFeaturesCache[$id_product.'-'.$id_lang]; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /override/classes/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /override/controllers/admin/AdminFeaturesController.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | class AdminFeaturesController extends AdminFeaturesControllerCore 28 | { 29 | public function renderView() 30 | { 31 | if (($id = Tools::getValue('id_feature'))) 32 | { 33 | $this->setTypeValue(); 34 | $this->list_id = 'feature_value'; 35 | $this->position_identifier = 'id_feature_value'; 36 | $this->position_group_identifier = 'id_feature'; 37 | $this->lang = true; 38 | 39 | // Action for list 40 | $this->addRowAction('edit'); 41 | $this->addRowAction('delete'); 42 | 43 | if (!Validate::isLoadedObject($obj = new Feature((int)$id))) 44 | { 45 | $this->errors[] = Tools::displayError('An error occurred while updating the status for an object.').' 46 | '.$this->table.' '.Tools::displayError('(cannot load object)'); 47 | return; 48 | } 49 | 50 | $this->feature_name = $obj->name; 51 | $this->toolbar_title = $this->feature_name[$this->context->employee->id_lang]; 52 | $this->fields_list = array( 53 | 'id_feature_value' => array( 54 | 'title' => $this->l('ID'), 55 | 'align' => 'center', 56 | 'class' => 'fixed-width-xs' 57 | ), 58 | 'value' => array( 59 | 'title' => $this->l('Value') 60 | ), 61 | 'position' => array( 62 | 'title' => $this->l('Position'), 63 | 'filter_key' => 'a!position', 64 | 'align' => 'center', 65 | 'class' => 'fixed-width-xs', 66 | 'position' => 'position' 67 | ) 68 | ); 69 | 70 | $this->_where = sprintf('AND `id_feature` = %d', (int)$id); 71 | $this->_orderBy = 'position'; 72 | self::$currentIndex = self::$currentIndex.'&id_feature='.(int)$id.'&viewfeature'; 73 | $this->processFilter(); 74 | return AdminController::renderList(); 75 | } 76 | } 77 | 78 | public function ajaxProcessUpdatePositions() 79 | { 80 | if ($this->tabAccess['edit'] === '1') 81 | { 82 | $way = (int)Tools::getValue('way'); 83 | $id = (int)Tools::getValue('id'); 84 | $table = 'feature'; 85 | $positions = Tools::getValue($table); 86 | if (empty($positions)) 87 | { 88 | $table = 'feature_value'; 89 | $positions = Tools::getValue($table); 90 | } 91 | 92 | $new_positions = array(); 93 | foreach ($positions as $v) 94 | if (!empty($v)) 95 | $new_positions[] = $v; 96 | 97 | foreach ($new_positions as $position => $value) 98 | { 99 | $pos = explode('_', $value); 100 | 101 | if (isset($pos[2]) && (int)$pos[2] === $id) 102 | { 103 | if ($table == 'feature') 104 | { 105 | if ($feature = new Feature((int)$pos[2])) 106 | if (isset($position) && $feature->updatePosition($way, $position, $id)) 107 | echo 'ok position '.(int)$position.' for feature '.(int)$pos[1].'\r\n'; 108 | else 109 | echo '{"hasError" : true, "errors" : "Can not update feature '.(int)$id.' to position '.(int)$position.' "}'; 110 | else 111 | echo '{"hasError" : true, "errors" : "This feature ('.(int)$id.') can t be loaded"}'; 112 | 113 | break; 114 | } 115 | elseif ($table == 'feature_value') 116 | { 117 | if ($feature_value = new FeatureValue((int)$pos[2])) 118 | if (isset($position) && $feature_value->updatePosition($way, $position, $id)) 119 | echo 'ok position '.(int)$position.' for feature value '.(int)$pos[2].'\r\n'; 120 | else 121 | echo '{"hasError" : true, "errors" : "Can not update feature value '.(int)$id.' to position '.(int)$position.' "}'; 122 | else 123 | echo '{"hasError" : true, "errors" : "This feature value ('.(int)$id.') can t be loaded"}'; 124 | 125 | break; 126 | } 127 | } 128 | } 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /override/controllers/admin/AdminProductsController.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | class AdminProductsController extends AdminProductsControllerCore 28 | { 29 | public function initFormFeatures($obj) 30 | { 31 | if (!$this->default_form_language) 32 | $this->getLanguages(); 33 | 34 | $tpl_path = _PS_MODULE_DIR_.'advancedfeaturesvalues/views/templates/admin/products/features.tpl'; 35 | $data = $this->context->smarty->createTemplate($tpl_path, $this->context->smarty); 36 | 37 | $data->assign('default_form_language', $this->default_form_language); 38 | $data->assign('languages', $this->_languages); 39 | 40 | if (!Feature::isFeatureActive()) 41 | $this->displayWarning($this->l('This feature has been disabled. ').' 42 | '. 43 | $this->l('Performances').''); 44 | else 45 | { 46 | if ($obj->id) 47 | { 48 | if ($this->product_exists_in_shop) 49 | { 50 | $features = Feature::getFeatures($this->context->language->id, (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP)); 51 | 52 | foreach ($features as $k => $tab_features) 53 | { 54 | $features[$k]['current_item'] = array(); 55 | $features[$k]['val'] = array(); 56 | 57 | $custom = true; 58 | foreach ($obj->getFeatures() as $tab_products) 59 | if ($tab_products['id_feature'] == $tab_features['id_feature']) 60 | $features[$k]['current_item'][] = $tab_products['id_feature_value']; 61 | 62 | $features[$k]['featureValues'] = FeatureValue::getFeatureValuesWithLang($this->context->language->id, (int)$tab_features['id_feature']); 63 | if (count($features[$k]['featureValues'])) 64 | foreach ($features[$k]['featureValues'] as $value) 65 | if (in_array($value['id_feature_value'], $features[$k]['current_item'])) 66 | $custom = false; 67 | 68 | if ($custom && !empty($features[$k]['current_item'])) 69 | $features[$k]['val'] = FeatureValue::getFeatureValueLang($features[$k]['current_item'][0]); 70 | } 71 | 72 | $data->assign('available_features', $features); 73 | $data->assign('product', $obj); 74 | $data->assign('link', $this->context->link); 75 | $data->assign('default_form_language', $this->default_form_language); 76 | } 77 | else 78 | $this->displayWarning($this->l('You must save the product in this shop before adding features.')); 79 | } 80 | else 81 | $this->displayWarning($this->l('You must save this product before adding features.')); 82 | } 83 | $this->tpl_form_vars['custom_form'] = $data->fetch(); 84 | } 85 | 86 | public function processFeatures() 87 | { 88 | if (!Feature::isFeatureActive()) 89 | return; 90 | 91 | if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) 92 | { 93 | // delete all objects 94 | $product->deleteFeatures(); 95 | 96 | // add new objects 97 | $languages = Language::getLanguages(false); 98 | foreach ($_POST as $key => $val) 99 | { 100 | if (preg_match('/^feature_([0-9]+)_value/i', $key, $match)) 101 | { 102 | if (!empty($val)) 103 | { 104 | foreach ($val as $v) 105 | $product->addFeaturesToDB($match[1], $v); 106 | } 107 | else 108 | { 109 | if ($default_value = $this->checkFeatures($languages, $match[1])) 110 | { 111 | $id_value = $product->addFeaturesToDB($match[1], 0, 1); 112 | foreach ($languages as $language) 113 | { 114 | if ($cust = Tools::getValue('custom_'.$match[1].'_'.(int)$language['id_lang'])) 115 | $product->addFeaturesCustomToDB($id_value, (int)$language['id_lang'], $cust); 116 | else 117 | $product->addFeaturesCustomToDB($id_value, (int)$language['id_lang'], $default_value); 118 | } 119 | } 120 | } 121 | } 122 | } 123 | } 124 | else 125 | $this->errors[] = Tools::displayError('A product must be created before adding features.'); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /override/controllers/admin/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /override/controllers/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /override/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /override/modules/blocklayered/blocklayered.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | if (!defined('_CAN_LOAD_FILES_')) 28 | exit; 29 | 30 | class BlockLayeredOverride extends BlockLayered 31 | { 32 | 33 | private $page = 1; 34 | 35 | public function getFilterBlock($selected_filters = array()) 36 | { 37 | static $cache = null; 38 | 39 | $id_lang = Context::getContext()->language->id; 40 | $currency = Context::getContext()->currency; 41 | $id_shop = (int)Context::getContext()->shop->id; 42 | $alias = 'product_shop'; 43 | 44 | if (is_array($cache)) 45 | return $cache; 46 | 47 | $home_category = Configuration::get('PS_HOME_CATEGORY'); 48 | $id_parent = (int)Tools::getValue('id_category', Tools::getValue('id_category_layered', $home_category)); 49 | if ($id_parent == $home_category) 50 | return; 51 | 52 | $parent = new Category((int)$id_parent, $id_lang); 53 | 54 | /* Get the filters for the current category */ 55 | $filters = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' 56 | SELECT * FROM '._DB_PREFIX_.'layered_category 57 | WHERE id_category = '.(int)$id_parent.' 58 | AND id_shop = '.$id_shop.' 59 | GROUP BY `type`, id_value ORDER BY position ASC' 60 | ); 61 | // Remove all empty selected filters 62 | foreach ($selected_filters as $key => $value) 63 | switch ($key) 64 | { 65 | case 'price': 66 | case 'weight': 67 | if ($value[0] === '' && $value[1] === '') 68 | unset($selected_filters[$key]); 69 | break; 70 | default: 71 | if ($value == '') 72 | unset($selected_filters[$key]); 73 | break; 74 | } 75 | 76 | $filter_blocks = array(); 77 | foreach ($filters as $filter) 78 | { 79 | $sql_query = array('select' => '', 'from' => '', 'join' => '', 'where' => '', 'group' => '', 'order' => '', 'second_query' => ''); 80 | switch ($filter['type']) 81 | { 82 | // conditions + quantities + weight + price 83 | case 'price': 84 | case 'weight': 85 | case 'condition': 86 | case 'quantity': 87 | 88 | $sql_query['select'] = 'SELECT p.`id_product`, product_shop.`condition`, p.`id_manufacturer`, sa.`quantity`, p.`weight` '; 89 | 90 | $sql_query['from'] = ' 91 | FROM '._DB_PREFIX_.'product p '; 92 | $sql_query['join'] = ' 93 | INNER JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product) 94 | INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND 95 | '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' 96 | AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' 97 | AND c.active = 1) '; 98 | 99 | $sql_query['join'] .= 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sa 100 | ON (sa.id_product = p.id_product AND sa.id_shop = '.(int)$this->context->shop->id.') '; 101 | $sql_query['where'] = 'WHERE product_shop.`active` = 1 AND product_shop.`visibility` IN ("both", "catalog") '; 102 | 103 | $sql_query['group'] = ' GROUP BY p.id_product '; 104 | break; 105 | 106 | case 'manufacturer': 107 | $sql_query['select'] = 'SELECT m.name, COUNT(DISTINCT p.id_product) nbr, m.id_manufacturer '; 108 | $sql_query['from'] = ' 109 | FROM `'._DB_PREFIX_.'category_product` cp 110 | INNER JOIN `'._DB_PREFIX_.'category` c ON (c.id_category = cp.id_category) 111 | INNER JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product) 112 | INNER JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer) '; 113 | $sql_query['where'] = 'WHERE 114 | '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' 115 | AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' 116 | AND c.active = 1 117 | AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog")'; 118 | $sql_query['group'] = ' GROUP BY p.id_manufacturer ORDER BY m.name'; 119 | 120 | if (!Configuration::get('PS_LAYERED_HIDE_0_VALUES')) 121 | { 122 | $sql_query['second_query'] = ' 123 | SELECT m.name, 0 nbr, m.id_manufacturer 124 | 125 | FROM `'._DB_PREFIX_.'category_product` cp'. 126 | Shop::addSqlAssociation('product', 'cp').' 127 | INNER JOIN `'._DB_PREFIX_.'category` c ON (c.id_category = cp.id_category) 128 | INNER JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product) 129 | INNER JOIN '._DB_PREFIX_.'manufacturer m ON (m.id_manufacturer = p.id_manufacturer) 130 | 131 | WHERE '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' 132 | AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' 133 | AND c.active = 1 134 | AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") 135 | GROUP BY p.id_manufacturer ORDER BY m.name'; 136 | } 137 | 138 | break; 139 | case 'id_attribute_group':// attribute group 140 | $sql_query['select'] = ' 141 | SELECT COUNT(DISTINCT p.id_product) nbr, lpa.id_attribute_group, 142 | a.color, al.name attribute_name, agl.public_name attribute_group_name , lpa.id_attribute, ag.is_color_group, 143 | liagl.url_name name_url_name, liagl.meta_title name_meta_title, lial.url_name value_url_name, lial.meta_title value_meta_title'; 144 | $sql_query['from'] = ' 145 | FROM '._DB_PREFIX_.'layered_product_attribute lpa 146 | INNER JOIN '._DB_PREFIX_.'attribute a 147 | ON a.id_attribute = lpa.id_attribute 148 | INNER JOIN '._DB_PREFIX_.'attribute_lang al 149 | ON al.id_attribute = a.id_attribute 150 | AND al.id_lang = '.(int)$id_lang.' 151 | INNER JOIN '._DB_PREFIX_.'product as p 152 | ON p.id_product = lpa.id_product 153 | INNER JOIN '._DB_PREFIX_.'attribute_group ag 154 | ON ag.id_attribute_group = lpa.id_attribute_group 155 | INNER JOIN '._DB_PREFIX_.'attribute_group_lang agl 156 | ON agl.id_attribute_group = lpa.id_attribute_group 157 | AND agl.id_lang = '.(int)$id_lang.' 158 | LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value liagl 159 | ON (liagl.id_attribute_group = lpa.id_attribute_group AND liagl.id_lang = '.(int)$id_lang.') 160 | LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_lang_value lial 161 | ON (lial.id_attribute = lpa.id_attribute AND lial.id_lang = '.(int)$id_lang.') '; 162 | 163 | $sql_query['where'] = 'WHERE a.id_attribute_group = '.(int)$filter['id_value']; 164 | $sql_query['where'] .= ' AND lpa.`id_shop` = '.(int)Context::getContext()->shop->id; 165 | $sql_query['where'] .= ' AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") 166 | AND p.id_product IN ( 167 | SELECT id_product 168 | FROM '._DB_PREFIX_.'category_product cp 169 | INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND 170 | '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' 171 | AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' 172 | AND c.active = 1) 173 | ) '; 174 | $sql_query['group'] = ' 175 | GROUP BY lpa.id_attribute 176 | ORDER BY ag.`position` ASC, a.`position` ASC'; 177 | 178 | if (!Configuration::get('PS_LAYERED_HIDE_0_VALUES')) 179 | { 180 | $sql_query['second_query'] = ' 181 | SELECT 0 nbr, lpa.id_attribute_group, 182 | a.color, al.name attribute_name, agl.public_name attribute_group_name , lpa.id_attribute, ag.is_color_group, 183 | liagl.url_name name_url_name, liagl.meta_title name_meta_title, lial.url_name value_url_name, lial.meta_title value_meta_title 184 | FROM '._DB_PREFIX_.'layered_product_attribute lpa'. 185 | Shop::addSqlAssociation('product', 'lpa').' 186 | INNER JOIN '._DB_PREFIX_.'attribute a 187 | ON a.id_attribute = lpa.id_attribute 188 | INNER JOIN '._DB_PREFIX_.'attribute_lang al 189 | ON al.id_attribute = a.id_attribute AND al.id_lang = '.(int)$id_lang.' 190 | INNER JOIN '._DB_PREFIX_.'product as p 191 | ON p.id_product = lpa.id_product 192 | INNER JOIN '._DB_PREFIX_.'attribute_group ag 193 | ON ag.id_attribute_group = lpa.id_attribute_group 194 | INNER JOIN '._DB_PREFIX_.'attribute_group_lang agl 195 | ON agl.id_attribute_group = lpa.id_attribute_group 196 | AND agl.id_lang = '.(int)$id_lang.' 197 | LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_group_lang_value liagl 198 | ON (liagl.id_attribute_group = lpa.id_attribute_group AND liagl.id_lang = '.(int)$id_lang.') 199 | LEFT JOIN '._DB_PREFIX_.'layered_indexable_attribute_lang_value lial 200 | ON (lial.id_attribute = lpa.id_attribute AND lial.id_lang = '.(int)$id_lang.') 201 | WHERE '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") 202 | AND a.id_attribute_group = '.(int)$filter['id_value'].' 203 | AND lpa.`id_shop` = '.(int)Context::getContext()->shop->id.' 204 | GROUP BY lpa.id_attribute 205 | ORDER BY id_attribute_group, id_attribute'; 206 | } 207 | break; 208 | 209 | case 'id_feature': 210 | $sql_query['select'] = 'SELECT fl.name feature_name, fp.id_feature, fv.id_feature_value, fvl.value, 211 | COUNT(DISTINCT p.id_product) nbr, 212 | lifl.url_name name_url_name, lifl.meta_title name_meta_title, lifvl.url_name value_url_name, lifvl.meta_title value_meta_title '; 213 | $sql_query['from'] = ' 214 | FROM '._DB_PREFIX_.'feature_product fp 215 | INNER JOIN '._DB_PREFIX_.'product p ON (p.id_product = fp.id_product) 216 | LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang = '.$id_lang.') 217 | INNER JOIN '._DB_PREFIX_.'feature_value fv ON (fv.id_feature_value = fp.id_feature_value AND (fv.custom IS NULL OR fv.custom = 0)) 218 | LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang = '.$id_lang.') 219 | LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_lang_value lifl 220 | ON (lifl.id_feature = fp.id_feature AND lifl.id_lang = '.$id_lang.') 221 | LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_value_lang_value lifvl 222 | ON (lifvl.id_feature_value = fp.id_feature_value AND lifvl.id_lang = '.$id_lang.') '; 223 | $sql_query['where'] = 'WHERE '.$alias.'.`active` = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") 224 | AND fp.id_feature = '.(int)$filter['id_value'].' 225 | AND p.id_product IN ( 226 | SELECT id_product 227 | FROM '._DB_PREFIX_.'category_product cp 228 | INNER JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category AND 229 | '.(Configuration::get('PS_LAYERED_FULL_TREE') ? 'c.nleft >= '.(int)$parent->nleft.' 230 | AND c.nright <= '.(int)$parent->nright : 'c.id_category = '.(int)$id_parent).' 231 | AND c.active = 1)) '; 232 | $sql_query['group'] = 'GROUP BY fv.id_feature_value '; 233 | $sql_query['order'] = 'ORDER BY fv.position '; 234 | 235 | if (!Configuration::get('PS_LAYERED_HIDE_0_VALUES')) 236 | { 237 | $sql_query['second_query'] = ' 238 | SELECT fl.name feature_name, fp.id_feature, fv.id_feature_value, fvl.value, 239 | 0 nbr, 240 | lifl.url_name name_url_name, lifl.meta_title name_meta_title, lifvl.url_name value_url_name, lifvl.meta_title value_meta_title 241 | 242 | FROM '._DB_PREFIX_.'feature_product fp'. 243 | Shop::addSqlAssociation('product', 'fp').' 244 | INNER JOIN '._DB_PREFIX_.'product p ON (p.id_product = fp.id_product) 245 | LEFT JOIN '._DB_PREFIX_.'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang = '.(int)$id_lang.') 246 | INNER JOIN '._DB_PREFIX_.'feature_value fv ON (fv.id_feature_value = fp.id_feature_value AND (fv.custom IS NULL OR fv.custom = 0)) 247 | LEFT JOIN '._DB_PREFIX_.'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang = '.(int)$id_lang.') 248 | LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_lang_value lifl 249 | ON (lifl.id_feature = fp.id_feature AND lifl.id_lang = '.(int)$id_lang.') 250 | LEFT JOIN '._DB_PREFIX_.'layered_indexable_feature_value_lang_value lifvl 251 | ON (lifvl.id_feature_value = fp.id_feature_value AND lifvl.id_lang = '.(int)$id_lang.') 252 | WHERE '.$alias.'.`active` = 1 AND '.$alias.'.`visibility` IN ("both", "catalog") 253 | AND fp.id_feature = '.(int)$filter['id_value'].' 254 | GROUP BY fv.id_feature_value'; 255 | } 256 | 257 | break; 258 | 259 | case 'category': 260 | if (Group::isFeatureActive()) 261 | { 262 | $this->user_groups = ($this->context->customer->isLogged() ? 263 | $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP'))); 264 | } 265 | 266 | $depth = Configuration::get('PS_LAYERED_FILTER_CATEGORY_DEPTH'); 267 | if ($depth === false) 268 | $depth = 1; 269 | 270 | $sql_query['select'] = ' 271 | SELECT c.id_category, c.id_parent, cl.name, (SELECT count(DISTINCT p.id_product) # '; 272 | $sql_query['from'] = ' 273 | FROM '._DB_PREFIX_.'category_product cp 274 | LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = cp.id_product) '; 275 | $sql_query['where'] = ' 276 | WHERE cp.id_category = c.id_category 277 | AND '.$alias.'.active = 1 AND '.$alias.'.`visibility` IN ("both", "catalog")'; 278 | $sql_query['group'] = ') count_products 279 | FROM '._DB_PREFIX_.'category c 280 | LEFT JOIN '._DB_PREFIX_.'category_lang cl ON 281 | (cl.id_category = c.id_category AND cl.`id_shop` = '.(int)Context::getContext()->shop->id.' and cl.id_lang = '.(int)$id_lang.') '; 282 | 283 | if (Group::isFeatureActive()) 284 | { 285 | $sql_query['group'] .= 'RIGHT JOIN '._DB_PREFIX_.'category_group cg ON 286 | (cg.id_category = c.id_category AND cg.`id_group` IN ('.implode(', ', $this->user_groups).')) '; 287 | } 288 | 289 | $sql_query['group'] .= 'WHERE c.nleft > '.(int)$parent->nleft.' 290 | AND c.nright < '.(int)$parent->nright.' 291 | '.($depth ? 'AND c.level_depth <= '.($parent->level_depth + (int)$depth) : '').' 292 | AND c.active = 1 293 | GROUP BY c.id_category ORDER BY c.nleft, c.position'; 294 | } 295 | foreach ($filters as $filter_tmp) 296 | { 297 | $method_name = 'get'.Tools::ucfirst($filter_tmp['type']).'FilterSubQuery'; 298 | if (method_exists('BlockLayeredOverride', $method_name) && 299 | (!in_array($filter['type'], array('price', 'weight')) && $filter['type'] != $filter_tmp['type'] || $filter['type'] == $filter_tmp['type'])) 300 | { 301 | if ($filter['type'] == $filter_tmp['type'] && $filter['id_value'] == $filter_tmp['id_value']) 302 | $sub_query_filter = self::$method_name(array(), true); 303 | else 304 | { 305 | if (!is_null($filter_tmp['id_value'])) 306 | $selected_filters_cleaned = $this->cleanFilterByIdValue(@$selected_filters[$filter_tmp['type']], $filter_tmp['id_value']); 307 | else 308 | $selected_filters_cleaned = @$selected_filters[$filter_tmp['type']]; 309 | $sub_query_filter = self::$method_name($selected_filters_cleaned, $filter['type'] == $filter_tmp['type']); 310 | } 311 | foreach ($sub_query_filter as $key => $value) 312 | $sql_query[$key] .= $value; 313 | } 314 | } 315 | 316 | $products = false; 317 | if (!empty($sql_query['from'])) 318 | { 319 | $sql_query['from'] .= Shop::addSqlAssociation('product', 'p'); 320 | $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql_query['select']."\n". 321 | $sql_query['from']."\n".$sql_query['join']."\n".$sql_query['where']. 322 | "\n".$sql_query['group']."\n".$sql_query['order']); 323 | } 324 | 325 | foreach ($filters as $filter_tmp) 326 | { 327 | $method_name = 'filterProductsBy'.Tools::ucfirst($filter_tmp['type']); 328 | if (method_exists('BlockLayeredOverride', $method_name) && 329 | (!in_array($filter['type'], array('price', 'weight')) && $filter['type'] != $filter_tmp['type'] || $filter['type'] == $filter_tmp['type'])) 330 | if ($filter['type'] == $filter_tmp['type']) 331 | $products = self::$method_name(array(), $products); 332 | else 333 | $products = self::$method_name(@$selected_filters[$filter_tmp['type']], $products); 334 | } 335 | 336 | if (!empty($sql_query['second_query'])) 337 | { 338 | $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql_query['second_query']); 339 | if ($res) 340 | $products = array_merge($products, $res); 341 | } 342 | 343 | switch ($filter['type']) 344 | { 345 | case 'price': 346 | if ($this->showPriceFilter()) 347 | { 348 | $price_array = array( 349 | 'type_lite' => 'price', 350 | 'type' => 'price', 351 | 'id_key' => 0, 352 | 'name' => $this->l('Price'), 353 | 'slider' => true, 354 | 'max' => '0', 355 | 'min' => null, 356 | 'values' => array ('1' => 0), 357 | 'unit' => $currency->sign, 358 | 'format' => $currency->format, 359 | 'filter_show_limit' => $filter['filter_show_limit'], 360 | 'filter_type' => $filter['filter_type'] 361 | ); 362 | if (isset($products) && $products) 363 | foreach ($products as $product) 364 | { 365 | if (is_null($price_array['min'])) 366 | { 367 | $price_array['min'] = $product['price_min']; 368 | $price_array['values'][0] = $product['price_min']; 369 | } 370 | else if ($price_array['min'] > $product['price_min']) 371 | { 372 | $price_array['min'] = $product['price_min']; 373 | $price_array['values'][0] = $product['price_min']; 374 | } 375 | 376 | if ($price_array['max'] < $product['price_max']) 377 | { 378 | $price_array['max'] = $product['price_max']; 379 | $price_array['values'][1] = $product['price_max']; 380 | } 381 | } 382 | 383 | if ($price_array['max'] != $price_array['min'] && $price_array['min'] != null) 384 | { 385 | if ($filter['filter_type'] == 2) 386 | { 387 | $price_array['list_of_values'] = array(); 388 | $nbr_of_value = $filter['filter_show_limit']; 389 | if ($nbr_of_value < 2) 390 | $nbr_of_value = 4; 391 | $delta = ($price_array['max'] - $price_array['min']) / $nbr_of_value; 392 | for ($i = 0; $i < $nbr_of_value; $i++) 393 | $price_array['list_of_values'][] = array( 394 | (int)($price_array['min'] + $i * $delta), 395 | (int)($price_array['min'] + ($i + 1) * $delta) 396 | ); 397 | } 398 | if (isset($selected_filters['price']) && isset($selected_filters['price'][0]) 399 | && isset($selected_filters['price'][1])) 400 | { 401 | $price_array['values'][0] = $selected_filters['price'][0]; 402 | $price_array['values'][1] = $selected_filters['price'][1]; 403 | } 404 | $filter_blocks[] = $price_array; 405 | } 406 | } 407 | break; 408 | 409 | case 'weight': 410 | $weight_array = array( 411 | 'type_lite' => 'weight', 412 | 'type' => 'weight', 413 | 'id_key' => 0, 414 | 'name' => $this->l('Weight'), 415 | 'slider' => true, 416 | 'max' => '0', 417 | 'min' => null, 418 | 'values' => array ('1' => 0), 419 | 'unit' => Configuration::get('PS_WEIGHT_UNIT'), 420 | 'format' => 5, // Ex: xxxxx kg 421 | 'filter_show_limit' => $filter['filter_show_limit'], 422 | 'filter_type' => $filter['filter_type'] 423 | ); 424 | if (isset($products) && $products) 425 | foreach ($products as $product) 426 | { 427 | if (is_null($weight_array['min'])) 428 | { 429 | $weight_array['min'] = $product['weight']; 430 | $weight_array['values'][0] = $product['weight']; 431 | } 432 | else if ($weight_array['min'] > $product['weight']) 433 | { 434 | $weight_array['min'] = $product['weight']; 435 | $weight_array['values'][0] = $product['weight']; 436 | } 437 | 438 | if ($weight_array['max'] < $product['weight']) 439 | { 440 | $weight_array['max'] = $product['weight']; 441 | $weight_array['values'][1] = $product['weight']; 442 | } 443 | } 444 | if ($weight_array['max'] != $weight_array['min'] && $weight_array['min'] != null) 445 | { 446 | if (isset($selected_filters['weight']) && isset($selected_filters['weight'][0]) 447 | && isset($selected_filters['weight'][1])) 448 | { 449 | $weight_array['values'][0] = $selected_filters['weight'][0]; 450 | $weight_array['values'][1] = $selected_filters['weight'][1]; 451 | } 452 | $filter_blocks[] = $weight_array; 453 | } 454 | break; 455 | 456 | case 'condition': 457 | $condition_array = array( 458 | 'new' => array('name' => $this->l('New'),'nbr' => 0), 459 | 'used' => array('name' => $this->l('Used'), 'nbr' => 0), 460 | 'refurbished' => array('name' => $this->l('Refurbished'), 461 | 'nbr' => 0) 462 | ); 463 | if (isset($products) && $products) 464 | foreach ($products as $product) 465 | if (isset($selected_filters['condition']) && in_array($product['condition'], $selected_filters['condition'])) 466 | $condition_array[$product['condition']]['checked'] = true; 467 | foreach (array_keys($condition_array) as $key) 468 | if (isset($selected_filters['condition']) && in_array($key, $selected_filters['condition'])) 469 | $condition_array[$key]['checked'] = true; 470 | if (isset($products) && $products) 471 | foreach ($products as $product) 472 | if (isset($condition_array[$product['condition']])) 473 | $condition_array[$product['condition']]['nbr']++; 474 | $filter_blocks[] = array( 475 | 'type_lite' => 'condition', 476 | 'type' => 'condition', 477 | 'id_key' => 0, 478 | 'name' => $this->l('Condition'), 479 | 'values' => $condition_array, 480 | 'filter_show_limit' => $filter['filter_show_limit'], 481 | 'filter_type' => $filter['filter_type'] 482 | ); 483 | break; 484 | 485 | case 'quantity': 486 | $quantity_array = array ( 487 | 0 => array('name' => $this->l('Not available'), 'nbr' => 0), 488 | 1 => array('name' => $this->l('In stock'), 'nbr' => 0) 489 | ); 490 | foreach (array_keys($quantity_array) as $key) 491 | if (isset($selected_filters['quantity']) && in_array($key, $selected_filters['quantity'])) 492 | $quantity_array[$key]['checked'] = true; 493 | if (isset($products) && $products) 494 | foreach ($products as $product) 495 | { 496 | //If oosp move all not available quantity to available quantity 497 | if ((int)$product['quantity'] > 0 || Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock($product['id_product']))) 498 | $quantity_array[1]['nbr']++; 499 | else 500 | $quantity_array[0]['nbr']++; 501 | } 502 | 503 | $filter_blocks[] = array( 504 | 'type_lite' => 'quantity', 505 | 'type' => 'quantity', 506 | 'id_key' => 0, 507 | 'name' => $this->l('Availability'), 508 | 'values' => $quantity_array, 509 | 'filter_show_limit' => $filter['filter_show_limit'], 510 | 'filter_type' => $filter['filter_type'] 511 | ); 512 | 513 | break; 514 | 515 | case 'manufacturer': 516 | if (isset($products) && $products) 517 | { 518 | $manufaturers_array = array(); 519 | foreach ($products as $manufacturer) 520 | { 521 | if (!isset($manufaturers_array[$manufacturer['id_manufacturer']])) 522 | $manufaturers_array[$manufacturer['id_manufacturer']] = array('name' => $manufacturer['name'], 'nbr' => $manufacturer['nbr']); 523 | if (isset($selected_filters['manufacturer']) && in_array((int)$manufacturer['id_manufacturer'], $selected_filters['manufacturer'])) 524 | $manufaturers_array[$manufacturer['id_manufacturer']]['checked'] = true; 525 | } 526 | $filter_blocks[] = array( 527 | 'type_lite' => 'manufacturer', 528 | 'type' => 'manufacturer', 529 | 'id_key' => 0, 530 | 'name' => $this->l('Manufacturer'), 531 | 'values' => $manufaturers_array, 532 | 'filter_show_limit' => $filter['filter_show_limit'], 533 | 'filter_type' => $filter['filter_type'] 534 | ); 535 | } 536 | break; 537 | 538 | case 'id_attribute_group': 539 | $attributes_array = array(); 540 | if (isset($products) && $products) 541 | { 542 | foreach ($products as $attributes) 543 | { 544 | if (!isset($attributes_array[$attributes['id_attribute_group']])) 545 | $attributes_array[$attributes['id_attribute_group']] = array ( 546 | 'type_lite' => 'id_attribute_group', 547 | 'type' => 'id_attribute_group', 548 | 'id_key' => (int)$attributes['id_attribute_group'], 549 | 'name' => $attributes['attribute_group_name'], 550 | 'is_color_group' => (bool)$attributes['is_color_group'], 551 | 'values' => array(), 552 | 'url_name' => $attributes['name_url_name'], 553 | 'meta_title' => $attributes['name_meta_title'], 554 | 'filter_show_limit' => $filter['filter_show_limit'], 555 | 'filter_type' => $filter['filter_type'] 556 | ); 557 | 558 | if (!isset($attributes_array[$attributes['id_attribute_group']]['values'][$attributes['id_attribute']])) 559 | $attributes_array[$attributes['id_attribute_group']]['values'][$attributes['id_attribute']] = array( 560 | 'color' => $attributes['color'], 561 | 'name' => $attributes['attribute_name'], 562 | 'nbr' => (int)$attributes['nbr'], 563 | 'url_name' => $attributes['value_url_name'], 564 | 'meta_title' => $attributes['value_meta_title'] 565 | ); 566 | 567 | if (isset($selected_filters['id_attribute_group'][$attributes['id_attribute']])) 568 | $attributes_array[$attributes['id_attribute_group']]['values'][$attributes['id_attribute']]['checked'] = true; 569 | } 570 | 571 | $filter_blocks = array_merge($filter_blocks, $attributes_array); 572 | } 573 | break; 574 | case 'id_feature': 575 | $feature_array = array(); 576 | if (isset($products) && $products) 577 | { 578 | foreach ($products as $feature) 579 | { 580 | if (!isset($feature_array[$feature['id_feature']])) 581 | $feature_array[$feature['id_feature']] = array( 582 | 'type_lite' => 'id_feature', 583 | 'type' => 'id_feature', 584 | 'id_key' => (int)$feature['id_feature'], 585 | 'values' => array(), 586 | 'name' => $feature['feature_name'], 587 | 'url_name' => $feature['name_url_name'], 588 | 'meta_title' => $feature['name_meta_title'], 589 | 'filter_show_limit' => $filter['filter_show_limit'], 590 | 'filter_type' => $filter['filter_type'] 591 | ); 592 | 593 | if (!isset($feature_array[$feature['id_feature']]['values'][$feature['id_feature_value']])) 594 | $feature_array[$feature['id_feature']]['values'][$feature['id_feature_value']] = array( 595 | 'nbr' => (int)$feature['nbr'], 596 | 'name' => $feature['value'], 597 | 'url_name' => $feature['value_url_name'], 598 | 'meta_title' => $feature['value_meta_title'] 599 | ); 600 | 601 | if (isset($selected_filters['id_feature'][$feature['id_feature_value']])) 602 | $feature_array[$feature['id_feature']]['values'][$feature['id_feature_value']]['checked'] = true; 603 | } 604 | 605 | $filter_blocks = array_merge($filter_blocks, $feature_array); 606 | } 607 | break; 608 | 609 | case 'category': 610 | $tmp_array = array(); 611 | if (isset($products) && $products) 612 | { 613 | $categories_with_products_count = 0; 614 | foreach ($products as $category) 615 | { 616 | $tmp_array[$category['id_category']] = array( 617 | 'name' => $category['name'], 618 | 'nbr' => (int)$category['count_products'] 619 | ); 620 | 621 | if ((int)$category['count_products']) 622 | $categories_with_products_count++; 623 | 624 | if (isset($selected_filters['category']) && in_array($category['id_category'], $selected_filters['category'])) 625 | $tmp_array[$category['id_category']]['checked'] = true; 626 | } 627 | if ($categories_with_products_count || !Configuration::get('PS_LAYERED_HIDE_0_VALUES')) 628 | $filter_blocks[] = array ( 629 | 'type_lite' => 'category', 630 | 'type' => 'category', 631 | 'id_key' => 0, 'name' => $this->l('Categories'), 632 | 'values' => $tmp_array, 633 | 'filter_show_limit' => $filter['filter_show_limit'], 634 | 'filter_type' => $filter['filter_type'] 635 | ); 636 | } 637 | break; 638 | } 639 | } 640 | 641 | // All non indexable attribute and feature 642 | $non_indexable = array(); 643 | 644 | // Get all non indexable attribute groups 645 | foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' 646 | SELECT public_name 647 | FROM `'._DB_PREFIX_.'attribute_group_lang` agl 648 | LEFT JOIN `'._DB_PREFIX_.'layered_indexable_attribute_group` liag 649 | ON liag.id_attribute_group = agl.id_attribute_group 650 | WHERE indexable IS NULL OR indexable = 0 651 | AND id_lang = '.(int)$id_lang) as $attribute) 652 | $non_indexable[] = Tools::link_rewrite($attribute['public_name']); 653 | 654 | // Get all non indexable features 655 | foreach (Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' 656 | SELECT name 657 | FROM `'._DB_PREFIX_.'feature_lang` fl 658 | LEFT JOIN `'._DB_PREFIX_.'layered_indexable_feature` lif 659 | ON lif.id_feature = fl.id_feature 660 | WHERE indexable IS NULL OR indexable = 0 661 | AND id_lang = '.(int)$id_lang) as $attribute) 662 | $non_indexable[] = Tools::link_rewrite($attribute['name']); 663 | 664 | //generate SEO link 665 | $param_selected = ''; 666 | $param_product_url = ''; 667 | $option_checked_array = array(); 668 | $param_group_selected_array = array(); 669 | $title_values = array(); 670 | $meta_values = array(); 671 | 672 | //get filters checked by group 673 | 674 | foreach ($filter_blocks as $type_filter) 675 | { 676 | $filter_name = (!empty($type_filter['url_name']) ? $type_filter['url_name'] : $type_filter['name']); 677 | $filter_meta = (!empty($type_filter['meta_title']) ? $type_filter['meta_title'] : $type_filter['name']); 678 | $attr_key = $type_filter['type'].'_'.$type_filter['id_key']; 679 | 680 | $param_group_selected = ''; 681 | 682 | if (in_array(Tools::strtolower($type_filter['type']), array('price', 'weight')) 683 | && (float)$type_filter['values'][0] > (float)$type_filter['min'] 684 | && (float)$type_filter['values'][1] > (float)$type_filter['max']) 685 | { 686 | $param_group_selected .= $this->getAnchor().str_replace($this->getAnchor(), '_', $type_filter['values'][0]) 687 | .$this->getAnchor().str_replace($this->getAnchor(), '_', $type_filter['values'][1]); 688 | $param_group_selected_array[Tools::link_rewrite($filter_name)][] = Tools::link_rewrite($filter_name); 689 | 690 | if (!isset($title_values[$filter_meta])) 691 | $title_values[$filter_meta] = array(); 692 | $title_values[$filter_meta][] = $filter_meta; 693 | if (!isset($meta_values[$attr_key])) 694 | $meta_values[$attr_key] = array('title' => $filter_meta, 'values' => array()); 695 | $meta_values[$attr_key]['values'][] = $filter_meta; 696 | } 697 | else 698 | { 699 | foreach ($type_filter['values'] as $key => $value) 700 | { 701 | if (is_array($value) && array_key_exists('checked', $value )) 702 | { 703 | $value_name = !empty($value['url_name']) ? $value['url_name'] : $value['name']; 704 | $value_meta = !empty($value['meta_title']) ? $value['meta_title'] : $value['name']; 705 | $param_group_selected .= $this->getAnchor().str_replace($this->getAnchor(), '_', Tools::link_rewrite($value_name)); 706 | $param_group_selected_array[Tools::link_rewrite($filter_name)][] = Tools::link_rewrite($value_name); 707 | 708 | if (!isset($title_values[$filter_meta])) 709 | $title_values[$filter_meta] = array(); 710 | $title_values[$filter_meta][] = $value_name; 711 | if (!isset($meta_values[$attr_key])) 712 | $meta_values[$attr_key] = array('title' => $filter_meta, 'values' => array()); 713 | $meta_values[$attr_key]['values'][] = $value_meta; 714 | } 715 | else 716 | $param_group_selected_array[Tools::link_rewrite($filter_name)][] = array(); 717 | } 718 | } 719 | 720 | if (!empty($param_group_selected)) 721 | { 722 | $param_selected .= '/'.str_replace($this->getAnchor(), '_', Tools::link_rewrite($filter_name)).$param_group_selected; 723 | $option_checked_array[Tools::link_rewrite($filter_name)] = $param_group_selected; 724 | } 725 | // select only attribute and group attribute to display an unique product combination link 726 | if (!empty($param_group_selected) && $type_filter['type'] == 'id_attribute_group') 727 | $param_product_url .= '/'.str_replace($this->getAnchor(), '_', Tools::link_rewrite($filter_name)).$param_group_selected; 728 | 729 | } 730 | 731 | if ($this->page > 1) 732 | $param_selected .= '/page-'.$this->page; 733 | 734 | $blacklist = array('weight', 'price'); 735 | 736 | if (!Configuration::get('PS_LAYERED_FILTER_INDEX_CDT')) 737 | $blacklist[] = 'condition'; 738 | if (!Configuration::get('PS_LAYERED_FILTER_INDEX_QTY')) 739 | $blacklist[] = 'quantity'; 740 | if (!Configuration::get('PS_LAYERED_FILTER_INDEX_MNF')) 741 | $blacklist[] = 'manufacturer'; 742 | if (!Configuration::get('PS_LAYERED_FILTER_INDEX_CAT')) 743 | $blacklist[] = 'category'; 744 | 745 | $global_nofollow = false; 746 | 747 | foreach ($filter_blocks as &$type_filter) 748 | { 749 | $filter_name = (!empty($type_filter['url_name']) ? $type_filter['url_name'] : $type_filter['name']); 750 | 751 | if (count($type_filter) > 0 && !isset($type_filter['slider'])) 752 | { 753 | foreach ($type_filter['values'] as $key => $values) 754 | { 755 | $nofollow = false; 756 | if (!empty($values['checked']) && in_array($type_filter['type'], $blacklist)) 757 | $global_nofollow = true; 758 | 759 | $option_checked_clone_array = $option_checked_array; 760 | 761 | // If not filters checked, add parameter 762 | $value_name = !empty($values['url_name']) ? $values['url_name'] : $values['name']; 763 | 764 | if (!in_array(Tools::link_rewrite($value_name), $param_group_selected_array[Tools::link_rewrite($filter_name)])) 765 | { 766 | // Update parameter filter checked before 767 | if (array_key_exists(Tools::link_rewrite($filter_name), $option_checked_array)) 768 | { 769 | $option_checked_clone_array[Tools::link_rewrite($filter_name)] = $option_checked_clone_array[Tools::link_rewrite($filter_name)]. 770 | $this->getAnchor().str_replace($this->getAnchor(), '_', Tools::link_rewrite($value_name)); 771 | 772 | if (in_array($type_filter['type'], $blacklist)) 773 | $nofollow = true; 774 | } 775 | else 776 | $option_checked_clone_array[Tools::link_rewrite($filter_name)] = $this->getAnchor(). 777 | str_replace($this->getAnchor(), '_', Tools::link_rewrite($value_name)); 778 | } 779 | else 780 | { 781 | // Remove selected parameters 782 | $option_checked_clone_array[Tools::link_rewrite($filter_name)] = str_replace($this->getAnchor(). 783 | str_replace($this->getAnchor(), '_', Tools::link_rewrite($value_name)), '', $option_checked_clone_array[Tools::link_rewrite($filter_name)]); 784 | if (empty($option_checked_clone_array[Tools::link_rewrite($filter_name)])) 785 | unset($option_checked_clone_array[Tools::link_rewrite($filter_name)]); 786 | } 787 | $parameters = ''; 788 | ksort($option_checked_clone_array); // Order parameters 789 | foreach ($option_checked_clone_array as $key_group => $value_group) 790 | $parameters .= '/'.str_replace($this->getAnchor(), '_', $key_group).$value_group; 791 | 792 | // Add nofollow if any blacklisted filters ins in parameters 793 | foreach ($filter_blocks as $filter) 794 | { 795 | $name = Tools::link_rewrite((!empty($filter['url_name']) ? $filter['url_name'] : $filter['name'])); 796 | if (in_array($filter['type'], $blacklist) && strpos($parameters, $name.'-') !== false) 797 | $nofollow = true; 798 | } 799 | 800 | // Check if there is an non indexable attribute or feature in the url 801 | foreach ($non_indexable as $value) 802 | if (strpos($parameters, '/'.$value) !== false) 803 | $nofollow = true; 804 | 805 | $type_filter['values'][$key]['link'] = Context::getContext()->link->getCategoryLink($parent, null, null).'#'.ltrim($parameters, '/'); 806 | $type_filter['values'][$key]['rel'] = ($nofollow) ? 'nofollow' : ''; 807 | } 808 | } 809 | } 810 | 811 | $n_filters = 0; 812 | if (isset($selected_filters['price'])) 813 | if ($price_array['min'] == $selected_filters['price'][0] && $price_array['max'] == $selected_filters['price'][1]) 814 | unset($selected_filters['price']); 815 | if (isset($selected_filters['weight'])) 816 | if ($weight_array['min'] == $selected_filters['weight'][0] && $weight_array['max'] == $selected_filters['weight'][1]) 817 | unset($selected_filters['weight']); 818 | 819 | foreach ($selected_filters as $filters) 820 | $n_filters += count($filters); 821 | 822 | $cache = array( 823 | 'layered_show_qties' => (int)Configuration::get('PS_LAYERED_SHOW_QTIES'), 824 | 'id_category_layered' => (int)$id_parent, 825 | 'selected_filters' => $selected_filters, 826 | 'n_filters' => (int)$n_filters, 827 | 'nbr_filterBlocks' => count($filter_blocks), 828 | 'filters' => $filter_blocks, 829 | 'title_values' => $title_values, 830 | 'meta_values' => $meta_values, 831 | 'current_friendly_url' => $param_selected, 832 | 'param_product_url' => $param_product_url, 833 | 'no_follow' => (!empty($param_selected) || $global_nofollow) 834 | ); 835 | 836 | return $cache; 837 | } 838 | 839 | private static function getPriceFilterSubQuery($filter_value) 840 | { 841 | $id_currency = (int)Context::getContext()->currency->id; 842 | 843 | if (isset($filter_value) && $filter_value) 844 | { 845 | $price_filter_query = ' 846 | INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi ON (psi.id_product = p.id_product AND psi.id_currency = '.(int)$id_currency.' 847 | AND psi.price_min <= '.(int)$filter_value[1].' AND psi.price_max >= '.(int)$filter_value[0].' AND psi.id_shop='.(int)Context::getContext()->shop->id.') '; 848 | } 849 | else 850 | { 851 | $price_filter_query = ' 852 | INNER JOIN `'._DB_PREFIX_.'layered_price_index` psi 853 | ON (psi.id_product = p.id_product AND psi.id_currency = '.(int)$id_currency.' AND psi.id_shop='.(int)Context::getContext()->shop->id.') '; 854 | } 855 | 856 | return array('join' => $price_filter_query, 'select' => ', psi.price_min, psi.price_max'); 857 | } 858 | 859 | private static function filterProductsByPrice($filter_value, $product_collection) 860 | { 861 | if (empty($filter_value)) 862 | return $product_collection; 863 | foreach ($product_collection as $key => $product) 864 | { 865 | if (isset($filter_value) && $filter_value && isset($product['price_min']) && isset($product['id_product']) 866 | && ((int)$filter_value[0] > $product['price_min'] || (int)$filter_value[1] < $product['price_max'])) 867 | { 868 | $price = Product::getPriceStatic($product['id_product'], Configuration::get('PS_LAYERED_FILTER_PRICE_USETAX')); 869 | if ($price < $filter_value[0] || $price > $filter_value[1]) 870 | continue; 871 | unset($product_collection[$key]); 872 | } 873 | } 874 | return $product_collection; 875 | } 876 | 877 | private static function getWeightFilterSubQuery($filter_value, $ignore_join) 878 | { 879 | if (isset($filter_value) && $filter_value) 880 | if ($filter_value[0] != 0 || $filter_value[1] != 0) 881 | return array('where' => ' AND p.`weight` BETWEEN '.(float)($filter_value[0] - 0.001).' AND '.(float)($filter_value[1] + 0.001).' '); 882 | 883 | return array(); 884 | } 885 | 886 | private static function getId_featureFilterSubQuery($filter_value, $ignore_join) 887 | { 888 | if (empty($filter_value)) 889 | return array(); 890 | $query_filters = ' AND p.id_product IN (SELECT id_product FROM '._DB_PREFIX_.'feature_product fp WHERE '; 891 | foreach ($filter_value as $filter_val) 892 | $query_filters .= 'fp.`id_feature_value` = '.(int)$filter_val.' OR '; 893 | $query_filters = rtrim($query_filters, 'OR ').') '; 894 | 895 | return array('where' => $query_filters); 896 | } 897 | private static function getId_attribute_groupFilterSubQuery($filter_value, $ignore_join) 898 | { 899 | if (empty($filter_value)) 900 | return array(); 901 | $query_filters = ' 902 | AND p.id_product IN (SELECT pa.`id_product` 903 | FROM `'._DB_PREFIX_.'product_attribute_combination` pac 904 | LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.`id_product_attribute` = pac.`id_product_attribute`) 905 | WHERE '; 906 | 907 | foreach ($filter_value as $filter_val) 908 | $query_filters .= 'pac.`id_attribute` = '.(int)$filter_val.' OR '; 909 | $query_filters = rtrim($query_filters, 'OR ').') '; 910 | 911 | return array('where' => $query_filters); 912 | } 913 | 914 | private static function getCategoryFilterSubQuery($filter_value, $ignore_join) 915 | { 916 | if (empty($filter_value)) 917 | return array(); 918 | $query_filters_join = ''; 919 | $query_filters_where = ' AND p.id_product IN (SELECT id_product FROM '._DB_PREFIX_.'category_product cp WHERE '; 920 | foreach ($filter_value as $id_category) 921 | $query_filters_where .= 'cp.`id_category` = '.(int)$id_category.' OR '; 922 | $query_filters_where = rtrim($query_filters_where, 'OR ').') '; 923 | 924 | return array('where' => $query_filters_where, 'join' => $query_filters_join); 925 | } 926 | 927 | private static function getQuantityFilterSubQuery($filter_value, $ignore_join) 928 | { 929 | if (count($filter_value) == 2 || empty($filter_value)) 930 | return array(); 931 | 932 | $query_filters_join = ''; 933 | 934 | $query_filters = ' AND sav.quantity '.(!$filter_value[0] ? '<=' : '>').' 0 '; 935 | $query_filters_join = 'LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.id_product = p.id_product AND sav.id_shop = '.(int)Context::getContext()->shop->id.') '; 936 | 937 | return array('where' => $query_filters, 'join' => $query_filters_join); 938 | } 939 | 940 | private static function getManufacturerFilterSubQuery($filter_value, $ignore_join) 941 | { 942 | if (empty($filter_value)) 943 | $query_filters = ''; 944 | else 945 | { 946 | array_walk($filter_value, create_function('&$id_manufacturer', '$id_manufacturer = (int)$id_manufacturer;')); 947 | $query_filters = ' AND p.id_manufacturer IN ('.implode($filter_value, ',').')'; 948 | } 949 | if ($ignore_join) 950 | return array('where' => $query_filters, 'select' => ', m.name'); 951 | else 952 | return array('where' => $query_filters, 'select' => ', m.name', 'join' => 'LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.id_manufacturer = p.id_manufacturer) '); 953 | } 954 | 955 | private static function getConditionFilterSubQuery($filter_value, $ignore_join) 956 | { 957 | if (count($filter_value) == 3 || empty($filter_value)) 958 | return array(); 959 | 960 | $query_filters = ' AND product_shop.condition IN ('; 961 | 962 | foreach ($filter_value as $cond) 963 | $query_filters .= '\''.$cond.'\','; 964 | $query_filters = rtrim($query_filters, ',').') '; 965 | 966 | return array('where' => $query_filters); 967 | } 968 | 969 | } 970 | -------------------------------------------------------------------------------- /override/modules/blocklayered/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /override/modules/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /translations/fr.php: -------------------------------------------------------------------------------- 1 | advancedfeaturesvalues_52444beab2c8168a0b6ae77b614641eb'] = 'Valeurs de caractéristiques avancées'; 6 | $_MODULE['<{advancedfeaturesvalues}prestashop>advancedfeaturesvalues_fa4c4a634ea71aa62d2349969bcdbb6b'] = 'Permet de sélectionner plusieurs valeurs de caractéristiques, ainsi que de les ordonner.'; 7 | $_MODULE['<{advancedfeaturesvalues}prestashop>advancedfeaturesvalues_876f23178c29dc2552c0b48bf23cd9bd'] = 'Êtes-vous sûr de vouloir désinstaller ce module?'; 8 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_16b71e8aeabca389b55423f00bd17e33'] = 'Attribuer des caractéristiques à ce produit'; 9 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_e05477ed7830eede8e2f6473a5fb1873'] = 'Vous pouvez préciser une valeur pour chaque caractéristique pertinente concernant ce produit ; les champs vides ne seront pas affichés.'; 10 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_1ebd268cbd989b7119c29d63cd622222'] = 'Vous pouvez définir une valeur spécifique, ou choisir parmi les valeurs existantes prédéfinies que vous avez ajoutées précédemment.'; 11 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_21021ea0e52be8e9c599f4dff41e5be0'] = 'Caractéristique'; 12 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_8bcdd31a1ab28f0db60efb2087c3f235'] = 'Valeur prédéfinie'; 13 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_e81c4e4f2b7b93b481e13a8553c2ae1b'] = 'ou'; 14 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_12085f07b6313b69c63a625d8e23f706'] = 'Valeur personnalisée'; 15 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_382b0f5185773fa0f67a8ed8056c7759'] = 'N/D'; 16 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_544baae42433c186ff222736db985d7d'] = 'Ajouter une valeur prédéfinie dans un premier temps'; 17 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_5fb1f955b45e38e31789286a1790398d'] = 'TOUS'; 18 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_d61248df0ca451d57196a4b4cdb35e1b'] = 'Il n\'y a pas de caractéristiques définies'; 19 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_d6ae681fcd58f1e1936ca97da36528ff'] = 'Ajouter une nouvel caractéristique'; 20 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_ea4788705e6873b424c65e91c2846b19'] = 'Annuler'; 21 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_c9cc8cce247e49bae79f15173ce97354'] = 'Enregistrer'; 22 | $_MODULE['<{advancedfeaturesvalues}prestashop>features_9ea67be453eaccf020697b4654fc021a'] = 'Enregistrer et rester'; 23 | -------------------------------------------------------------------------------- /upgrade/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../../"); 35 | exit; -------------------------------------------------------------------------------- /upgrade/install-1.0.3.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | if (!defined('_PS_VERSION_')) 28 | exit; 29 | 30 | function upgrade_module_1_0_3($object) 31 | { 32 | return $object->registerHook('header'); 33 | } 34 | -------------------------------------------------------------------------------- /views/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /views/js/blocklayered.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 2007-2015 PrestaShop 3 | * 4 | * NOTICE OF LICENSE 5 | * 6 | * This source file is subject to the Academic Free License (AFL 3.0) 7 | * that is bundled with this package in the file LICENSE.txt. 8 | * It is also available through the world-wide-web at this URL: 9 | * http://opensource.org/licenses/afl-3.0.php 10 | * If you did not receive a copy of the license and are unable to 11 | * obtain it through the world-wide-web, please send an email 12 | * to license@prestashop.com so we can send you a copy immediately. 13 | * 14 | * DISCLAIMER 15 | * 16 | * Do not edit or add to this file if you wish to upgrade PrestaShop to newer 17 | * versions in the future. If you wish to customize PrestaShop for your 18 | * needs please refer to http://www.prestashop.com for more information. 19 | * 20 | * @author PrestaShop SA 21 | * @copyright 2007-2015 PrestaShop SA 22 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 23 | * International Registred Trademark & Property of PrestaShop SA 24 | */ 25 | function reloadContent(params_plus) 26 | { 27 | stopAjaxQuery(); 28 | 29 | if (!ajaxLoaderOn) 30 | { 31 | $('.product_list').prepend($('#layered_ajax_loader').html()); 32 | $('.product_list').css('opacity', '0.7'); 33 | ajaxLoaderOn = 1; 34 | } 35 | 36 | data = $('#layered_form').serialize(); 37 | $('.layered_slider').each( function () { 38 | var sliderStart = $(this).slider('values', 0); 39 | var sliderStop = $(this).slider('values', 1); 40 | if (typeof(sliderStart) == 'number' && typeof(sliderStop) == 'number') 41 | data += '&'+$(this).attr('id')+'='+sliderStart+'_'+sliderStop; 42 | }); 43 | 44 | $(['price', 'weight']).each(function(it, sliderType) 45 | { 46 | if ($('#layered_'+sliderType+'_range_min').length) 47 | { 48 | data += '&layered_'+sliderType+'_slider='+$('#layered_'+sliderType+'_range_min').val()+'_'+$('#layered_'+sliderType+'_range_max').val(); 49 | } 50 | }); 51 | 52 | $('#layered_form .select option').each( function () { 53 | if($(this).attr('id') && $(this).parent().val() == $(this).val()) 54 | { 55 | data += '&'+$(this).attr('id') + '=' + $(this).val(); 56 | } 57 | }); 58 | 59 | if ($('.selectProductSort').length && $('.selectProductSort').val()) 60 | { 61 | if ($('.selectProductSort').val().search(/orderby=/) > 0) 62 | { 63 | // Old ordering working 64 | var splitData = [ 65 | $('.selectProductSort').val().match(/orderby=(\w*)/)[1], 66 | $('.selectProductSort').val().match(/orderway=(\w*)/)[1] 67 | ]; 68 | } 69 | else 70 | { 71 | // New working for default theme 1.4 and theme 1.5 72 | var splitData = $('.selectProductSort').val().split(':'); 73 | } 74 | data += '&orderby='+splitData[0]+'&orderway='+splitData[1]; 75 | } 76 | if ($('select[name=n]:first').length) 77 | { 78 | if (params_plus) 79 | data += '&n=' + $('select[name=n]:first').val(); 80 | else 81 | data += '&n=' + $('div.pagination form.showall').find('input[name=n]').val(); 82 | } 83 | 84 | var slideUp = true; 85 | if (params_plus == undefined) 86 | { 87 | params_plus = ''; 88 | slideUp = false; 89 | } 90 | 91 | // Get nb items per page 92 | var n = ''; 93 | if (params_plus) 94 | { 95 | $('div.pagination select[name=n]').children().each(function(it, option) { 96 | if (option.selected) 97 | n = '&n=' + option.value; 98 | }); 99 | } 100 | ajaxQuery = $.ajax( 101 | { 102 | type: 'GET', 103 | url: baseDir + 'modules/advancedfeaturesvalues/blocklayered-ajax.php', 104 | data: data+"&"+params_plus+n, 105 | dataType: 'json', 106 | cache: false, // @todo see a way to use cache and to add a timestamps parameter to refresh cache each 10 minutes for example 107 | success: function(result) 108 | { 109 | if (result.meta_description != '') 110 | $('meta[name="description"]').attr('content', result.meta_description); 111 | 112 | if (result.meta_keywords != '') 113 | $('meta[name="keywords"]').attr('content', result.meta_keywords); 114 | 115 | if (result.meta_title != '') 116 | $('title').html(result.meta_title); 117 | 118 | if (result.heading != '') 119 | $('h1.page-heading .cat-name').html(result.heading); 120 | 121 | $('#layered_block_left').replaceWith(utf8_decode(result.filtersBlock)); 122 | $('.category-product-count, .heading-counter').html(result.categoryCount); 123 | 124 | if (result.nbRenderedProducts == result.nbAskedProducts) 125 | $('div.clearfix.selector1').hide(); 126 | 127 | if (result.productList) 128 | $('.product_list').replaceWith(utf8_decode(result.productList)); 129 | else 130 | $('.product_list').html(''); 131 | 132 | $('.product_list').css('opacity', '1'); 133 | if ($.browser.msie) // Fix bug with IE8 and aliasing 134 | $('.product_list').css('filter', ''); 135 | 136 | if (result.pagination.search(/[^\s]/) >= 0) { 137 | var pagination = $('
').html(result.pagination) 138 | var pagination_bottom = $('
').html(result.pagination_bottom); 139 | 140 | if ($('
').html(pagination).find('#pagination').length) 141 | { 142 | $('#pagination').show(); 143 | $('#pagination').replaceWith(pagination.find('#pagination')); 144 | } 145 | else 146 | { 147 | $('#pagination').hide(); 148 | } 149 | 150 | if ($('
').html(pagination_bottom).find('#pagination_bottom').length) 151 | { 152 | $('#pagination_bottom').show(); 153 | $('#pagination_bottom').replaceWith(pagination_bottom.find('#pagination_bottom')); 154 | } 155 | else 156 | { 157 | $('#pagination_bottom').hide(); 158 | } 159 | } 160 | else 161 | { 162 | $('#pagination').hide(); 163 | $('#pagination_bottom').hide(); 164 | } 165 | 166 | paginationButton(result.nbRenderedProducts, result.nbAskedProducts); 167 | ajaxLoaderOn = 0; 168 | 169 | // On submiting nb items form, relaod with the good nb of items 170 | $('div.pagination form').on('submit', function(e) 171 | { 172 | e.preventDefault(); 173 | val = $('div.pagination select[name=n]').val(); 174 | 175 | $('div.pagination select[name=n]').children().each(function(it, option) { 176 | if (option.value == val) 177 | $(option).attr('selected', true); 178 | else 179 | $(option).removeAttr('selected'); 180 | }); 181 | 182 | // Reload products and pagination 183 | reloadContent(); 184 | }); 185 | if (typeof(ajaxCart) != "undefined") 186 | ajaxCart.overrideButtonsInThePage(); 187 | 188 | if (typeof(reloadProductComparison) == 'function') 189 | reloadProductComparison(); 190 | 191 | filters = result.filters; 192 | initFilters(); 193 | initSliders(); 194 | 195 | current_friendly_url = result.current_friendly_url; 196 | 197 | // Currente page url 198 | if (typeof(current_friendly_url) === 'undefined') 199 | current_friendly_url = '#'; 200 | 201 | // Get all sliders value 202 | $(['price', 'weight']).each(function(it, sliderType) 203 | { 204 | if ($('#layered_'+sliderType+'_slider').length) 205 | { 206 | // Check if slider is enable & if slider is used 207 | if(typeof($('#layered_'+sliderType+'_slider').slider('values', 0)) != 'object') 208 | { 209 | if ($('#layered_'+sliderType+'_slider').slider('values', 0) != $('#layered_'+sliderType+'_slider').slider('option' , 'min') 210 | || $('#layered_'+sliderType+'_slider').slider('values', 1) != $('#layered_'+sliderType+'_slider').slider('option' , 'max')) 211 | current_friendly_url += '/'+blocklayeredSliderName[sliderType]+'-'+$('#layered_'+sliderType+'_slider').slider('values', 0)+'-'+$('#layered_'+sliderType+'_slider').slider('values', 1) 212 | } 213 | } 214 | else if ($('#layered_'+sliderType+'_range_min').length) 215 | { 216 | current_friendly_url += '/'+blocklayeredSliderName[sliderType]+'-'+$('#layered_'+sliderType+'_range_min').val()+'-'+$('#layered_'+sliderType+'_range_max').val(); 217 | } 218 | }); 219 | 220 | window.location.href = current_friendly_url; 221 | 222 | if (current_friendly_url != '#/show-all') 223 | $('div.clearfix.selector1').show(); 224 | 225 | lockLocationChecking = true; 226 | 227 | if(slideUp) 228 | $.scrollTo('.product_list', 400); 229 | updateProductUrl(); 230 | 231 | $('.hide-action').each(function() { 232 | hideFilterValueAction(this); 233 | }); 234 | 235 | if (display instanceof Function) { 236 | var view = $.totalStorage('display'); 237 | 238 | if (view && view != 'grid') 239 | display(view); 240 | } 241 | } 242 | }); 243 | ajaxQueries.push(ajaxQuery); 244 | } 245 | -------------------------------------------------------------------------------- /views/js/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /views/templates/admin/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /views/templates/admin/products/features.tpl: -------------------------------------------------------------------------------- 1 | {* 2 | * 2007-2015 PrestaShop 3 | * 4 | * NOTICE OF LICENSE 5 | * 6 | * This source file is subject to the Academic Free License (AFL 3.0) 7 | * that is bundled with this package in the file LICENSE.txt. 8 | * It is also available through the world-wide-web at this URL: 9 | * http://opensource.org/licenses/afl-3.0.php 10 | * If you did not receive a copy of the license and are unable to 11 | * obtain it through the world-wide-web, please send an email 12 | * to license@prestashop.com so we can send you a copy immediately. 13 | * 14 | * DISCLAIMER 15 | * 16 | * Do not edit or add to this file if you wish to upgrade PrestaShop to newer 17 | * versions in the future. If you wish to customize PrestaShop for your 18 | * needs please refer to http://www.prestashop.com for more information. 19 | * 20 | * @author PrestaShop SA 21 | * @copyright 2007-2015 PrestaShop SA 22 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 23 | * International Registered Trademark & Property of PrestaShop SA 24 | *} 25 | 26 | {if isset($product->id)} 27 |
28 | 29 |

{l s='Assign features to this product' mod='advancedfeaturesvalues'}

30 | 31 |
32 | {l s='You can specify a value for each relevant feature regarding this product. Empty fields will not be displayed.' mod='advancedfeaturesvalues'}
33 | {l s='You can either create a specific value, or select among the existing pre-defined values you\'ve previously added.' mod='advancedfeaturesvalues'} 34 |
35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | {foreach from=$available_features item=available_feature} 47 | 48 | 49 | 67 | 124 | 125 | 126 | {foreachelse} 127 | 128 | 129 | 130 | {/foreach} 131 | 132 |
{l s='Feature' mod='advancedfeaturesvalues'}{l s='Pre-defined value' mod='advancedfeaturesvalues'}{l s='or' mod='advancedfeaturesvalues'} {l s='Customized value' mod='advancedfeaturesvalues'}
{$available_feature.name|escape:'html'} 50 | {if sizeof($available_feature.featureValues)} 51 | 59 | {else} 60 | 61 | {l s='N/A' mod='advancedfeaturesvalues'} - 62 | {l s='Add pre-defined values first' mod='advancedfeaturesvalues'} 64 | 65 | {/if} 66 | 68 | 69 | 91 | 92 | {foreach from=$languages key=k item=language} 93 | {if $languages|count > 1} 94 |
95 |
96 | {/if} 97 | 103 | 104 | {if $languages|count > 1} 105 |
106 |
107 | 111 | 119 |
120 |
121 | {/if} 122 | {/foreach} 123 |
{l s='No features have been defined' mod='advancedfeaturesvalues'}
133 | 134 | 135 | {l s='Add a new feature' mod='advancedfeaturesvalues'} 136 | 137 | 142 |
143 | 175 | {/literal} 176 | 177 | {/if} 178 | -------------------------------------------------------------------------------- /views/templates/admin/products/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; -------------------------------------------------------------------------------- /views/templates/index.php: -------------------------------------------------------------------------------- 1 | 22 | * @copyright 2007-2014 PrestaShop SA 23 | * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 24 | * International Registered Trademark & Property of PrestaShop SA 25 | */ 26 | 27 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 28 | header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); 29 | 30 | header("Cache-Control: no-store, no-cache, must-revalidate"); 31 | header("Cache-Control: post-check=0, pre-check=0", false); 32 | header("Pragma: no-cache"); 33 | 34 | header("Location: ../"); 35 | exit; --------------------------------------------------------------------------------