nopSolutions / nopCommerce

ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
https://www.nopcommerce.com
Other
9.09k stars 5.2k forks source link

Product Attribute value not found while it has value #7169

Closed deathgore closed 2 months ago

deathgore commented 2 months ago

nopCommerce version: 4.70

With upgrade to 4.70 logic for GetShoppingCartItemAttributeWarningsAsync in ShoppingCartService.cs was changed a bit.

Line 865-867 var attributeValuesStr = _productAttributeParser.ParseValues(attributesXml, a1.Id);:

if (productAttributeValues.Any() && !productAttributeValues.Any(x => attributeValuesStr.Contains(x.Id.ToString())))

attributeValuesStr has the value of the attribute and not the Id

Shouldn't it check here that productAttributeValues contains all selected values?

AndreiMaz commented 2 months ago

@skoshelev Probably related to https://github.com/nopSolutions/nopCommerce/commit/647e10308e93cfa517fd1d108d4e4f7936ace1b7 and https://github.com/nopSolutions/nopCommerce/commit/bf5a97f65a0a5d6fb322ecf7f2d0ab103ed26259

skoshelev commented 2 months ago

Hi @deathgore. I don't quite understand the problem you describe. The attributesXml parameter at the input has this format

<Attributes>
    <ProductAttribute ID="9">
        <ProductAttributeValue>
            <Value>21</Value>
        </ProductAttributeValue>
    </ProductAttribute>
    <ProductAttribute ID="10">
        <ProductAttributeValue>
            <Value>25</Value>
        </ProductAttributeValue>
    </ProductAttribute>
</Attributes>

after parsing, attributeValuesStr will always contain the value from the Value tag, which contains not a value, but an identifier

skoshelev commented 2 months ago

Closed #7169