Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hierarchical Product Features #4

Open
mjawaids opened this issue May 9, 2015 · 37 comments
Open

Hierarchical Product Features #4

mjawaids opened this issue May 9, 2015 · 37 comments

Comments

@mjawaids
Copy link

mjawaids commented May 9, 2015

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.

@jdanthinne
Copy link
Owner

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.

@mjawaids
Copy link
Author

OK. Could you provide some documentation or a short summary of your code? I can try extending it. Thanks.

@jdanthinne
Copy link
Owner

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.

@mjawaids
Copy link
Author

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
#4 (comment)
.

@jdanthinne
Copy link
Owner

What do you mean by "showing the relationship"? Visually?

@mjawaids
Copy link
Author

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
#4 (comment)
.

@jdanthinne
Copy link
Owner

What you're talking about looks more like categories than features to me… don't you think?

@mjawaids
Copy link
Author

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
#4 (comment)
.

@mjawaids
Copy link
Author

I have couple questions for you.

  1. What is blocklayered.js in your code and why have you used it?
  2. 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;

@mjawaids
Copy link
Author

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?

@jdanthinne
Copy link
Owner

  1. 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
  2. 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).
  3. I think you have to change almost all the files, because this kind of relationship influences everything…

@mjawaids
Copy link
Author

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.

@jdanthinne
Copy link
Owner

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.

@mjawaids
Copy link
Author

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), ), ); ``` }

@jdanthinne
Copy link
Owner

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)

@mjawaids
Copy link
Author

OK thanks. I have another question.
Where does the method getFrontFeaturesStatic() in /override/classes/Product.php gets called from and what it does?

@jdanthinne
Copy link
Owner

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.

@mjawaids
Copy link
Author

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.

@jdanthinne
Copy link
Owner

You have to override the renderForm() function in /controllers/admin/AdminFeaturesController.php, I think.

@mjawaids
Copy link
Author

Ya I did that but its not working. Any clues?

@jdanthinne
Copy link
Owner

What is not working exactly? Where can I see the code/fork?

@mjawaids
Copy link
Author

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
#4 (comment)
.

@mjawaids
Copy link
Author

I think attachment didn't went through. Let me know your email I'll send it to you.

@jdanthinne
Copy link
Owner

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.

@mjawaids
Copy link
Author

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.

@jdanthinne
Copy link
Owner

As I told you, I can hardly help you if you don't give me the link to your repository.

@mjawaids
Copy link
Author

@mjawaids
Copy link
Author

OK, it saves parent feature value when adding a new feature. But if I edit a feature it doesn't update.

@jdanthinne
Copy link
Owner

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?

@mjawaids
Copy link
Author

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
#4 (comment)
.

@jdanthinne
Copy link
Owner

Does Prestashop say "Feature updated" or nothing? No fields are updated or only your new field?

@mjawaids
Copy link
Author

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
#4 (comment)
.

@mjawaids
Copy link
Author

Any clue?

@jdanthinne
Copy link
Owner

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.

@jdanthinne
Copy link
Owner

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).

@mjawaids
Copy link
Author

mjawaids commented Jun 1, 2015

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.

@mjawaids
Copy link
Author

mjawaids commented Jun 1, 2015

The tree they are using is I think for displaying it as tree structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants