advancedfeaturesvalues
advancedfeaturesvalues copied to clipboard
Hierarchical Product Features
Can you modify the module to provide parent-child relationship between 2 or more features. Selecting any value in parent feature should filter out the values in child feature. Similarly, if there is any grand child under child feature selecting value of child should filter values in grand child. This will also require the define the parent-child relationship when adding product features in admin.
That would be hard to do. I don't think I'm able to do that. Anyone interested in that can fork this project. Sorry.
OK. Could you provide some documentation or a short summary of your code? I can try extending it. Thanks.
The short summary is that the code overrides the default Feature controllers so that it allows multiple rows in the association DB table between products and features instead of just one, and also adds a new column in the features values table so it can handle ordering. If you need specific explanations of the code, just ask, but it is self-explanatory.
I would really appreciate if you could guide me meanwhile I extend it. First of all as you added a new field for ordering we would need another field for parent feature. Adding a field in db is not a problem but where do you think I should handle this parent field to show the relationship.
On Mon, May 11, 2015 at 11:21 PM Jérôme Danthinne [email protected] wrote:
The short summary is that the code overrides the default Feature controllers so that it allows multiple rows in the association DB table between products and features instead of just one, and also adds a new column in the features values table so it can handle ordering. If you need specific explanations of the code, just ask, but it is self-explanatory.
— Reply to this email directly or view it on GitHub https://github.com/jdanthinne/advancedfeaturesvalues/issues/4#issuecomment-101005758 .
What do you mean by "showing the relationship"? Visually?
When defining product features we need to tell the parent value for child value. For example: I add a product parent feature say 'Series' that has values HP Probook and Dell Latitude, and I add product child feature say 'Model' that has values 4540s and D800. Here I should be able to tell that 4540s belongs the HP Probook in parent feature and D800 belongs to Dell Latitude series.
On Tue, May 12, 2015 at 4:19 PM Jérôme Danthinne [email protected] wrote:
What do you mean by "showing the relationship"? Visually?
— Reply to this email directly or view it on GitHub https://github.com/jdanthinne/advancedfeaturesvalues/issues/4#issuecomment-101241649 .
What you're talking about looks more like categories than features to me… don't you think?
No I just gave an example. Actually the product can be compatible with multiple models and there can be hundreds of models while category is something like laptop, desktop etc.
Sent from my Phone. On May 12, 2015 8:01 PM, "Jérôme Danthinne" [email protected] wrote:
What you're talking about looks more like categories than features to me… don't you think?
— Reply to this email directly or view it on GitHub https://github.com/jdanthinne/advancedfeaturesvalues/issues/4#issuecomment-101310294 .
I have couple questions for you.
- What is blocklayered.js in your code and why have you used it?
- In file advancedfeaturesvalues.php:114 under function hookHeader() what this code snippet does: if (Tools::getValue('id_category', Tools::getValue('id_category_layered', Configuration::get('PS_HOME_CATEGORY'))) == Configuration::get('PS_HOME_CATEGORY')) return;
If I add new field parent_id_feature_value in feature_value table and want to reflect changes in back and front office what files do you think will change?
- blocklayered.js is an override of the original blocklayered module script, so it use advancedfeaturesvalues module when selecting a filter and making the Ajax request, instead of the default one
- It is also an override just to load our custom javascript file (mentioned above). The condition is there to abort the function if we're browsing the homepage (because the script isn't needed there).
- I think you have to change almost all the files, because this kind of relationship influences everything…
Thanks. Actually I'm new to Prestashop development and Prestashop docs are pretty basic while what I need is kind of advanced thing. I can do the architectural thing but if you could help me in developing this functionality I'll be very grateful to you. I think its a small change and just have to add one field in database table and some logic in module. Please let me know we can both together can do this. Thanks in advance.
Actually I'm new to Prestashop as well, and this module is the first one I've built. And I've done it for a client, so I've been paid for the time spent on this particular function. I'm sorry but I don't have the free time do that for you. If what you were asking was easy, I could, but believe me, it is not (for new PS developers). I think you should ask for help in the Prestashop forums, I've found many advices there.
Sorry to bother you again. There is an issue with your module. I'm not sure if its your module or is it Prestashop. When I install your module and then uninstall and delete it, it leaves FeatureValue.php file behind under override/classes folder with following content that is causing syntax errors. All other overridden files are successfully deleted except this one. Do you have any idea why this file is not being deleted?
'feature_value', 'primary' => 'id_feature_value', 'multilang' => true, 'fields' => array( 'id_feature' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'position' => array('type' => self::TYPE_INT, 'validate' => 'isInt'), 'custom' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'), 'value' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255), ), ); ``` }
Unfortunately, I don't think the issue is related to the module, but to Prestashop itself, and its uninstall function. No module installs itself, PS manages that, but it seems that sometimes, the process fails… (i.e. http://forge.prestashop.com/browse/PSCSX-4910)
OK thanks. I have another question. Where does the method getFrontFeaturesStatic() in /override/classes/Product.php gets called from and what it does?
This function is called when a page need to display all the feature values, given a feature id and a language. I had to override this function so I can order alphabetical instead of by ID.
Do you have any idea how to override Feature Add/Edit form so I can display my custom field as well. I am able to do the same thing for Feature Value but cannot find place to do for Feature.
You have to override the renderForm() function in /controllers/admin/AdminFeaturesController.php, I think.
Ya I did that but its not working. Any clues?
What is not working exactly? Where can I see the code/fork?
Attached is the code.
Muhammad Jawaid Shamshad
On Wed, May 27, 2015 at 5:21 PM, Jérôme Danthinne [email protected] wrote:
What is not working exactly? Where can I see the code/fork?
— Reply to this email directly or view it on GitHub https://github.com/jdanthinne/advancedfeaturesvalues/issues/4#issuecomment-105887940 .
I think attachment didn't went through. Let me know your email I'll send it to you.
I prefer not to handle that by emails. Just give me the link your repository on GitHub, and tell me what is not working from there, it will be much easier.
OK I fixed it. Actually had to call AdminController::renderForm() instead of parent::renderForm() in my override. But now there is new problem. My custom field for Feature is not saving in the database. Custom field for FeatureValue is working fine and saving in the database but not for Feature. What should I do so it also saves in the database.
As I told you, I can hardly help you if you don't give me the link to your repository.
Here you go https://github.com/mjawaids/advancedfeaturesvalues
OK, it saves parent feature value when adding a new feature. But if I edit a feature it doesn't update.
Does it output an error message (with debug mode enabled) ? But I'm kind of lost in what you're trying to achieve… Are you building parent-child relationship between features and child features AND between features values and features child values?? Wouldn't be easier to just do that for features values?
No it doesn't show any error. Yes that's what I'm trying to achieve. Basically relationship between feature and child feature is necessary in order for feature values to know who their parent are and show only parent values in drop drown instead of populating all the values from all the features.
Current problem is that parent feature is saving when adding new feature. But when I edit it, the parent feature doesn't get updated.
Do you get my point? If this is fixed then we are almost done with some minor tweaks. On May 28, 2015 7:38 PM, "Jérôme Danthinne" [email protected] wrote:
Does it output an error message (with debug mode enabled) ? But I'm kind of lost in what you're trying to achieve… Are you building parent-child relationship between features and child features AND between features values and features child values?? Wouldn't be easier to just do that for features values?
— Reply to this email directly or view it on GitHub https://github.com/jdanthinne/advancedfeaturesvalues/issues/4#issuecomment-106363264 .
Does Prestashop say "Feature updated" or nothing? No fields are updated or only your new field?
Yes it says feature updated and it does update the data but not my custom field. On May 29, 2015 8:14 PM, "Jérôme Danthinne" [email protected] wrote:
Does Prestashop say "Feature updated" or nothing? No fields are updated or only your new field?
— Reply to this email directly or view it on GitHub https://github.com/jdanthinne/advancedfeaturesvalues/issues/4#issuecomment-106842478 .
Any clue?
I've just had a look, and no, I don't understand directly why this isn't working. Perhaps you should have a look into the Category class/controllers, because it's already handling parent-children relationship in this one.
Yep, have a look at https://github.com/PrestaShop/PrestaShop/blob/1.6/controllers/admin/AdminCategoriesController.php#L477, they're using a tree index (but not documented).
My hierarchy problem is solved by adding a parent field for each feature and feature value since one feature/value can have only one parent. Current problem is when editing a feature it does not update the parent field that I have added while it does update other fields. Also, if I add a new feature it saves all the fields including the parent successfully. I'm not sure why it doesn't update when editing it.
The tree they are using is I think for displaying it as tree structure.