Predefined Attributes changes to reflect on ALL products with those attributes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 7 años
We have set up some predefined product attributes.

We have a situation where we could have up to 50 products with the same product attributes attached to them.

The issue is that if we need to make a price change to an attribute, the way NOP sets up the attributes, and we go into the predefined product attribute, the price change on the attribute does not reflect price attached to the product.  This looks like it is because once the attributes are attached to the product, they become separate from the Predefined attributes.  

We need to trigger the save on the Predefined attributes to cascade through all the attributes that are attached to products with those attributes.

Example:

Products 1 through 50 have attribute "A" and the price adjustment is $10.  At a later date we need to adjust attribute "A" to $12.  But the way they are set up now, we would have to go to EACH of the 50 products and change attribute "A" manually.  

Is there a way to use code to trigger on the 'Save' of a predefined field property change, to cascade through ALL products that have that attribute "A" attached to it, so we don't have to go into all products with attribute "A" and change the price manually or reattach the predefined attribute?

Does that make sense?
Hace 7 años
One possibility might be to setup to the product attribute values as associated to product attribute value types instead of simple attribute value types: http://docs.nopcommerce.com/pages/viewpage.action?pageId=1441945

Then when you want to change the price of the attribute value you can actually just update the price of the associated product.
Hace 7 años
Hi Pete,

That is a good recommendation and A solution, but now we run into the issue where, lets say we have 50 different TVs that were configured with the same predefined attributes.

TV One:
Attributes
Attribute "A"
Attribute "B"

Brand Two:
Attributes
Attribute "A"
Attribute "B"

etc.

Now what if we need to add new attribute with the same value to ALL 50 products listed on the site, ALL with the attributes and we need to add a new attribute to the all 50 products that is the same attribute?

There is not a "master" attribute list that we can easily add the attribute to a group without having to touch every single of the 50 TV products so that the attribute list updates on each.  This is why we are looking for an attribute list that IF the values are updated, it cascades through all products that have those attributes, without having to go through each product with those attributes.

I don't understand why the product attributes section has the predefined attributes have a tab for "Used by products", but when you try to add another attribute option to an existing list of predefined attributes, that the values don't update on ALL products that have the same attribute list tied to them.


I configure, in the attributes section of the NopCommerce admin, NOT on the product itself


I see it is configured and used on a product


BUT when I try to add another new attribute to the initial predefined attribute list the new attribute value DOES NOT show on the product that is using the attribute list.


(NOT showing updated value from predefined attribute list on product)



NOW this is not ideal if 50 products have that same list, because the way NOP does it now, we would have to go into ALL 50+ products add add the new attribute.

This is why going to back to my original question, in code, at which point could we map the predefined attribute list and have those save to ALL products with the same attribute lists tied to them and update either a property of the attribute( price, preselected, etc), AND have the ability to add a new attribute without having to manually to into every single product that had the predefined attribute list tied to them and add the new value. Why can't an updated to the predefined attribute list cascade through all products that IT ways are listed as being used by the products.
Hace 7 años
cmosqueda wrote:
I don't understand why the product attributes section has the predefined attributes have a tab for "Used by products", but when you try to add another attribute option to an existing list of predefined attributes, that the values don't update on ALL products that have the same attribute list tied to them.

The 2 tabs aren't related. The Used by products tab just shows you which products have this product attribute linked to them. You can see that this is true because it will contain a list of products even if the attribute in question doesn't have any predefined values.

In fact the Used by products attribute existed before the concept of predefined product attribute values was introduced in nop and you can see from the code that the function that populates it goes off and grabs a list of all the products that use that particular attribute.

cmosqueda wrote:
NOW this is not ideal if 50 products have that same list, because the way NOP does it now, we would have to go into ALL 50+ products add add the new attribute.

The way that nop currently implements the predefined values is just as a convenience to quickly pre-populate the attribute values when adding a product attribute to the product. Once they've been added to the product they don't retain a link back to the predefined value that they originated from. In this respect they are different to specification attributes which share a common set of values that are mapped to the product (I think this is the behaviour you are expecting). It makes them flexible in that you can define different values and prices for each product but as you point out it means they can't be updated en masse.

cmosqueda wrote:
This is why going to back to my original question, in code, at which point could we map the predefined attribute list and have those save to ALL products with the same attribute lists tied to them and update either a property of the attribute( price, preselected, etc), AND have the ability to add a new attribute without having to manually to into every single product that had the predefined attribute list tied to them and add the new value. Why can't an updated to the predefined attribute list cascade through all products that IT ways are listed as being used by the products.

If you're looking at implementing this behaviour yourself either through code modification or in a plugin you could start by looking at the PredefinedProductAttributeValueCreatePopup, PredefinedProductAttributeValueEditPopup and PredefinedProductAttributeValueDelete methods in the ProductAttributeController. These are the controller actions that are called when you add, edit or delete a predefined attriubte value and they then call methods in the ProductAttributeService (such as UpdatePredefinedProductAttributeValue) which do the database updates and raise events once they've occurred.

In most situations I'd suggest writing a plugin that handles these events and carries out some further actions (like updating all the values associated to products) but I don't think that's going to work in this case because of what I mentioned above about there being no way to link the product attribute value back to the predefined attribute that it originated from (inserts and deletes could work but updates wouldn't as you don't have access to the original values once the predefined value has been updated). It might be easier to override the controller actions I've linked to above. That way you have access to the original and new values in the update action so you could potentially identify the product attribute values that would need to be updated.

Hope that makes sense even if it's probably not what you wanted to hear.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.