Micro Data Out Of Stock Problem ( I have solution code)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi dear developers,

I use nopcommerce 4.30 beta released. And i have out of stock problem with your sample data. There is this problem since version 4.20.(I was fix that issue in my custom nopcommerce 4.20)

I was edited stock qty but its still seem out of stock in microdata, and this makes you appear to be out of google stock, very bad situation for seo.

Problem is conditions doesn't work well(string comparison)

I will fixed with stock quantity conditions like 3. photo. Please fix it with your solution its important.




@a.m
[quote=a.m.]
[mention=a.m.]
code:
@model ProductDetailsModel
@using System.Globalization
@using Nop.Core.Domain.Catalog
@inject Nop.Core.IWebHelper webHelper

<!--Microdata-->
<div @if (ViewData.ContainsKey("isAccessoryOrSparePartFor")) { <text>itemprop="isAccessoryOrSparePartFor"</text> } itemscope itemtype="http://schema.org/Product">
    <meta itemprop="name" content="@Model.Name"/>
    <meta itemprop="sku" content="@Model.Sku"/>
    <meta itemprop="gtin" content="@Model.Gtin"/>
    <meta itemprop="mpn" content="@Model.ManufacturerPartNumber"/>
    <meta itemprop="description" content="@Model.ShortDescription"/>
    <meta itemprop="image" content="@Model.DefaultPictureModel.ImageUrl"/>
    @foreach (var manufacturer in Model.ProductManufacturers)
    {
        <meta itemprop="brand" content="@manufacturer.Name"/>
    }
    @if (@Model.ProductReviewOverview.TotalReviews > 0)
    {
        <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
            @{
                var ratingPercent = 0;
                if (Model.ProductReviewOverview.TotalReviews != 0)
                {
                    ratingPercent = ((Model.ProductReviewOverview.RatingSum * 100) / Model.ProductReviewOverview.TotalReviews) / 5;
                }
                var ratingValue = ratingPercent / (decimal)20;
            }
            <meta itemprop="ratingValue" content="@ratingValue.ToString("0.0", new CultureInfo("en-US"))"/>
            <meta itemprop="reviewCount" content="@Model.ProductReviewOverview.TotalReviews"/>
        </div>
    }    
    <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <meta itemprop="url" content="@Url.RouteUrl("Product", new { SeName = Model.SeName }, webHelper.CurrentRequestProtocol).ToLowerInvariant()"/>
        <meta itemprop="price" content="@Model.ProductPrice.PriceValue.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)"/>
        <meta itemprop="priceCurrency" content="@Model.ProductPrice.CurrencyCode"/>
        <meta itemprop="priceValidUntil" content="@Model.AvailableEndDate"/>
        @if (Model.ManageInventoryMethod == ManageInventoryMethod.ManageStock || Model.ManageInventoryMethod == ManageInventoryMethod.ManageStockByAttributes)
        {
            @if (Model.StockAvailability.Any(char.IsDigit)|| Model.StockAvailability == @T("Products.Availability.InStockWithQuantity").ToString())
            {
                <meta itemprop="availability" content="http://schema.org/InStock"/>
            }
            else
            {                              
                <meta itemprop="availability" content="http://schema.org/OutOfStock"/>
            }
        }        
    </div>
    <div itemprop="review" itemscope itemtype="http://schema.org/Review">
        <meta itemprop="author" content="ALL"/>
        <meta itemprop="url" content="@Url.RouteUrl("ProductReviews", new { productId = Model.ProductReviewOverview.ProductId })"/>
    </div>
    @foreach (var product in Model.AssociatedProducts)
    {
        var dataAccociatedType = new ViewDataDictionary(ViewData);
        dataAccociatedType.Add("isAccessoryOrSparePartFor", "true");
        @await Html.PartialAsync("_Microdata", product, dataAccociatedType)        
    }
</div>
3 years ago
We will check it. I created a work item. Thank!
3 years ago
Done. Please see this commit.
3 years ago
This is why I love nopCommerce and its team. Super responsive and fast to improve the things. Kudos to the team. +1
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.