Skip to content

Commit 6f2e976

Browse files
Added yandex receipt generation
1 parent 8a785ee commit 6f2e976

File tree

11 files changed

+249
-196
lines changed

11 files changed

+249
-196
lines changed

docs/snippets/receipt-sitemap-feed.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
33

44
<url>
5-
<loc>https://example.com/products/porro-odit-molestiae-illo-nemo-et</loc>
5+
<loc>https://example.com/products/dolorem-sit-dolore-a-quibusdam-rerum</loc>
66
<lastmod>2025-09-04T04:08:12+00:00</lastmod>
77
<priority>0.9</priority>
88
</url>
99
<url>
10-
<loc>https://example.com/products/magni-similique-voluptas-qui-doloribus</loc>
10+
<loc>https://example.com/products/magni-quo-adipisci-quaerat-rerum-eum-a-nesciunt</loc>
1111
<lastmod>2025-09-04T04:08:12+00:00</lastmod>
1212
<priority>0.9</priority>
1313
</url>

docs/snippets/receipt-yandex-feed-info.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ public function toArray(): array
3939
'@attributes' => ['id' => 539],
4040
'@value' => 'Велосипедки',
4141
],
42-
[
43-
'@attributes' => ['id' => 44],
44-
'@value' => 'Ремни',
45-
],
4642
],
4743
],
4844
];

docs/snippets/receipt-yandex-feed-item.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
use DragonCode\LaravelFeed\Feeds\Items\FeedItem;
88

