vkotecha91 wrote:Sure.
Create a Product.
Create a product attributes ex. Image Squares. 3 values. Edit a value and upload square image and product image.
Create another product attribute. Image squares. 3 values. Edit a value and upload square image and product image.
add a condition that if a value from first attribute is selected then only second product attribute should appear.
The first attribute selection will change the product image. The second won't.
Now if you remove the condition, second one selection will also work.
Update :
even after removing condition,if you select the attribute 2 directly, then it changes the product image.
Selecting first attribute,and then selecting second also doesn't work.
after digging, i figure out that
ShoppingController's method
ProductDetails_AttributeChange possibly giving the problem.
in the method, to load picture based on selection, following code is written
//just load (return) the first found picture (in case if we have several distinct attributes with associated pictures)
//actually we're going to support pictures associated to attribute combinations (not attribute values) soon. it'll more flexible approach
var attributeValues = _productAttributeParser.ParseProductAttributeValues(attributeXml);
var attributeValueWithPicture = attributeValues.FirstOrDefault(x => x.PictureId > 0);
here i get two attributeValues both have PictureId > 0 and it needs to pick the one with selection choice, but the code is picking first or default so it doesn't load the correct image.
Please atleast guide me what to do to load correct image.
I've got the same problem. Here is a solution that might work. I know it's
super duper uncool to adjust the core but because this bug is present in 3.9 and previous and because the topic isn't solved on github yet here is a small fix that might help you out.
Just select the last item from the list that way you will change the picture to what is selected even when it has multiple conditions:
In Nop.Web.Controllers ShoppingCartController go to ProductDetails_AttributeChange method +- line 1001
// comment out this line var attributeValueWithPicture = attributeValues.FirstOrDefault(x => x.PictureId > 0);
/* add this line */ var attributeValueWithPicture = attributeValues.LastOrDefault();
That worked for me.
Please note changing the core is not good practice and remember when you update Nop Commerce the Nop team could have an other and probably much better approach.