Add yandex feed
This commit is contained in:
parent
4d1a5229e5
commit
4aac347867
42
Pages/Feed.xml.cshtml
Normal file
42
Pages/Feed.xml.cshtml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
@page "/feed.yml"
|
||||||
|
@using Microsoft.AspNetCore.Http
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@inject MyDarling.Models.DataContext context
|
||||||
|
@{
|
||||||
|
var p =
|
||||||
|
new { Url = "https://mydarlingunderwear.ru/", LastUpdated = DateTime.Today };
|
||||||
|
Response.ContentType = "text/xml";
|
||||||
|
var products = context.Products
|
||||||
|
.Include(b => b.Figures)
|
||||||
|
.Where(b => b.Price != 0 && b.Figures.Count > 0);
|
||||||
|
await Response.WriteAsync("<?xml version='1.0' encoding='UTF-8' ?>");
|
||||||
|
var updateDate = p.LastUpdated.ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
|
||||||
|
<yml_catalog date="@updateDate">
|
||||||
|
<shop>
|
||||||
|
<name>My Darling Underwear</name>
|
||||||
|
<company>Екатерина Мануйлова</company>
|
||||||
|
<url>@p.Url</url>
|
||||||
|
<currencies>
|
||||||
|
<currency id="RUB" rate="1"></currency>
|
||||||
|
</currencies>
|
||||||
|
<categories>
|
||||||
|
<category id="1">Нижнее бельё</category>
|
||||||
|
</categories>
|
||||||
|
<offers>
|
||||||
|
@foreach (var product in products)
|
||||||
|
{
|
||||||
|
var figureUrl = $"{@p.Url}Content/{@product.Id}/{@product.Figures[0].Id}.jpg";
|
||||||
|
<offer id="@product.Id" available="true">
|
||||||
|
<url>@p.Url#@product.Id-1</url>
|
||||||
|
<price>@product.Price</price>
|
||||||
|
<currencyId>RUR</currencyId>
|
||||||
|
<categoryId>1</categoryId>
|
||||||
|
<name>@product.Name</name>
|
||||||
|
<picture>@figureUrl</picture>
|
||||||
|
</offer>
|
||||||
|
}
|
||||||
|
</offers>
|
||||||
|
</shop>
|
||||||
|
</yml_catalog>
|
Loading…
Reference in New Issue
Block a user