9-
use function route;
10-
119
/** @property-read \App\Models\Product $model */
1210
class YandexFeedItem extends FeedItem
1311
{

docs/snippets/receipt-yandex-feed.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
namespace App\Feeds;
66

7-
use App\Models\Product;
87
use DragonCode\LaravelFeed\Data\ElementData;
98
use DragonCode\LaravelFeed\Feeds\Feed;
109
use DragonCode\LaravelFeed\Feeds\Info\FeedInfo;
1110
use DragonCode\LaravelFeed\Feeds\Items\FeedItem;
1211
use Illuminate\Database\Eloquent\Builder;
1312
use Illuminate\Database\Eloquent\Model;
13+
use App\Feeds\Info\YandexFeedInfo;
14+
use App\Feeds\Items\YandexFeedItem;
15+
use App\Models\Product;
1416

1517
class YandexFeed extends Feed
1618
{
@@ -42,16 +44,16 @@ public function footer(): string
4244

4345
public function info(): FeedInfo
4446
{
45-
return new Info\YandexFeedInfo;
47+
return new YandexFeedInfo;
4648
}
4749

48-
public function filename(): string
50+
public function item(Model $model): FeedItem
4951
{
50-
return 'yandex.xml';
52+
return new YandexFeedItem($model);
5153
}
5254

53-
public function item(Model $model): FeedItem
55+
public function filename(): string
5456
{
55-
return new Items\YandexFeedItem($model);
57+
return 'yandex.xml';
5658
}
5759
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!DOCTYPE yml_catalog SYSTEM "shops.dtd">
2+
<yml_catalog date="2025-09-04T04:08:12+00:00">
3+
<shop>
4+
<offers>
5+
6+
<name>Laravel</name>
7+
<company>Laravel</company>
8+
<platform>Laravel</platform>
9+
<url>https://example.com</url>
10+
<email>test@example.com</email>
11+
<currencies>
12+
<currency id="RUR" rate="1"/>
13+
</currencies>
14+
<categories>
15+
<category id="41">Домашние майки</category>
16+
<category id="539">Велосипедки</category>
17+
</categories>
18+
19+
<offer id="1" available="true" type="vendor.model">
20+
<url>https://example.com/products/soluta-cumque-omnis-quam-et</url>
21+
<barcode>GD-Y@GH</barcode>
22+
<name>doloremque voluptas delectus est</name>
23+
<description>Quaerat nobis vel ab odio facilis cumque. Et nemo aspernatur sint amet dolor facilis. Doloremque ut possimus unde id corrupti ut. Quam alias quo molestias rem incidunt.</description>
24+
<delivery>true</delivery>
25+
<price>746</price>
26+
<currencyId>RUR</currencyId>
27+
<vendor>vel</vendor>
28+
<picture>https://via.placeholder.com/640x480.png/00cc77?text=non</picture>
29+
<picture>https://via.placeholder.com/640x480.png/0066aa?text=autem</picture>
30+
<picture>https://via.placeholder.com/640x480.png/001177?text=cum</picture>
31+
<param name="Артикул">GD-Y@GH</param>
32+
<param name="Код цвета">7</param>
33+
<param name="Пол">male</param>
34+
</offer>
35+
<offer id="2" available="true" type="vendor.model">
36+
<url>https://example.com/products/aut-eos-alias-voluptate-inventore-fugit-iste-ut</url>
37+
<barcode>GD-UC:1J</barcode>
38+
<name>ut repellendus eveniet et</name>
39+
<description>Repellat voluptatum et optio consequatur. Repellendus qui consequatur voluptas praesentium. A velit explicabo praesentium atque. Explicabo rerum ut sequi consequatur perspiciatis cumque.</description>
40+
<delivery>true</delivery>
41+
<price>455</price>
42+
<currencyId>RUR</currencyId>
43+
<vendor>occaecati</vendor>
44+
<picture>https://via.placeholder.com/640x480.png/0044cc?text=est</picture>
45+
<picture>https://via.placeholder.com/640x480.png/002299?text=libero</picture>
46+
<picture>https://via.placeholder.com/640x480.png/005533?text=cupiditate</picture>
47+
<param name="Артикул">GD-UC:1J</param>
48+
<param name="Код цвета">9</param>
49+
<param name="Пол">female</param>
50+
</offer>
51+
52+
</offers>
53+
</shop>
54+
</yml_catalog>

docs/snippets/receipt-yandex-result.xml

Lines changed: 0 additions & 181 deletions
This file was deleted.

docs/topics/receipt-yandex.topic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@
3939
</chapter>
4040

4141
<chapter title="Result" id="result">
42-
<code-block lang="xml" src="receipt-yandex-result.xml" />
42+
<code-block lang="xml" src="receipt-yandex-feed.xml" />
4343
</chapter>
4444
</topic>

tests/Feature/Docs/ReceiptTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use DragonCode\LaravelFeed\Commands\FeedGenerateCommand;
66
use DragonCode\LaravelFeed\Models\Feed;
77
use Workbench\App\Feeds\Docs\ReceiptSitemapFeed;
8+
use Workbench\App\Feeds\Docs\ReceiptYandexFeed;
89
use Workbench\App\Models\Product;
910

1011
use function Pest\Laravel\artisan;
@@ -40,4 +41,21 @@
4041
'../../../../../../../../../docs/snippets/receipt-sitemap-feed.xml' => 'sitemaps/products.xml',
4142
],
4243
],
44+
45+
'yandex' => [
46+
'feed' => ReceiptYandexFeed::class,
47+
48+
'files' => [
49+
'ReceiptYandexFeed' => 'receipt-yandex-feed.php',
50+
'Info/ReceiptYandexFeedInfo' => 'receipt-yandex-feed-info.php',
51+
'Items/ReceiptYandexFeedItem' => 'receipt-yandex-feed-item.php',
52+
],
53+
54+
'replaces' => [
55+
'ReceiptYandexFeed' => 'YandexFeed',
56+
'Workbench\App\Feeds\Docs' => 'App\Feeds',
57+
58+
'../../../../../../../../../docs/snippets/receipt-yandex-feed.xml' => 'yandex.xml',
59+
],
60+
],
4361
]);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Workbench\App\Feeds\Docs\Info;
6+
7+
use DragonCode\LaravelFeed\Feeds\Info\FeedInfo;
8+
9+
class ReceiptYandexFeedInfo extends FeedInfo
10+
{
11+
public function toArray(): array
12+
{
13+
return [
14+
'name' => config('app.name'),
15+
'company' => config('app.name'),
16+
'platform' => config('app.name'),
17+
18+
'url' => config('app.url'),
19+
'email' => config('emails.manager'),
20+
21+
'currencies' => [
22+
'@currency' => [
23+
[
24+
'@attributes' => [
25+
'id' => 'RUR',
26+
'rate' => '1',
27+
],
28+
],
29+
],
30+
],
31+
32+
'categories' => [
33+
'@category' => [
34+
[
35+
'@attributes' => ['id' => 41],
36+
'@value' => 'Домашние майки',
37+
],
38+
[
39+
'@attributes' => ['id' => 539],
40+
'@value' => 'Велосипедки',
41+
],
42+
],
43+
],
44+
];
45+
}
46+
}

0 commit comments

Comments
 (0)