manufacturer product

5 years ago
Hello
I have a product, how do I know the list of manufacturers?
Each product is associated with a single manufacturer. When I view a category, I want to print the manufacturer for each product.
Thanks so much
5 years ago
If you product object, just use following line to get manufactures of the product
product.ProductManufacturers 
5 years ago
svipla wrote:
Hello
I have a product, how do I know the list of manufacturers?
Each product is associated with a single manufacturer. When I view a category, I want to print the manufacturer for each product.
Thanks so much


Here you are :). A solution for "No_Source".

Following are steps to do it:
- Copy/paste "_ProductBox.cshtml" partial view to "Themes/DefaultClean/Views/Shared" folder.
- Add code to show product manufacturer(s)
- Restart application to take effect.
5 years ago
In the "Themes/DefaultClean/Views/Shared/_ProductBox.cshtml" partial view, add following blocks of code:

BLOCK 1:
---
BEFORE

@model ProductOverviewModel
@using Nop.Core
@using Nop.Core.Domain.Orders
@using Nop.Core.Domain.Tax
@using Nop.Core.Infrastructure
@using Nop.Web.Models.Catalog;

AFTER

@model ProductOverviewModel
@using Nop.Core
@using Nop.Core.Domain.Orders
@using Nop.Core.Domain.Tax
@using Nop.Core.Infrastructure
@using Nop.Services.Catalog
@using Nop.Web.Extensions
@using Nop.Web.Models.Catalog;
5 years ago
BLOCK 2:
---
Place following code

@helper RenderProductManufacturers()
{
    var productManufacturers = EngineContext.Current.Resolve<IManufacturerService>()
        .GetProductManufacturersByProductId(Model.Id)
        .Select(i => i.Manufacturer.ToModel())
        .ToList();
    if (!productManufacturers.Any())
    {
        return;
    }
    <div class="manufacturers">
        @if (productManufacturers.Count == 1)
        {
            <span class="label">@T("Products.Manufacturer"):</span>
        }
        else
        {
            <span class="label">@T("Products.Manufacturers"):</span>
        }
        <span class="value">
            @for (int i = 0; i < productManufacturers.Count; i++)
            {
                var item = productManufacturers[i];
                <a href="@Url.RouteUrl("Manufacturer", new { SeName = item.SeName })">@item.Name</a>
                if (i != productManufacturers.Count - 1)
                {
                    <span class="separator">,</span>
                }
            }
        </span>
    </div>
}

above this code

<div class="product-item" data-productid="@Model.Id">
5 years ago
BLOCK 3:
---
Place following code

<!--product manufacturers-->
        @RenderProductManufacturers()

below this code

<div class="description">
            @Html.Raw(Model.ShortDescription)
        </div>

Hope this help :)
7 months ago
some know how to set this in .net core in nop 4.2. Thanks