Where I can find the controller which manage this, image insisde

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 5 años


I found something in OrderModel.cs, but I need something before that, in which it decides where to show the SKU of the product, or the ones with attributes.

Thank you.
Hace 5 años
Hello,

In Nop 4.1, you can find the below code in OrderModelFactory.cs file that fills the SKU property:

//fill in additional values (not existing in the entity)
orderItemModel.Sku = _productService.FormatSku(orderItem.Product, orderItem.AttributesXml);


Also, check this code in _OrderDetails.Products.cshtml:

@if (!string.IsNullOrEmpty(item.Sku))
{
     <p>
     <strong>@T("Admin.Orders.Products.SKU")</strong><text>:</text>
     @item.Sku
     </p>
}
Hace 5 años
Thank you, that's what I've already found it, what I am looking something before that.

When doing an order with a product variant that has no inventory tracking, it puts the product parent sku instead of the variant in the order details and if the product has inventory tracking, yes it puts the product variant sku, and that's what I need to find.

Regards
Hace 5 años
Ok, so you should check these codes in ProductService:

protected virtual void GetSkuMpnGtin(Product product, string attributesXml,
            out string sku, out string manufacturerPartNumber, out string gtin)
        {
            if (product == null)
                throw new ArgumentNullException(nameof(product));

            sku = null;
            manufacturerPartNumber = null;
            gtin = null;

            if (!string.IsNullOrEmpty(attributesXml) &&
                product.ManageInventoryMethod == ManageInventoryMethod.ManageStockByAttributes)
            {
                //manage stock by attribute combinations
                //let's find appropriate record
                var combination = _productAttributeParser.FindProductAttributeCombination(product, attributesXml);
                if (combination != null)
                {
                    sku = combination.Sku;
                    manufacturerPartNumber = combination.ManufacturerPartNumber;
                    gtin = combination.Gtin;
                }
            }

            if (string.IsNullOrEmpty(sku))
                sku = product.Sku;
            if (string.IsNullOrEmpty(manufacturerPartNumber))
                manufacturerPartNumber = product.ManufacturerPartNumber;
            if (string.IsNullOrEmpty(gtin))
                gtin = product.Gtin;
        }



Hope this helps you.

Regards
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.