Skip to content

Commit

Permalink
Glami, Google: fixed ItemsGroup generating
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Apr 14, 2020
1 parent 9925cb1 commit 69c6679
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Feeds/Glami/GlamiFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public function generate(IOutput $output)
} else {
$this->generateItem($item, $output);
}

$output->output("</SHOPITEM>\n");
}

$output->output('</SHOP>');
Expand Down Expand Up @@ -124,5 +122,7 @@ private function generateItem($item, IOutput $output)
],
]);
}

$output->output("</SHOPITEM>\n");
}
}
4 changes: 2 additions & 2 deletions src/Feeds/GoogleMerchant/GoogleMerchantFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ public function generate(IOutput $output)
} else {
$this->generateItem($item, $output);
}

$output->output("</entry>\n");
}

$output->output('</feed>');
Expand Down Expand Up @@ -225,5 +223,7 @@ private function generateItem($item, IOutput $output)
// identifiers
'g:identifier_exists' => !$item->hasIdentifiers() ? 'no' : NULL,
]);

$output->output("</entry>\n");
}
}
35 changes: 35 additions & 0 deletions tests/FeedGenerator/Feeds/Glami/Glami.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ test(function () {
->addDelivery('PPL', 69)
->addDelivery('CPOST', 59, 99);

$itemsGroup->addItem($groupItem);
$itemsGroup->addItem($groupItem);
$items[] = $itemsGroup;
$items[] = NULL;
Expand Down Expand Up @@ -92,6 +93,40 @@ test(function () {
'</DELIVERY>',
'</SHOPITEM>',

'<SHOPITEM>',
'<ITEM_ID>001</ITEM_ID>',
'<EAN>6417182041488</EAN>',
'<PRODUCTNAME>Product ABC</PRODUCTNAME>',
'<DESCRIPTION>Lorem ipsum dolor sit amet</DESCRIPTION>',
'<CATEGORYTEXT>Glami.cz | Oblečení</CATEGORYTEXT>',
'<URL>http://www.example.com/product-abc/</URL>',
'<URL_SIZE>http://www.example.com/product-abc/?size=41</URL_SIZE>',
'<IMGURL>http://www.example.com/images/product-abc.jpg</IMGURL>',
'<IMGURL_ALTERNATIVE>http://www.example.com/images/product-abc-1.jpg</IMGURL_ALTERNATIVE>',
'<IMGURL_ALTERNATIVE>http://www.example.com/images/product-abc-2.jpg</IMGURL_ALTERNATIVE>',
'<PRICE_VAT>5.00</PRICE_VAT>',
'<DELIVERY_DATE>0</DELIVERY_DATE>',
'<ITEMGROUP_ID>AB12345</ITEMGROUP_ID>',
'<MANUFACTURER>Adidas</MANUFACTURER>',
'<PARAM>',
'<PARAM_NAME>barva</PARAM_NAME>',
'<VAL>modrá</VAL>',
'</PARAM>',
'<PARAM>',
'<PARAM_NAME>velikost</PARAM_NAME>',
'<VAL>XXL</VAL>',
'</PARAM>',
'<DELIVERY>',
'<DELIVERY_ID>PPL</DELIVERY_ID>',
'<DELIVERY_PRICE>69</DELIVERY_PRICE>',
'</DELIVERY>',
'<DELIVERY>',
'<DELIVERY_ID>CPOST</DELIVERY_ID>',
'<DELIVERY_PRICE>59</DELIVERY_PRICE>',
'<DELIVERY_PRICE_COD>99</DELIVERY_PRICE_COD>',
'</DELIVERY>',
'</SHOPITEM>',

'<SHOPITEM>',
'<ITEM_ID>002</ITEM_ID>',
'<PRODUCTNAME>Product DEF</PRODUCTNAME>',
Expand Down
19 changes: 19 additions & 0 deletions tests/FeedGenerator/Feeds/GoogleMerchant/GoogleMerchant.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ test(function () {
->setShipping(10, 'USD')
->setShippingLabel('Only FedEx');

$itemsGroup->addItem($groupItem);
$itemsGroup->addItem($groupItem);
$feed->setItems([$itemsGroup, NULL]);
$feed->generate($output);
Expand Down Expand Up @@ -66,6 +67,24 @@ test(function () {
'<g:shipping_label>Only FedEx</g:shipping_label>',
'<g:identifier_exists>no</g:identifier_exists>',
'</entry>',
'<entry>',
'<g:id>001</g:id>',
'<g:title>Product ABC</g:title>',
'<g:description>Lorem ipsum dolor sit amet</g:description>',
'<g:link>http://www.example.com/product-abc/</g:link>',
'<g:image_link>http://www.example.com/images/product-abc.jpg</g:image_link>',
'<g:availability>in stock</g:availability>',
'<g:price>5.00 USD</g:price>',
'<g:condition>new</g:condition>',
'<g:adult>no</g:adult>',
'<g:color>red</g:color>',
'<g:gender>male</g:gender>',
'<g:size>XXL</g:size>',
'<g:item_group_id>AB12345</g:item_group_id>',
'<g:shipping>10.00 USD</g:shipping>',
'<g:shipping_label>Only FedEx</g:shipping_label>',
'<g:identifier_exists>no</g:identifier_exists>',
'</entry>',
'</feed>',
'',
]), $output->getOutput());
Expand Down
26 changes: 26 additions & 0 deletions tests/FeedGenerator/Feeds/Heureka/Heureka.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test(function () {
->addParameter('size', 'XXL')
->addParameter('weight', 10, 'kg');

$itemsGroup->addItem($groupItem);
$itemsGroup->addItem($groupItem);
$items[] = $itemsGroup;
$items[] = NULL;
Expand Down Expand Up @@ -77,6 +78,31 @@ test(function () {
'</PARAM>',
'</SHOPITEM>',

'<SHOPITEM>',
'<ITEM_ID>001</ITEM_ID>',
'<EAN>6417182041488</EAN>',
'<PRODUCTNAME>Product ABC</PRODUCTNAME>',
'<DESCRIPTION>Lorem ipsum dolor sit amet</DESCRIPTION>',
'<CATEGORYTEXT>Electronics | TVs</CATEGORYTEXT>',
'<URL>http://www.example.com/product-abc/</URL>',
'<IMGURL>http://www.example.com/images/product-abc.jpg</IMGURL>',
'<PRICE_VAT>5.00</PRICE_VAT>',
'<DELIVERY_DATE>0</DELIVERY_DATE>',
'<ITEMGROUP_ID>AB12345</ITEMGROUP_ID>',
'<PARAM>',
'<PARAM_NAME>color</PARAM_NAME>',
'<VAL>red</VAL>',
'</PARAM>',
'<PARAM>',
'<PARAM_NAME>size</PARAM_NAME>',
'<VAL>XXL</VAL>',
'</PARAM>',
'<PARAM>',
'<PARAM_NAME>weight</PARAM_NAME>',
'<VAL>10kg</VAL>',
'</PARAM>',
'</SHOPITEM>',

'<SHOPITEM>',
'<ITEM_ID>002</ITEM_ID>',
'<PRODUCTNAME>Product DEF</PRODUCTNAME>',
Expand Down
6 changes: 6 additions & 0 deletions tests/FeedGenerator/Feeds/PostFeed/PostFeed.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test(function () {

$groupItem = new PostFeedItem(1, 'Title', new DateTime('2016-02-06 18:00:00+0200', new DateTimeZone('UTC')));

$itemsGroup->addItem($groupItem);
$itemsGroup->addItem($groupItem);
$items[] = $itemsGroup;
$items[] = NULL;
Expand All @@ -52,6 +53,11 @@ test(function () {
'title' => 'Title',
'date' => '2016-02-06 16:00:00',
]) . ',',
Json::encode([
'id' => 1,
'title' => 'Title',
'date' => '2016-02-06 16:00:00',
]) . ',',
Json::encode([
'id' => 'item2',
'title' => 'Title 2',
Expand Down
25 changes: 25 additions & 0 deletions tests/FeedGenerator/Feeds/Zbozi/Zbozi.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test(function () {
->addParameter('size', 'XXL')
->addParameter('weight', 10, 'kg');

$itemsGroup->addItem($groupItem);
$itemsGroup->addItem($groupItem);
$items[] = $itemsGroup;
$items[] = NULL;
Expand Down Expand Up @@ -74,6 +75,30 @@ test(function () {
'</PARAM>',
'</SHOPITEM>',

'<SHOPITEM>',
'<ITEM_ID>001</ITEM_ID>',
'<PRODUCTNAME>Product ABC</PRODUCTNAME>',
'<DESCRIPTION>Lorem ipsum dolor sit amet</DESCRIPTION>',
'<URL>http://www.example.com/product-abc/</URL>',
'<IMGURL>http://www.example.com/images/product-abc.jpg</IMGURL>',
'<PRICE_VAT>5.00</PRICE_VAT>',
'<DELIVERY_DATE>0</DELIVERY_DATE>',
'<ITEMGROUP_ID>AB12345</ITEMGROUP_ID>',
'<PARAM>',
'<PARAM_NAME>color</PARAM_NAME>',
'<VAL>red</VAL>',
'</PARAM>',
'<PARAM>',
'<PARAM_NAME>size</PARAM_NAME>',
'<VAL>XXL</VAL>',
'</PARAM>',
'<PARAM>',
'<PARAM_NAME>weight</PARAM_NAME>',
'<VAL>10</VAL>',
'<UNIT>kg</UNIT>',
'</PARAM>',
'</SHOPITEM>',

'<SHOPITEM>',
'<ITEM_ID>002</ITEM_ID>',
'<PRODUCTNAME>Product DEF</PRODUCTNAME>',
Expand Down

0 comments on commit 69c6679

Please sign in to comment.