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.