From 65b40c6cb09ddf9456e4a9985790b3ee76f1b8eb Mon Sep 17 00:00:00 2001 From: paveltizek Date: Sun, 25 Jun 2017 12:16:58 +0200 Subject: [PATCH 01/52] Update composer.json --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 915fc43..47a65de 100644 --- a/composer.json +++ b/composer.json @@ -16,10 +16,10 @@ ], "require": { "php": ">=5.4", - "nette/di": "~2.3.0", - "nette/utils": "~2.3.0", - "latte/latte": "~2.3.0", - "kdyby/console": "~2.6.0", + "nette/di": ">=2.3.0", + "nette/utils": ">=2.3.0", + "latte/latte": ">=2.3.0", + "kdyby/console": ">=2.6.0", "sergiors/importing": "1.0.1" }, "require-dev": { From 93e7966cd587118d4db75bedade522dce096dd0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Kor=C4=8D=C3=A1k?= Date: Tue, 6 Feb 2018 11:20:53 +0100 Subject: [PATCH 02/52] Feed (heureka,zbozi) with php 7.2+ --- composer.json | 2 +- src/Generators/BaseGenerator.php | 7 ++- src/Generators/BaseItem.php | 8 ++- src/Generators/Google/Image.php | 5 +- src/Generators/Google/ProductType.php | 6 ++- src/Generators/Heureka/Delivery.php | 5 +- src/Generators/Heureka/Gift.php | 5 +- src/Generators/Heureka/Image.php | 5 +- src/Generators/Heureka/Parameter.php | 5 +- src/Generators/Heureka/latte/item.latte | 46 ++++++++-------- src/Generators/Zbozi/CategoryText.php | 6 ++- src/Generators/Zbozi/ExtraMessage.php | 5 +- src/Generators/Zbozi/Image.php | 6 ++- src/Generators/Zbozi/Parameter.php | 5 +- src/Generators/Zbozi/ShopDepot.php | 5 +- src/Generators/Zbozi/latte/item.latte | 70 ++++++++++++------------- 16 files changed, 115 insertions(+), 76 deletions(-) diff --git a/composer.json b/composer.json index dc361e7..7ab9e73 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "nette/di": "~2.4.0", "nette/utils": "~2.4.0", "latte/latte": "~2.4.0", - "kdyby/console": "~2.6.0", + "kdyby/console": "^2.6.0", "sergiors/importing": "1.0.1" }, "require-dev": { diff --git a/src/Generators/BaseGenerator.php b/src/Generators/BaseGenerator.php index f966b34..02d8aaa 100644 --- a/src/Generators/BaseGenerator.php +++ b/src/Generators/BaseGenerator.php @@ -1,9 +1,9 @@ * @package Mk\Feed\Generators */ -abstract class BaseGenerator extends Object implements IGenerator { +abstract class BaseGenerator implements IGenerator { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; /** @var bool true if some products added */ private $prepared = false; diff --git a/src/Generators/BaseItem.php b/src/Generators/BaseItem.php index 55243f8..6aefe84 100644 --- a/src/Generators/BaseItem.php +++ b/src/Generators/BaseItem.php @@ -10,15 +10,18 @@ * @author Martin Knor * @package Mk\Feed\Generators\Zbozi */ -abstract class BaseItem extends Nette\Object implements Mk\Feed\Generators\IItem +abstract class BaseItem implements Mk\Feed\Generators\IItem { + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; /** * Validate item * @return bool return true if item is valid */ public function validate() { - $reflection = $this->getReflection(); + + $reflection = new Nette\Reflection\ClassType(get_called_class()); foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $v) { if ($v->getAnnotation('required')) { @@ -30,4 +33,5 @@ public function validate() { return TRUE; } + } diff --git a/src/Generators/Google/Image.php b/src/Generators/Google/Image.php index 5e45ed8..7ac706b 100644 --- a/src/Generators/Google/Image.php +++ b/src/Generators/Google/Image.php @@ -10,8 +10,11 @@ * @author Martin Knor * @package Mk\Feed\Generators\Google */ -class Image extends Nette\Object +class Image { + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + /** @var string */ private $url; diff --git a/src/Generators/Google/ProductType.php b/src/Generators/Google/ProductType.php index bec21e2..498130d 100644 --- a/src/Generators/Google/ProductType.php +++ b/src/Generators/Google/ProductType.php @@ -10,8 +10,10 @@ * @author Martin Knor * @package Mk\Feed\Generators\Google */ -class ProductType extends Nette\Object { - +class ProductType { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; /** @var string */ protected $text; diff --git a/src/Generators/Heureka/Delivery.php b/src/Generators/Heureka/Delivery.php index acf876d..1cf0ae0 100644 --- a/src/Generators/Heureka/Delivery.php +++ b/src/Generators/Heureka/Delivery.php @@ -9,7 +9,10 @@ * @author Martin Knor * @package Mk\Feed\Generators\Heureka */ -class Delivery extends Nette\Object { +class Delivery{ + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; CONST CESKA_POSTA = 'CESKA_POSTA', CESKA_POSTA_NA_POSTU = 'CESKA_POSTA_NA_POSTU', diff --git a/src/Generators/Heureka/Gift.php b/src/Generators/Heureka/Gift.php index ac0f65c..14a4852 100644 --- a/src/Generators/Heureka/Gift.php +++ b/src/Generators/Heureka/Gift.php @@ -9,7 +9,10 @@ * @author Martin Knor * @package Mk\Feed\Generators\Heureka */ -class Gift extends Nette\Object { +class Gift { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; /** @var string */ protected $name; diff --git a/src/Generators/Heureka/Image.php b/src/Generators/Heureka/Image.php index 319b3b3..64416fa 100644 --- a/src/Generators/Heureka/Image.php +++ b/src/Generators/Heureka/Image.php @@ -10,8 +10,11 @@ * @author Martin Knor * @package Mk\Feed\Generators\Heureka */ -class Image extends Nette\Object +class Image { + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + /** @var string */ private $url; diff --git a/src/Generators/Heureka/Parameter.php b/src/Generators/Heureka/Parameter.php index 6c66bd6..6cc03e9 100644 --- a/src/Generators/Heureka/Parameter.php +++ b/src/Generators/Heureka/Parameter.php @@ -9,7 +9,10 @@ * @author Martin Knor * @package Mk\Feed\Generators\Heureka */ -class Parameter extends Nette\Object { +class Parameter { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; protected $name; protected $value; diff --git a/src/Generators/Heureka/latte/item.latte b/src/Generators/Heureka/latte/item.latte index fd38ad3..7e73432 100644 --- a/src/Generators/Heureka/latte/item.latte +++ b/src/Generators/Heureka/latte/item.latte @@ -1,36 +1,36 @@ {contentType xml} - {$item->itemId} - productName}]]> - product}]]> - description}]]> - {$item->url} + {$item->getItemId()} + getProductName()}]]> + getProduct()}]]> + getDescription()}]]> + {$item->getUrl()} - {if !empty($images = $item->images)} + {if !empty($images = $item->getImages())} {foreach $images as $image} {var tag = $iterator->first ? 'IMGURL' : 'IMGURL_ALTERNATIVE'} - <{$tag}>{$image->url} + <{$tag}>{$image->getUrl()} {/foreach} {/if} - {$item->videoUrl} - {$item->priceVat} + {$item->getVideoUrl()} + {$item->getPriceVat()} - {if !empty($parameters = $item->parameters)} + {if !empty($parameters = $item->getParameters())} - {$parameter->name} - {$parameter->value} + {$parameter->getName()} + {$parameter->getValue()} {/if} - manufacturer}]]> - categoryText}]]> - {$item->ean} - {$item->isbn} - {$item->heurekaCpc} - {$item->deliveryDate} + getManufacturer()}]]> + getCategoryText()}]]> + {$item->getEan()} + {$item->getIsbn()} + {$item->getHeurekaCpc()} + {$item->getDeliveryDate()} - {if !empty($deliveries = $item->deliveries)} + {if !empty($deliveries = $item->getDeliveries())} {$delivery->id} {$delivery->price} @@ -38,14 +38,14 @@ {/if} - {$item->itemGroupId} + {$item->getItemGroupId()} - {if !empty($accessories = $item->accessories)} + {if !empty($accessories = $item->getAccessories())} {$itemId} {/if} - {$item->dues} - {if !empty($gifts = $item->gifts)} + {$item->getDues()} + {if !empty($gifts = $item->getGifts())} {$gift->name} {/if} diff --git a/src/Generators/Zbozi/CategoryText.php b/src/Generators/Zbozi/CategoryText.php index 8327264..87d7f5d 100644 --- a/src/Generators/Zbozi/CategoryText.php +++ b/src/Generators/Zbozi/CategoryText.php @@ -10,8 +10,10 @@ * @author Martin Knor * @package Mk\Feed\Generators\Zbozi */ -class CategoryText extends Nette\Object { - +class CategoryText { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; /** @var string */ protected $text; diff --git a/src/Generators/Zbozi/ExtraMessage.php b/src/Generators/Zbozi/ExtraMessage.php index 3ebca87..9a8c5c3 100644 --- a/src/Generators/Zbozi/ExtraMessage.php +++ b/src/Generators/Zbozi/ExtraMessage.php @@ -10,7 +10,10 @@ * @author Martin Knor * @package Mk\Feed\Generators\Zbozi */ -class ExtraMessage extends Nette\Object { +class ExtraMessage { + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + CONST EXTENDED_WARRANTY = 'extended_warranty', FREE_ACCESSORIES = 'free_accessories', FREE_CASE = 'free_case', diff --git a/src/Generators/Zbozi/Image.php b/src/Generators/Zbozi/Image.php index 87fa744..ae03995 100644 --- a/src/Generators/Zbozi/Image.php +++ b/src/Generators/Zbozi/Image.php @@ -4,7 +4,11 @@ use Mk, Nette; -class Image extends Nette\Object { +class Image { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + private $url; /** diff --git a/src/Generators/Zbozi/Parameter.php b/src/Generators/Zbozi/Parameter.php index a037bba..570d671 100644 --- a/src/Generators/Zbozi/Parameter.php +++ b/src/Generators/Zbozi/Parameter.php @@ -10,7 +10,10 @@ * @package Mk\Feed\Generators\Zbozi * @see http://napoveda.seznam.cz/cz/zbozi/specifikace-xml-pro-obchody/specifikace-xml-feedu/#PARAM */ -class Parameter extends Nette\Object { +class Parameter { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; protected $name; protected $value; diff --git a/src/Generators/Zbozi/ShopDepot.php b/src/Generators/Zbozi/ShopDepot.php index 67e43c2..0e7d177 100644 --- a/src/Generators/Zbozi/ShopDepot.php +++ b/src/Generators/Zbozi/ShopDepot.php @@ -4,7 +4,10 @@ use Mk, Nette; -class ShopDepot extends Nette\Object { +class ShopDepot { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; private $id; diff --git a/src/Generators/Zbozi/latte/item.latte b/src/Generators/Zbozi/latte/item.latte index 40e631b..bf920f5 100644 --- a/src/Generators/Zbozi/latte/item.latte +++ b/src/Generators/Zbozi/latte/item.latte @@ -1,54 +1,54 @@ {contentType xml} - {$item->productName} - {$item->description} - {$item->url} - {$item->priceVat} - {$item->deliveryDate} - {$item->itemId} - - {if !empty($images = $item->images)} - {$image->url} + {$item->getProductName()} + {$item->getDescription()} + {$item->getUrl()} + {$item->getPriceVat()} + {$item->getDeliveryDate()} + {$item->getItemId()} + + {if !empty($images = $item->getImages())} + {$image->getUrl()} {/if} - {$item->ean} - {$item->isbn} - {$item->productNo} - {$item->itemGroupId} - {$item->manufacturer} - {$item->brand} - {$item->categoryId} + {$item->getEan()} + {$item->getIsbn()} + {$item->getProductNo()} + {$item->getItemGroupId()} + {$item->getManufacturer()} + {$item->getBrand()} + {$item->getCategoryId()} - {if !empty($categoryTexts = $item->categoryTexts)} - {$categoryText->text} + {if !empty($categoryTexts = $item->getCategoryTexts())} + {$categoryText->getText()} {/if} - {$item->product} + {$item->getProduct()} {*{$item->type}*} - {if !empty($extraMessages = $item->extraMessages)} - {$extraMessage->type} + {if !empty($extraMessages = $item->getExtraMessages())} + {$extraMessage->getType()} {/if} - {if !empty($shopDepots = $item->shopDepots)} - {$shopDepot->id} + {if !empty($shopDepots = $item->getShopDepots())} + {$shopDepot->getId()} {/if} - {$item->visibility ? 1 : 0} - {$item->customLabel} - {$item->customLabel1} - {$item->maxCpc} - {$item->maxCpcSearch} + {$item->isVisibility() ? 1 : 0} + {$item->getCustomLabel()} + {$item->getCustomLabel()} + {$item->getMaxCpc()} + {$item->getMaxCpcSearch()} - {if !empty($parameters = $item->parameters)} + {if !empty($parameters = $item->getParameters())} - {$parameter->name} - {$parameter->value} - {$parameter->unit} + {$parameter->getName()} + {$parameter->getValue()} + {$parameter->getUnit()} {/if} - {$item->productLine} - {$item->listPrice} - {$item->releaseDate|date:'c'} + {$item->getProductLine()} + {$item->getListPrice()} + {$item->getReleaseDate()|date:'c'} From d348ae94ee8a87ef79d258ee39d7f4591dd6a9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 22 Feb 2018 10:42:20 +0100 Subject: [PATCH 03/52] Added zasilkovna & ulozenka --- src/Generators/Heureka/Delivery.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Generators/Heureka/Delivery.php b/src/Generators/Heureka/Delivery.php index 1cf0ae0..8bc3dbe 100644 --- a/src/Generators/Heureka/Delivery.php +++ b/src/Generators/Heureka/Delivery.php @@ -35,7 +35,9 @@ class Delivery{ TNT = 'TNT', TOPTRANS = 'TOPTRANS', UPS = 'UPS', - VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA'; + ULOZENKA = 'ULOZENKA', + VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA', + ZASILKOVNA = 'ZASILKOVNA'; static $ids = array( self::CESKA_POSTA, @@ -59,7 +61,9 @@ class Delivery{ self::TNT, self::TOPTRANS, self::UPS, + self::ULOZENKA, self::VLASTNI_PREPRAVA, + self::ZASILKOVNA, ); /** @var string */ From 2926c41d3739bb48dc519d407e6af4e69b3d99e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Mon, 5 Mar 2018 09:30:13 +0100 Subject: [PATCH 04/52] Updated google feed --- src/Generators/Google/Item.php | 38 ++++++++++++++++++++++++ src/Generators/Google/latte/footer.latte | 3 +- src/Generators/Google/latte/header.latte | 3 +- src/Generators/Google/latte/item.latte | 9 ++++-- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/Generators/Google/Item.php b/src/Generators/Google/Item.php index 8adbc43..dd96c53 100644 --- a/src/Generators/Google/Item.php +++ b/src/Generators/Google/Item.php @@ -88,6 +88,12 @@ class Item extends BaseItem { protected $labels = []; + /** @var string */ + protected $itemGroupId; + + /** @var array */ + protected $params; + /** * @return string */ @@ -450,4 +456,36 @@ public function setLabels(array $labels) $this->labels = $labels; } + /** + * @return string + */ + public function getItemGroupId(): string { + return $this->itemGroupId; + } + + /** + * @param string $itemGroupId + */ + public function setItemGroupId(string $itemGroupId): void { + $this->itemGroupId = $itemGroupId; + } + + public function addParam($name, $value){ + $this->params[$name] = $value; + } + + /** + * @return array + */ + public function getParams(): array { + return $this->params; + } + + + + + + + + } diff --git a/src/Generators/Google/latte/footer.latte b/src/Generators/Google/latte/footer.latte index 9ab9fd0..f651c3b 100644 --- a/src/Generators/Google/latte/footer.latte +++ b/src/Generators/Google/latte/footer.latte @@ -1 +1,2 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/src/Generators/Google/latte/header.latte b/src/Generators/Google/latte/header.latte index 018914b..caa59a2 100644 --- a/src/Generators/Google/latte/header.latte +++ b/src/Generators/Google/latte/header.latte @@ -1,2 +1,3 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index c9e15b6..504577f 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -1,5 +1,5 @@ {contentType xml} - + {$item->id} {$item->title} {$item->description} @@ -34,4 +34,9 @@ {/if} {$item->googleProductCategory} - \ No newline at end of file + + + {$item->itemGroupId} + {dump $item->params} + {*{$value}*} + \ No newline at end of file From d6cf6dc209783c18a16261fd151956e8d581eea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Mon, 5 Mar 2018 09:34:49 +0100 Subject: [PATCH 05/52] Updated composer & return type --- composer.json | 2 +- src/Generators/Google/Item.php | 2 +- src/Generators/Google/latte/item.latte | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index ec0ee85..be72f51 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": ">=5.6", "nette/di": "~2.4.0", - "nette/utils": "~2.4.0", + "nette/utils": "~2.4.0 || ~2.5.0", "latte/latte": "~2.4.0", "kdyby/console": "^2.6.0", "sergiors/importing": "1.0.1" diff --git a/src/Generators/Google/Item.php b/src/Generators/Google/Item.php index dd96c53..5098474 100644 --- a/src/Generators/Google/Item.php +++ b/src/Generators/Google/Item.php @@ -459,7 +459,7 @@ public function setLabels(array $labels) /** * @return string */ - public function getItemGroupId(): string { + public function getItemGroupId(): ?string { return $this->itemGroupId; } diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index 504577f..5baa65a 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -37,6 +37,5 @@ {$item->itemGroupId} - {dump $item->params} {*{$value}*} \ No newline at end of file From f8c1555ddb5783b3f5f540bd4ad613a81a749ca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Mon, 5 Mar 2018 09:52:35 +0100 Subject: [PATCH 06/52] Renamed entity to item --- src/Generators/Google/Item.php | 1 + src/Generators/Google/latte/item.latte | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Generators/Google/Item.php b/src/Generators/Google/Item.php index 5098474..ae25608 100644 --- a/src/Generators/Google/Item.php +++ b/src/Generators/Google/Item.php @@ -7,6 +7,7 @@ /** * Class Item + * @property string $id * @author Martin Knor * @package Mk\Feed\Generators\Google */ diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index 5baa65a..f6b6bff 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -1,5 +1,5 @@ {contentType xml} - + {$item->id} {$item->title} {$item->description} @@ -38,4 +38,4 @@ {$item->itemGroupId} {*{$value}*} - \ No newline at end of file + \ No newline at end of file From aaccf21639d7fb0e8e39ce8efd1d8ed62e32ab48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Mon, 5 Mar 2018 10:05:23 +0100 Subject: [PATCH 07/52] Added CDATA --- src/Generators/Google/latte/item.latte | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index f6b6bff..d70818a 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -1,20 +1,20 @@ {contentType xml} {$item->id} - {$item->title} - {$item->description} - {$item->link} + title}]]> + description}]]> + link}]]> {if !empty($images = $item->images)} {foreach $images as $image} {var tag = $iterator->first ? 'g:image_link' : 'g:additional_image_link'} - <{$tag}>{$image->url} + <{$tag}>url}]]> {/foreach} {/if} {$item->condition} {$item->availability} - {$item->price} + {$item->price} CZK {$item->salePrice} {$item->gtin} {$item->brand} From 7039cff3ba77bb0c3ca22508691468c5821aaffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 6 Mar 2018 14:38:21 +0100 Subject: [PATCH 08/52] Updated item --- src/Generators/Google/latte/item.latte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index d70818a..e0d0b5d 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -1,9 +1,9 @@ {contentType xml} {$item->id} - title}]]> - description}]]> - link}]]> + <![CDATA[{$item->title}]]> + description}]]> + link}]]> {if !empty($images = $item->images)} {foreach $images as $image} From 912cf250b6e4b280535dceda124345b7fd928c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Wed, 7 Mar 2018 15:27:38 +0100 Subject: [PATCH 09/52] Google feed update --- src/Generators/BaseGenerator.php | 43 +++++++++++++++++++++++- src/Generators/Google/latte/header.latte | 3 ++ src/Generators/Google/latte/item.latte | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/Generators/BaseGenerator.php b/src/Generators/BaseGenerator.php index 02d8aaa..34ac88d 100644 --- a/src/Generators/BaseGenerator.php +++ b/src/Generators/BaseGenerator.php @@ -26,6 +26,18 @@ abstract class BaseGenerator implements IGenerator { /** @var \Mk\Feed\Storage */ private $storage; + /** @var array */ + private $config; + + /** @var string */ + private $link; + + /** @var string */ + private $description; + + /** @var string */ + private $storeName; + /** * BaseGenerator constructor. * @param \Mk\Feed\Storage $storage @@ -35,6 +47,30 @@ public function __construct(Storage $storage) $this->storage = $storage; } + /** + * @param string $link + */ + public function setLink(string $link): void { + $this->link = $link; + } + + /** + * @param string $description + */ + public function setDescription(string $description): void { + $this->description = $description; + } + + /** + * @param string $storeName + */ + public function setStoreName(string $storeName): void { + $this->storeName = $storeName; + } + + + + /** * @param $name * @return string path to template @@ -48,6 +84,7 @@ abstract protected function getTemplate($name); protected function prepare() { $this->handle = tmpfile(); + $this->prepareTemplate('header'); $this->prepared = true; } @@ -106,11 +143,15 @@ public function save($filename) */ protected function prepareTemplate($template) { + + $latte = new Engine; + $content = $latte->renderToString($this->getTemplate($template), array('storeName' => $this->storeName, 'description' => $this->description, 'link' => $this->link)); $file = $this->getTemplate($template); $footerHandle = fopen('safe://' . $file, 'r'); $footer = fread($footerHandle, filesize($file)); fclose($footerHandle); - fwrite($this->handle, $footer); + fwrite($this->handle, $content); +// fwrite($this->handle, $footer); } } \ No newline at end of file diff --git a/src/Generators/Google/latte/header.latte b/src/Generators/Google/latte/header.latte index caa59a2..ce61ec8 100644 --- a/src/Generators/Google/latte/header.latte +++ b/src/Generators/Google/latte/header.latte @@ -1,3 +1,6 @@ + {$storeName} + {$link} + {$description} \ No newline at end of file diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index e0d0b5d..02d26ac 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -2,7 +2,7 @@ {$item->id} <![CDATA[{$item->title}]]> - description}]]> + description|noescape}]]> link}]]> {if !empty($images = $item->images)} From 8387fa029fd8366fad1179db66e1f741c8ad57b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 8 Mar 2018 08:18:04 +0100 Subject: [PATCH 10/52] Added permanent mpn & changed header --- src/Generators/Google/latte/header.latte | 4 ++-- src/Generators/Google/latte/item.latte | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Generators/Google/latte/header.latte b/src/Generators/Google/latte/header.latte index ce61ec8..f17c5a9 100644 --- a/src/Generators/Google/latte/header.latte +++ b/src/Generators/Google/latte/header.latte @@ -1,6 +1,6 @@ - + + {$storeName} {$link} {$description} - \ No newline at end of file diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index 02d26ac..656604f 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -27,7 +27,7 @@ Adult Navy 8 Standard*} - {$item->mpn} + {if $item->mpn}{$item->mpn}{/if} {if !empty($productTypes = $item->productTypes)} {$productType->text} From f91d66807f332949af71fa249bebb7086b1c401c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 8 Mar 2018 13:15:36 +0100 Subject: [PATCH 11/52] Added identifier_exists, removed HTML tags --- src/Generators/Google/latte/item.latte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index 656604f..49c0f05 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -2,7 +2,7 @@ {$item->id} <![CDATA[{$item->title}]]> - description|noescape}]]> + description|striptags|noescape}]]> link}]]> {if !empty($images = $item->images)} @@ -15,8 +15,9 @@ {$item->condition} {$item->availability} {$item->price} CZK + {$item->identifierExists ? 'TRUE' : 'FALSE'} {$item->salePrice} - {$item->gtin} + {if $item->gtin}{$item->gtin}{/if} {$item->brand} {$item->labels[0]} {$item->labels[1]} From 3df9b268ad3acded04f98ac6229febd269bdbbe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Sat, 10 Mar 2018 10:56:49 +0100 Subject: [PATCH 12/52] Fixed description tags --- src/Generators/Zbozi/latte/item.latte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/Zbozi/latte/item.latte b/src/Generators/Zbozi/latte/item.latte index bf920f5..e8d342c 100644 --- a/src/Generators/Zbozi/latte/item.latte +++ b/src/Generators/Zbozi/latte/item.latte @@ -1,7 +1,7 @@ {contentType xml} {$item->getProductName()} - {$item->getDescription()} + getDescription()|striptags|noescape}]]> {$item->getUrl()} {$item->getPriceVat()} {$item->getDeliveryDate()} From c0a5aee797cc295a6eeb4d6b84abda3033a14905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 16 Mar 2018 14:53:25 +0100 Subject: [PATCH 13/52] Fixed description --- src/Generators/Heureka/Parameter.php | 14 +++++++++++++- src/Generators/Heureka/latte/item.latte | 6 +++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Generators/Heureka/Parameter.php b/src/Generators/Heureka/Parameter.php index 6cc03e9..f42e1f5 100644 --- a/src/Generators/Heureka/Parameter.php +++ b/src/Generators/Heureka/Parameter.php @@ -16,16 +16,20 @@ class Parameter { protected $name; protected $value; + protected $unit; /** * Parameter constructor. * @param $name * @param $value + * @param $unit */ - public function __construct($name, $value) + public function __construct($name, $value, $unit = null) { $this->name = $name; $this->value = $value; + + $this->unit = $unit; } /** @@ -44,4 +48,12 @@ public function getValue() return $this->value; } + /** + * @return mixed + */ + public function getUnit() { + return $this->unit; + } + + } diff --git a/src/Generators/Heureka/latte/item.latte b/src/Generators/Heureka/latte/item.latte index 7e73432..06bdd3d 100644 --- a/src/Generators/Heureka/latte/item.latte +++ b/src/Generators/Heureka/latte/item.latte @@ -3,7 +3,7 @@ {$item->getItemId()} getProductName()}]]> getProduct()}]]> - getDescription()}]]> + getDescription()|striptags|noescape}]]> {$item->getUrl()} {if !empty($images = $item->getImages())} @@ -19,7 +19,7 @@ {if !empty($parameters = $item->getParameters())} {$parameter->getName()} - {$parameter->getValue()} + {$parameter->getValue()}{$parameter->getUnit()} {/if} @@ -34,7 +34,7 @@ {$delivery->id} {$delivery->price} - {$delivery->priceCod} + {$delivery->priceCod} {/if} From 91dc55b74e3789b0ab23153743d9fdfda10e4d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 25 Sep 2018 09:46:42 +0200 Subject: [PATCH 14/52] New zbozi delivery --- .gitignore | 2 + src/Generators/Zbozi/Delivery.php | 116 ++++++++++++++++++++++++++ src/Generators/Zbozi/Item.php | 60 +++++++++++++ src/Generators/Zbozi/latte/item.latte | 6 ++ 4 files changed, 184 insertions(+) create mode 100644 .gitignore create mode 100644 src/Generators/Zbozi/Delivery.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b6927a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +/.idea/ diff --git a/src/Generators/Zbozi/Delivery.php b/src/Generators/Zbozi/Delivery.php new file mode 100644 index 0000000..47b52a9 --- /dev/null +++ b/src/Generators/Zbozi/Delivery.php @@ -0,0 +1,116 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Delivery{ + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + CONST CESKA_POSTA = 'CESKA_POSTA', + CESKA_POSTA_NA_POSTU = 'CESKA_POSTA_NA_POSTU', + CSAD_LOGISTIK_OSTRAVA = 'CSAD_LOGISTIK_OSTRAVA', + DPD = 'DPD', + DHL = 'DHL', + DSV = 'DSV', + EMS = 'EMS', + FOFR = 'FOFR', + GEBRUDER_WEISS = 'GEBRUDER_WEISS', + GEIS = 'GEIS', + GENERAL_PARCEL = 'GENERAL_PARCEL', + GLS = 'GLS', + HDS = 'HDS', + HEUREKAPOINT = 'HEUREKAPOINT', + INTIME = 'INTIME', + PPL = 'PPL', + RADIALKA = 'RADIALKA', + SEEGMULLER = 'SEEGMULLER', + TNT = 'TNT', + TOPTRANS = 'TOPTRANS', + UPS = 'UPS', + ULOZENKA = 'ULOZENKA', + VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA', + ZASILKOVNA = 'ZASILKOVNA'; + + static $ids = array( + self::CESKA_POSTA, + self::CESKA_POSTA_NA_POSTU, + self::CSAD_LOGISTIK_OSTRAVA, + self::DPD, + self::DHL, + self::DSV, + self::EMS, + self::FOFR, + self::GEBRUDER_WEISS, + self::GEIS, + self::GENERAL_PARCEL, + self::GLS, + self::HDS, + self::HEUREKAPOINT, + self::INTIME, + self::PPL, + self::RADIALKA, + self::SEEGMULLER, + self::TNT, + self::TOPTRANS, + self::UPS, + self::ULOZENKA, + self::VLASTNI_PREPRAVA, + self::ZASILKOVNA, + ); + + /** @var string */ + private $id; + /** @var float */ + private $price; + /** @var float|null */ + private $priceCod; + + /** + * Delivery constructor. + * @param $id + * @param $price + * @param null $priceCod + */ + public function __construct($id, $price, $priceCod = null) + { + if (!in_array($id, self::$ids)) { + throw new \InvalidArgumentException("Delivery with id $id doesn\t exist"); + } + $this->id = (string) $id; + $this->price = (float) $price; + $this->priceCod = isset($priceCod) ? (float) $priceCod : null; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return float + */ + public function getPrice() + { + return $this->price; + } + + /** + * @return float|null + */ + public function getPriceCod() + { + return $this->priceCod; + } + +} diff --git a/src/Generators/Zbozi/Item.php b/src/Generators/Zbozi/Item.php index 041456c..9825f31 100644 --- a/src/Generators/Zbozi/Item.php +++ b/src/Generators/Zbozi/Item.php @@ -26,6 +26,15 @@ class Item extends BaseItem { /** @var \DateTime|int @required */ protected $deliveryDate; + /** @var Delivery|null */ + protected $deliveryId; + + /** @var float|null */ + protected $deliveryPrice; + + /** @var float|null */ + protected $deliveryPriceCod; + #recomanded /** @var string|null */ protected $itemId; @@ -597,4 +606,55 @@ public function getParameters() return $this->parameters; } + /** + * @return Delivery|null + */ + public function getDeliveryId() { + return $this->deliveryId; + } + + /** + * @param Delivery|null $deliveryId + * @return Item + */ + public function setDeliveryId($deliveryId) { + $this->deliveryId = $deliveryId; + return $this; + } + + + + /** + * @return float|null + */ + public function getDeliveryPrice() { + return $this->deliveryPrice; + } + + /** + * @param float|null $deliveryPrice + * @return Item + */ + public function setDeliveryPrice($deliveryPrice) { + $this->deliveryPrice = $deliveryPrice; + return $this; + } + + /** + * @return float|null + */ + public function getDeliveryPriceCod() { + return $this->deliveryPriceCod; + } + + /** + * @param float|null $deliveryPriceCod + * @return Item + */ + public function setDeliveryPriceCod($deliveryPriceCod) { + $this->deliveryPriceCod = $deliveryPriceCod; + return $this; + } + + } diff --git a/src/Generators/Zbozi/latte/item.latte b/src/Generators/Zbozi/latte/item.latte index bf920f5..476ee93 100644 --- a/src/Generators/Zbozi/latte/item.latte +++ b/src/Generators/Zbozi/latte/item.latte @@ -5,6 +5,12 @@ {$item->getUrl()} {$item->getPriceVat()} {$item->getDeliveryDate()} + + {$item->getDeliveryId()} + {$item->getDeliveryPrice()} + {$item->getDeliveryPriceCod()} + + {$item->getItemId()} {if !empty($images = $item->getImages())} From cfe26bf3cc7bb9dc1440274d6acdfa82ec118ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 25 Sep 2018 09:58:18 +0200 Subject: [PATCH 15/52] Updated zbozi delivery --- src/Generators/Zbozi/Item.php | 54 +-------------------------- src/Generators/Zbozi/latte/item.latte | 8 ++-- 2 files changed, 5 insertions(+), 57 deletions(-) diff --git a/src/Generators/Zbozi/Item.php b/src/Generators/Zbozi/Item.php index 9825f31..2cbf437 100644 --- a/src/Generators/Zbozi/Item.php +++ b/src/Generators/Zbozi/Item.php @@ -27,14 +27,7 @@ class Item extends BaseItem { protected $deliveryDate; /** @var Delivery|null */ - protected $deliveryId; - - /** @var float|null */ - protected $deliveryPrice; - - /** @var float|null */ - protected $deliveryPriceCod; - + protected $delivery; #recomanded /** @var string|null */ protected $itemId; @@ -606,55 +599,10 @@ public function getParameters() return $this->parameters; } - /** - * @return Delivery|null - */ - public function getDeliveryId() { - return $this->deliveryId; - } - /** - * @param Delivery|null $deliveryId - * @return Item - */ - public function setDeliveryId($deliveryId) { - $this->deliveryId = $deliveryId; - return $this; - } - - - - /** - * @return float|null - */ - public function getDeliveryPrice() { - return $this->deliveryPrice; - } - /** - * @param float|null $deliveryPrice - * @return Item - */ - public function setDeliveryPrice($deliveryPrice) { - $this->deliveryPrice = $deliveryPrice; - return $this; - } - /** - * @return float|null - */ - public function getDeliveryPriceCod() { - return $this->deliveryPriceCod; - } - /** - * @param float|null $deliveryPriceCod - * @return Item - */ - public function setDeliveryPriceCod($deliveryPriceCod) { - $this->deliveryPriceCod = $deliveryPriceCod; - return $this; - } } diff --git a/src/Generators/Zbozi/latte/item.latte b/src/Generators/Zbozi/latte/item.latte index d8057a2..2bf6b14 100644 --- a/src/Generators/Zbozi/latte/item.latte +++ b/src/Generators/Zbozi/latte/item.latte @@ -5,10 +5,10 @@ {$item->getUrl()} {$item->getPriceVat()} {$item->getDeliveryDate()} - - {$item->getDeliveryId()} - {$item->getDeliveryPrice()} - {$item->getDeliveryPriceCod()} + + {$delivery->id} + {$delivery->price} + {$delivery->priceCod} {$item->getItemId()} From 10d681655545146d411d95d86ab2603777d1a58c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 25 Sep 2018 10:05:59 +0200 Subject: [PATCH 16/52] Updated delivetry zbozi --- src/Generators/Zbozi/Item.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Generators/Zbozi/Item.php b/src/Generators/Zbozi/Item.php index 2cbf437..16c9775 100644 --- a/src/Generators/Zbozi/Item.php +++ b/src/Generators/Zbozi/Item.php @@ -599,6 +599,23 @@ public function getParameters() return $this->parameters; } + /** + * @return Delivery|null + */ + public function getDelivery() { + return $this->delivery; + } + + /** + * @param Delivery|null $delivery + * @return Item + */ + public function setDelivery($delivery) { + $this->delivery = $delivery; + return $this; + } + + From 8ee348aab17184c9b753a3a89cca4c4771a51b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 25 Sep 2018 10:10:33 +0200 Subject: [PATCH 17/52] Updated delivetry zbozi --- src/Generators/Zbozi/Item.php | 2 +- src/Generators/Zbozi/latte/item.latte | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Generators/Zbozi/Item.php b/src/Generators/Zbozi/Item.php index 16c9775..d839f0e 100644 --- a/src/Generators/Zbozi/Item.php +++ b/src/Generators/Zbozi/Item.php @@ -615,7 +615,7 @@ public function setDelivery($delivery) { return $this; } - + diff --git a/src/Generators/Zbozi/latte/item.latte b/src/Generators/Zbozi/latte/item.latte index 2bf6b14..169793f 100644 --- a/src/Generators/Zbozi/latte/item.latte +++ b/src/Generators/Zbozi/latte/item.latte @@ -5,10 +5,10 @@ {$item->getUrl()} {$item->getPriceVat()} {$item->getDeliveryDate()} - - {$delivery->id} - {$delivery->price} - {$delivery->priceCod} + + {$item->getDelivery()->id} + {$item->getDelivery()->price} + {$item->getDelivery()->priceCod} {$item->getItemId()} From 863f5c2804ebe53388e0a4cfa0c0f34428cae82c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 5 Oct 2018 14:59:38 +0200 Subject: [PATCH 18/52] ADded support for custom feeds --- src/Generators/Custom/CategoriesHelper.php | 56 ++ src/Generators/Custom/Delivery.php | 116 +++ src/Generators/Custom/Generator.php | 24 + src/Generators/Custom/Gift.php | 38 + src/Generators/Custom/Image.php | 40 + src/Generators/Custom/Item.php | 966 +++++++++++++++++++++ src/Generators/Custom/Parameter.php | 59 ++ src/Generators/Custom/latte/footer.latte | 1 + src/Generators/Custom/latte/header.latte | 2 + src/Generators/Custom/latte/item.latte | 76 ++ 10 files changed, 1378 insertions(+) create mode 100644 src/Generators/Custom/CategoriesHelper.php create mode 100644 src/Generators/Custom/Delivery.php create mode 100644 src/Generators/Custom/Generator.php create mode 100644 src/Generators/Custom/Gift.php create mode 100644 src/Generators/Custom/Image.php create mode 100644 src/Generators/Custom/Item.php create mode 100644 src/Generators/Custom/Parameter.php create mode 100644 src/Generators/Custom/latte/footer.latte create mode 100644 src/Generators/Custom/latte/header.latte create mode 100644 src/Generators/Custom/latte/item.latte diff --git a/src/Generators/Custom/CategoriesHelper.php b/src/Generators/Custom/CategoriesHelper.php new file mode 100644 index 0000000..834fd99 --- /dev/null +++ b/src/Generators/Custom/CategoriesHelper.php @@ -0,0 +1,56 @@ +cache = new Cache($storage, __CLASS__); + } + } + + public function getCategories() + { + $categories = array(); + if (!$this->cache || !($categories = $this->cache->load('categories'))) { + $xml = file_get_contents(self::CATEGORY_URL); + $dom = new \DOMDocument(); + + $dom->loadXML($xml); + $xpath = new \DOMXPath($dom); + /** @var \DOMElement[] $_categories */ + $_categories = $xpath->query(".//CATEGORY"); + + foreach ($_categories as $category) { + $categoryIdElement = $xpath->query($category->getNodePath().'/CATEGORY_ID'); + $id = isset($categoryIdElement[0]) ? (int)$categoryIdElement[0]->nodeValue : null; + + $categoryFullNameElement = $xpath->query($category->getNodePath().'/CATEGORY_FULLNAME'); + $_cat = isset($categoryFullNameElement[0]) ? (string)$categoryFullNameElement[0]->nodeValue : null; + + if($id && $_cat) { + $_cat = str_replace('Heureka.cz | ', '', $_cat); + $categories[$id] = $_cat; + } + } + + asort($categories); + + if ($this->cache) { + $this->cache->save('categories', $categories); + } + } + + return $categories; + } +} \ No newline at end of file diff --git a/src/Generators/Custom/Delivery.php b/src/Generators/Custom/Delivery.php new file mode 100644 index 0000000..ccbfbe9 --- /dev/null +++ b/src/Generators/Custom/Delivery.php @@ -0,0 +1,116 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Delivery{ + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + CONST CESKA_POSTA = 'CESKA_POSTA', + CESKA_POSTA_NA_POSTU = 'CESKA_POSTA_NA_POSTU', + CSAD_LOGISTIK_OSTRAVA = 'CSAD_LOGISTIK_OSTRAVA', + DPD = 'DPD', + DHL = 'DHL', + DSV = 'DSV', + EMS = 'EMS', + FOFR = 'FOFR', + GEBRUDER_WEISS = 'GEBRUDER_WEISS', + GEIS = 'GEIS', + GENERAL_PARCEL = 'GENERAL_PARCEL', + GLS = 'GLS', + HDS = 'HDS', + HEUREKAPOINT = 'HEUREKAPOINT', + INTIME = 'INTIME', + PPL = 'PPL', + RADIALKA = 'RADIALKA', + SEEGMULLER = 'SEEGMULLER', + TNT = 'TNT', + TOPTRANS = 'TOPTRANS', + UPS = 'UPS', + ULOZENKA = 'ULOZENKA', + VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA', + ZASILKOVNA = 'ZASILKOVNA'; + + static $ids = array( + self::CESKA_POSTA, + self::CESKA_POSTA_NA_POSTU, + self::CSAD_LOGISTIK_OSTRAVA, + self::DPD, + self::DHL, + self::DSV, + self::EMS, + self::FOFR, + self::GEBRUDER_WEISS, + self::GEIS, + self::GENERAL_PARCEL, + self::GLS, + self::HDS, + self::HEUREKAPOINT, + self::INTIME, + self::PPL, + self::RADIALKA, + self::SEEGMULLER, + self::TNT, + self::TOPTRANS, + self::UPS, + self::ULOZENKA, + self::VLASTNI_PREPRAVA, + self::ZASILKOVNA, + ); + + /** @var string */ + private $id; + /** @var float */ + private $price; + /** @var float|null */ + private $priceCod; + + /** + * Delivery constructor. + * @param $id + * @param $price + * @param null $priceCod + */ + public function __construct($id, $price, $priceCod = null) + { + if (!in_array($id, self::$ids)) { + throw new \InvalidArgumentException("Delivery with id $id doesn\t exist"); + } + $this->id = (string) $id; + $this->price = (float) $price; + $this->priceCod = isset($priceCod) ? (float) $priceCod : null; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return float + */ + public function getPrice() + { + return $this->price; + } + + /** + * @return float|null + */ + public function getPriceCod() + { + return $this->priceCod; + } + +} diff --git a/src/Generators/Custom/Generator.php b/src/Generators/Custom/Generator.php new file mode 100644 index 0000000..a145492 --- /dev/null +++ b/src/Generators/Custom/Generator.php @@ -0,0 +1,24 @@ + + * @package Mk\Feed\Generators + * @see http://sluzby.heureka.cz/napoveda/xml-feed/ Documentation + */ +abstract class Generator extends BaseGenerator { + + /** + * @param $name + * @return string + */ + protected function getTemplate($name) + { + $reflection = new \ReflectionClass(__CLASS__); + return dirname($reflection->getFileName()) . '/latte/' . $name . '.latte'; + } + +} \ No newline at end of file diff --git a/src/Generators/Custom/Gift.php b/src/Generators/Custom/Gift.php new file mode 100644 index 0000000..d526d4f --- /dev/null +++ b/src/Generators/Custom/Gift.php @@ -0,0 +1,38 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Gift { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + /** @var string */ + protected $name; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Gift constructor. + * @param $name + */ + public function __construct($name) + { + + $this->name = (string)$name; + } + +} diff --git a/src/Generators/Custom/Image.php b/src/Generators/Custom/Image.php new file mode 100644 index 0000000..571ede7 --- /dev/null +++ b/src/Generators/Custom/Image.php @@ -0,0 +1,40 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Image +{ + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + /** @var string */ + private $url; + + /** + * Image constructor. + * @param string $url + */ + public function __construct($url) + { + $this->url = (string) $url; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + + +} diff --git a/src/Generators/Custom/Item.php b/src/Generators/Custom/Item.php new file mode 100644 index 0000000..3a60171 --- /dev/null +++ b/src/Generators/Custom/Item.php @@ -0,0 +1,966 @@ + + * @package Mk\Feed\Generators\Heureka + * @see http://sluzby.heureka.cz/napoveda/xml-feed/ Documentation + */ +class Item extends BaseItem { + + /** @var string @required */ + protected $itemId; + + /** @var string @required */ + protected $productName; + + /** @var string|null */ + protected $product; + + /** @var bool */ + protected $status; + + /** @var string|null */ + protected $name; + /** @var string |null*/ + protected $nameExt; + /** @var string |null*/ + protected $descriptionShort; + /** @var string |null*/ + protected $title; + /** @var string|null */ + protected $metaDescription; + /** @var string |null*/ + protected $metaKeywords; + /** @var string |null*/ + protected $parts; + /** @var float|null */ + protected $priceOriginal; + /** @var int |null*/ + protected $soldQty; + /** @var string |null*/ + protected $defaultCategory; + /** @var float|null */ + protected $weight; + /** @var float |null*/ + protected $cost; + /** @var float |null*/ + protected $margin; + /** @var bool|null */ + protected $freeDelivery; + /** @var string|null */ + protected $model; + /** @var bool */ + protected $inSale; + /** @var bool */ + protected $archived; + /** @var int |null*/ + protected $minQuantity; + /** @var int|null */ + protected $maxQuantity; + /** @var string|null */ + protected $guarantee; + /** @var string |null*/ + protected $unit; + /** @var string |null*/ + protected $vat; + /** @var int |null*/ + protected $stock; + /** @var string |null*/ + protected $sku; + + /** @var string | null */ + protected $availability; + + /** @var string @required */ + protected $description; + + /** @var string @required */ + protected $url; + + /** @var Image[] */ + protected $images = array(); + + /** @var string|null */ + protected $videoUrl; + + /** @var float @required */ + protected $priceVat; + /** @var float */ + protected $priceNoVat; + + /** @var string|null */ + protected $itemType; + + /** @var Parameter[] */ + protected $parameters = array(); + + /** @var string|null */ + protected $manufacturer; + + /** @var string|null */ + protected $categoryText; + + /** @var string|null */ + protected $ean; + + /** @var string|null */ + protected $isbn; + + /** @var float|null */ + protected $heurekaCpc; + + /** @var \DateTime|int @required */ + protected $deliveryDate; + + /** @var Delivery[] */ + protected $deliveries = array(); + + /** @var string|null */ + protected $itemGroupId; + + /** @var array */ + protected $accessories = array(); + + /** @var float */ + protected $dues = 0; + + /** @var Gift[] */ + protected $gifts = array(); + + /** + * @return float + */ + public function getDues() + { + return $this->dues; + } + + /** + * @param float $dues + * @return Item + */ + public function setDues($dues) + { + $this->dues = (float)$dues; + + return $this; + } + + /** + * @return string + */ + public function getVideoUrl() + { + return $this->videoUrl; + } + + /** + * @param string $videoUrl + * @return $this + */ + public function setVideoUrl($videoUrl) + { + $this->videoUrl = $videoUrl; + + return $this; + } + + /** + * @param $url + * @return $this + */ + public function addImage($url) + { + $this->images[] = new Image($url); + + return $this; + } + + /** + * @param $id + * @param $price + * @param null $priceCod + * @return $this + */ + public function addDelivery($id, $price, $priceCod = null) + { + $this->deliveries[] = new Delivery($id, $price, $priceCod); + + return $this; + } + + /** + * @return Delivery[] + */ + public function getDeliveries() + { + return $this->deliveries; + } + + /** + * @param $name + * @param $val + * @param null $unit + * @return Item + */ + public function addParameter($name, $val, $unit = null) + { + $this->parameters[] = new Parameter($name, $val, $unit); + + return $this; + } + + /** + * @param $name + * @return $this + */ + public function addGift($name) + { + $this->gifts[] = new Gift($name); + + return $this; + } + + /** + * @param $itemId + * @return $this + */ + public function addAccessory($itemId) + { + $this->accessories[] = $itemId; + + return $this; + } + + /** + * @return array + */ + public function getAccessories() + { + return $this->accessories; + } + + /** + * @return string + */ + public function getProductName() + { + return $this->productName; + } + + /** + * @param string $productName + * @return Item + */ + public function setProductName($productName) + { + $this->productName = (string)$productName; + + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + * @return Item + */ + public function setDescription($description) + { + $this->description = (string)$description; + + return $this; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + * @return Item + */ + public function setUrl($url) + { + $this->url = (string)$url; + + return $this; + } + + /** + * @return float + */ + public function getPriceVat() + { + return $this->priceVat; + } + + /** + * @param float $priceVat + * @return Item + */ + public function setPriceVat($priceVat) + { + $this->priceVat = (float)$priceVat; + + return $this; + } + + /** + * @return int|string + */ + public function getDeliveryDate() + { + return $this->deliveryDate instanceof \DateTime ? $this->deliveryDate->format('Y-m-d') : $this->deliveryDate; + } + + /** + * @param int|\DateTime $deliveryDate + * @return Item + */ + public function setDeliveryDate($deliveryDate) + { + if (!is_int($deliveryDate) && !($deliveryDate instanceof \DateTime)) { + throw new \InvalidArgumentException("Delivery date must be integer or DateTime"); + } + $this->deliveryDate = $deliveryDate; + + return $this; + } + + /** + * @return null|string + */ + public function getItemId() + { + return $this->itemId; + } + + /** + * @param null|string $itemId + * @return Item + */ + public function setItemId($itemId) + { + $this->itemId = $itemId; + + return $this; + } + + /** + * @return null|string + */ + public function getEan() + { + return $this->ean; + } + + /** + * @param null|string $ean + * @return Item + */ + public function setEan($ean) + { + $this->ean = $ean; + + return $this; + } + + /** + * @return null|string + */ + public function getIsbn() + { + return $this->isbn; + } + + /** + * @param null|string $isbn + * @return Item + */ + public function setIsbn($isbn) + { + $this->isbn = $isbn; + + return $this; + } + + /** + * @return null|string + */ + public function getItemGroupId() + { + return $this->itemGroupId; + } + + /** + * @param null|string $itemGroupId + * @return Item + */ + public function setItemGroupId($itemGroupId) + { + $this->itemGroupId = $itemGroupId; + + return $this; + } + + /** + * @return null|string + */ + public function getManufacturer() + { + return $this->manufacturer; + } + + /** + * @param null|string $manufacturer + * @return Item + */ + public function setManufacturer($manufacturer) + { + $this->manufacturer = $manufacturer; + + return $this; + } + + /** + * @return null|string + */ + public function getCategoryText() + { + return $this->categoryText; + } + + /** + * @param null|string $categoryText + * @return Item + */ + public function setCategoryText($categoryText) + { + $this->categoryText = $categoryText; + + return $this; + } + + /** + * @return null|string + */ + public function getProduct() + { + return $this->product; + } + + /** + * @param null|string $product + * @return Item + */ + public function setProduct($product) + { + $this->product = $product; + + return $this; + } + + /** + * @return null|string + */ + public function getItemType() + { + return $this->itemType; + } + + /** + * @return Image[] + */ + public function getImages() + { + return $this->images; + } + + /** + * @return Gift[] + */ + public function getGifts() + { + return $this->gifts; + } + + /** + * @return Parameter[] + */ + public function getParameters() + { + return $this->parameters; + } + + /** + * @return null|string + */ + public function getHeurekaCpc() + { + return $this->heurekaCpc; + } + + /** + * @param null|string $heurekaCpc + * @return $this + */ + public function setHeurekaCpc($heurekaCpc) + { + $this->heurekaCpc = $heurekaCpc; + + return $this; + } + + /** + * @return bool + */ + public function getStatus(): ?bool { + return $this->status; + } + + /** + * @param bool $status + * @return Item + */ + public function setStatus(bool $status): Item { + $this->status = $status; + return $this; + } + + /** + * @return null|string + */ + public function getName(): ?string { + return $this->name; + } + + /** + * @param null|string $name + * @return Item + */ + public function setName(?string $name): Item { + $this->name = $name; + return $this; + } + + /** + * @return null|string + */ + public function getNameExt(): ?string { + return $this->nameExt; + } + + /** + * @param null|string $nameExt + * @return Item + */ + public function setNameExt(?string $nameExt): Item { + $this->nameExt = $nameExt; + return $this; + } + + /** + * @return null|string + */ + public function getDescriptionShort(): ?string { + return $this->descriptionShort; + } + + /** + * @param null|string $descriptionShort + * @return Item + */ + public function setDescriptionShort(?string $descriptionShort): Item { + $this->descriptionShort = $descriptionShort; + return $this; + } + + /** + * @return null|string + */ + public function getTitle(): ?string { + return $this->title; + } + + /** + * @param null|string $title + * @return Item + */ + public function setTitle(?string $title): Item { + $this->title = $title; + return $this; + } + + /** + * @return null|string + */ + public function getMetaDescription(): ?string { + return $this->metaDescription; + } + + /** + * @param null|string $metaDescription + * @return Item + */ + public function setMetaDescription(?string $metaDescription): Item { + $this->metaDescription = $metaDescription; + return $this; + } + + /** + * @return null|string + */ + public function getMetaKeywords(): ?string { + return $this->metaKeywords; + } + + /** + * @param null|string $metaKeywords + * @return Item + */ + public function setMetaKeywords(?string $metaKeywords): Item { + $this->metaKeywords = $metaKeywords; + return $this; + } + + /** + * @return null|string + */ + public function getParts(): ?string { + return $this->parts; + } + + /** + * @param null|string $parts + * @return Item + */ + public function setParts(?string $parts): Item { + $this->parts = $parts; + return $this; + } + + /** + * @return float|null + */ + public function getPriceOriginal(): ?float { + return $this->priceOriginal; + } + + /** + * @param float|null $priceOriginal + * @return Item + */ + public function setPriceOriginal(?float $priceOriginal): Item { + $this->priceOriginal = $priceOriginal; + return $this; + } + + /** + * @return int|null + */ + public function getSoldQty(): ?int { + return $this->soldQty; + } + + /** + * @param int|null $soldQty + * @return Item + */ + public function setSoldQty(?int $soldQty): Item { + $this->soldQty = $soldQty; + return $this; + } + + /** + * @return null|string + */ + public function getDefaultCategory(): ?string { + return $this->defaultCategory; + } + + /** + * @param null|string $defaultCategory + * @return Item + */ + public function setDefaultCategory(?string $defaultCategory): Item { + $this->defaultCategory = $defaultCategory; + return $this; + } + + /** + * @return float|null + */ + public function getWeight(): ?float { + return $this->weight; + } + + /** + * @param float|null $weight + * @return Item + */ + public function setWeight(?float $weight): Item { + $this->weight = $weight; + return $this; + } + + /** + * @return float|null + */ + public function getCost(): ?float { + return $this->cost; + } + + /** + * @param float|null $cost + * @return Item + */ + public function setCost(?float $cost): Item { + $this->cost = $cost; + return $this; + } + + /** + * @return float|null + */ + public function getMargin(): ?float { + return $this->margin; + } + + /** + * @param float|null $margin + * @return Item + */ + public function setMargin(?float $margin): Item { + $this->margin = $margin; + return $this; + } + + /** + * @return bool|null + */ + public function getFreeDelivery(): ?bool { + return $this->freeDelivery; + } + + /** + * @param bool|null $freeDelivery + * @return Item + */ + public function setFreeDelivery(?bool $freeDelivery): Item { + $this->freeDelivery = $freeDelivery; + return $this; + } + + /** + * @return null|string + */ + public function getModel(): ?string { + return $this->model; + } + + /** + * @param null|string $model + * @return Item + */ + public function setModel(?string $model): Item { + $this->model = $model; + return $this; + } + + /** + * @return bool + */ + public function isInSale(): ?bool { + return $this->inSale; + } + + /** + * @param bool $inSale + * @return Item + */ + public function setInSale(bool $inSale): Item { + $this->inSale = $inSale; + return $this; + } + + /** + * @return bool + */ + public function isArchived(): bool { + return $this->archived; + } + + /** + * @param bool $archived + * @return Item + */ + public function setArchived(bool $archived): Item { + $this->archived = $archived; + return $this; + } + + /** + * @return int|null + */ + public function getMinQuantity(): ?int { + return $this->minQuantity; + } + + /** + * @param int|null $minQuantity + * @return Item + */ + public function setMinQuantity(?int $minQuantity): Item { + $this->minQuantity = $minQuantity; + return $this; + } + + /** + * @return int|null + */ + public function getMaxQuantity(): ?int { + return $this->maxQuantity; + } + + /** + * @param int|null $maxQuantity + * @return Item + */ + public function setMaxQuantity(?int $maxQuantity): Item { + $this->maxQuantity = $maxQuantity; + return $this; + } + + /** + * @return null|string + */ + public function getGuarantee(): ?string { + return $this->guarantee; + } + + /** + * @param null|string $guarantee + * @return Item + */ + public function setGuarantee(?string $guarantee): Item { + $this->guarantee = $guarantee; + return $this; + } + + /** + * @return null|string + */ + public function getUnit(): ?string { + return $this->unit; + } + + /** + * @param null|string $unit + * @return Item + */ + public function setUnit(?string $unit): Item { + $this->unit = $unit; + return $this; + } + + /** + * @return null|string + */ + public function getAvailability(): ?string { + return $this->availability; + } + + /** + * @param null|string $availability + * @return Item + */ + public function setAvailability(?string $availability): Item { + $this->availability = $availability; + return $this; + } + + /** + * @return null|string + */ + public function getVat(): ?string { + return $this->vat; + } + + /** + * @param null|string $vat + * @return Item + */ + public function setVat(?string $vat): Item { + $this->vat = $vat; + return $this; + } + + /** + * @return int|null + */ + public function getStock(): ?int { + return $this->stock; + } + + /** + * @param int|null $stock + * @return Item + */ + public function setStock(?int $stock): Item { + $this->stock = $stock; + return $this; + } + + /** + * @return float + */ + public function getPriceNoVat(){ + return $this->priceNoVat; + } + + /** + * @param float $priceNoVat + * @return Item + */ + public function setPriceNoVat(float $priceNoVat): Item { + $this->priceNoVat = $priceNoVat; + return $this; + } + + /** + * @return null|string + */ + public function getSku(): ?string { + return $this->sku; + } + + /** + * @param null|string $sku + * @return Item + */ + public function setSku(?string $sku): Item { + $this->sku = $sku; + return $this; + } + + + + +} diff --git a/src/Generators/Custom/Parameter.php b/src/Generators/Custom/Parameter.php new file mode 100644 index 0000000..9b00436 --- /dev/null +++ b/src/Generators/Custom/Parameter.php @@ -0,0 +1,59 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Parameter { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + protected $name; + protected $value; + protected $unit; + + /** + * Parameter constructor. + * @param $name + * @param $value + * @param $unit + */ + public function __construct($name, $value, $unit = null) + { + $this->name = $name; + $this->value = $value; + + $this->unit = $unit; + } + + /** + * @return mixed + */ + public function getName() + { + return $this->name; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @return mixed + */ + public function getUnit() { + return $this->unit; + } + + +} diff --git a/src/Generators/Custom/latte/footer.latte b/src/Generators/Custom/latte/footer.latte new file mode 100644 index 0000000..5cfd1ab --- /dev/null +++ b/src/Generators/Custom/latte/footer.latte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Generators/Custom/latte/header.latte b/src/Generators/Custom/latte/header.latte new file mode 100644 index 0000000..900cb04 --- /dev/null +++ b/src/Generators/Custom/latte/header.latte @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/Generators/Custom/latte/item.latte b/src/Generators/Custom/latte/item.latte new file mode 100644 index 0000000..7d4c167 --- /dev/null +++ b/src/Generators/Custom/latte/item.latte @@ -0,0 +1,76 @@ +{contentType xml} + + {$item->getItemId()} + {$item->getSku()} + getName()}]]> + getNameExt()}]]> + getDescription()|striptags|noescape}]]> + getDescriptionShort()|striptags|noescape}]]> + <![CDATA[{$item->getTitle()|striptags|noescape}]]> + getMetaDescription()|striptags|noescape}]]> + getMetaKeywords()|striptags|noescape}]]> + {$item->getParts()} + {$item->getSoldQty()} + {$item->getCategoryText()} + {$item->getWeight()} + {$item->getMargin()} + {$item->getFreeDelivery()} + {$item->getModel()} + {$item->isInSale()} + {$item->getMinQuantity()} + {$item->getMaxQuantity()} + {$item->getGuarantee()} + {$item->getUnit()} + {$item->getAvailability()} + {$item->getVat()} + {$item->getStock()} + + {$item->getUrl()} + {intval($item->getStatus())} + + {if !empty($images = $item->getImages())} + {foreach $images as $image} + {var tag = $iterator->first ? 'IMGURL' : 'IMGURL_ALTERNATIVE'} + <{$tag}>{$image->getUrl()} + {/foreach} + {/if} + + {$item->getVideoUrl()} + {$item->getPriceOriginal()} + {$item->getCost()} + {$item->getPriceVat()} + {$item->getPriceNoVat()} + + {if !empty($parameters = $item->getParameters())} + + {$parameter->getName()} + {$parameter->getValue()}{$parameter->getUnit()} + + {/if} + + getManufacturer()}]]> + getCategoryText()}]]> + {$item->getEan()} + {$item->getIsbn()} + {$item->getHeurekaCpc()} + {$item->getDeliveryDate()} + + {if !empty($deliveries = $item->getDeliveries())} + + {$delivery->id} + {$delivery->price} + {$delivery->priceCod} + + {/if} + + {$item->getItemGroupId()} + + {if !empty($accessories = $item->getAccessories())} + {$itemId} + {/if} + + {$item->getDues()} + {if !empty($gifts = $item->getGifts())} + {$gift->name} + {/if} + From ff3b286b335188cb71b0555f51c7d3fbb3d303ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Mon, 8 Oct 2018 07:33:00 +0200 Subject: [PATCH 19/52] Added support for suppliers --- src/Generators/Custom/Item.php | 20 ++++++++++++++++++++ src/Generators/Custom/latte/item.latte | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/src/Generators/Custom/Item.php b/src/Generators/Custom/Item.php index 3a60171..8f77d37 100644 --- a/src/Generators/Custom/Item.php +++ b/src/Generators/Custom/Item.php @@ -74,6 +74,9 @@ class Item extends BaseItem { /** @var string |null*/ protected $sku; + /** @var string[] */ + protected $suppliers; + /** @var string | null */ protected $availability; @@ -960,6 +963,23 @@ public function setSku(?string $sku): Item { return $this; } + /** + * @return string[] + */ + public function getSuppliers(): ?array { + return $this->suppliers; + } + + /** + * @param string[] $supplier + * @return Item + */ + public function addSupplier(string $supplier): Item { + $this->suppliers[] = $supplier; + return $this; + } + + diff --git a/src/Generators/Custom/latte/item.latte b/src/Generators/Custom/latte/item.latte index 7d4c167..2cb1677 100644 --- a/src/Generators/Custom/latte/item.latte +++ b/src/Generators/Custom/latte/item.latte @@ -49,6 +49,13 @@ {/if} getManufacturer()}]]> + {if $item->getSuppliers()} + + + + + + {/if} getCategoryText()}]]> {$item->getEan()} {$item->getIsbn()} From 18aa53e8bb9f32ec967807b1fbc3b73469861f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 16 Oct 2018 10:27:41 +0200 Subject: [PATCH 20/52] Added support for sk heureka --- src/Generators/Heureka/CategoriesHelper.php | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Generators/Heureka/CategoriesHelper.php b/src/Generators/Heureka/CategoriesHelper.php index ca5a6a0..2d55a78 100644 --- a/src/Generators/Heureka/CategoriesHelper.php +++ b/src/Generators/Heureka/CategoriesHelper.php @@ -8,22 +8,43 @@ class CategoriesHelper { CONST CATEGORY_URL = 'http://www.heureka.cz/direct/xml-export/shops/heureka-sekce.xml'; + CONST CATEGORY_SK_URL = 'http://www.heureka.sk/direct/xml-export/shops/heureka-sekce.xml'; /** @var \Nette\Caching\Cache */ private $cache; + /** @var bool */ + private $sk; + function __construct(IStorage $storage = null) { if ($storage) { $this->cache = new Cache($storage, __CLASS__); } + $this->sk = false; + } + + /** + * @param bool $sk + * @return CategoriesHelper + */ + public function setSk(bool $sk): CategoriesHelper { + $this->sk = $sk; + return $this; } + + + public function getCategories() { $categories = array(); if (!$this->cache || !($categories = $this->cache->load('categories'))) { - $xml = file_get_contents(self::CATEGORY_URL); + if ($this->sk) { + $xml = file_get_contents(self::CATEGORY_SK_URL); + } else { + $xml = file_get_contents(self::CATEGORY_URL); + } $dom = new \DOMDocument(); $dom->loadXML($xml); From ecc6e4a180e8197788ca41d79631153058580cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 18 Oct 2018 14:11:21 +0200 Subject: [PATCH 21/52] Allowed slovak post delivery --- src/Generators/Heureka/Delivery.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Generators/Heureka/Delivery.php b/src/Generators/Heureka/Delivery.php index 8bc3dbe..26cc888 100644 --- a/src/Generators/Heureka/Delivery.php +++ b/src/Generators/Heureka/Delivery.php @@ -37,7 +37,10 @@ class Delivery{ UPS = 'UPS', ULOZENKA = 'ULOZENKA', VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA', - ZASILKOVNA = 'ZASILKOVNA'; + ZASILKOVNA = 'ZASILKOVNA', + + SLOVENSKA_POSTA = 'SLOVENSKA_POSTA'; + static $ids = array( self::CESKA_POSTA, @@ -64,6 +67,8 @@ class Delivery{ self::ULOZENKA, self::VLASTNI_PREPRAVA, self::ZASILKOVNA, + + self::SLOVENSKA_POSTA, ); /** @var string */ From 3e45c1c42ad9a45d8a0706535f509b63def1dbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 9 Apr 2019 13:07:55 +0200 Subject: [PATCH 22/52] Added support for multiple zbozi deliveries --- src/Generators/Zbozi/Item.php | 21 +++++++++++++++++++++ src/Generators/Zbozi/latte/item.latte | 8 ++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Generators/Zbozi/Item.php b/src/Generators/Zbozi/Item.php index d839f0e..4c988cc 100644 --- a/src/Generators/Zbozi/Item.php +++ b/src/Generators/Zbozi/Item.php @@ -28,6 +28,11 @@ class Item extends BaseItem { /** @var Delivery|null */ protected $delivery; + + + /** @var Delivery[] */ + protected $deliveries; + #recomanded /** @var string|null */ protected $itemId; @@ -616,8 +621,24 @@ public function setDelivery($delivery) { } + /** + * @param Delivery $delivery + * @return $this + */ + public function addDelivery(Delivery $delivery) + { + $this->deliveries[] = $delivery; + return $this; + } + /** + * @return Delivery[] + */ + public function getDeliveries() + { + return $this->deliveries; + } diff --git a/src/Generators/Zbozi/latte/item.latte b/src/Generators/Zbozi/latte/item.latte index 169793f..cccdfe9 100644 --- a/src/Generators/Zbozi/latte/item.latte +++ b/src/Generators/Zbozi/latte/item.latte @@ -5,10 +5,10 @@ {$item->getUrl()} {$item->getPriceVat()} {$item->getDeliveryDate()} - - {$item->getDelivery()->id} - {$item->getDelivery()->price} - {$item->getDelivery()->priceCod} + + {$delivery->id} + {$delivery->price} + {$delivery->priceCod} {$item->getItemId()} From efa3b2886d8e628c1c9fb399195e9a0622aff435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 12 Apr 2019 10:23:21 +0200 Subject: [PATCH 23/52] Added CP na postu --- src/Generators/Heureka/Delivery.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Generators/Heureka/Delivery.php b/src/Generators/Heureka/Delivery.php index 26cc888..e3e1d7d 100644 --- a/src/Generators/Heureka/Delivery.php +++ b/src/Generators/Heureka/Delivery.php @@ -16,6 +16,7 @@ class Delivery{ CONST CESKA_POSTA = 'CESKA_POSTA', CESKA_POSTA_NA_POSTU = 'CESKA_POSTA_NA_POSTU', + CESKA_POSTA_DOPORUCENA_ZASILKA = 'CESKA_POSTA_DOPORUCENA_ZASILKA', CSAD_LOGISTIK_OSTRAVA = 'CSAD_LOGISTIK_OSTRAVA', DPD = 'DPD', DHL = 'DHL', @@ -45,6 +46,7 @@ class Delivery{ static $ids = array( self::CESKA_POSTA, self::CESKA_POSTA_NA_POSTU, + self::CESKA_POSTA_DOPORUCENA_ZASILKA, self::CSAD_LOGISTIK_OSTRAVA, self::DPD, self::DHL, From 9ecaf1c6d996efbe865b522f8a3114529b37df7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 16 May 2019 12:14:17 +0200 Subject: [PATCH 24/52] Update composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index be72f51..5a2d39f 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,8 @@ "require": { "php": ">=5.6", - "nette/di": "~2.4.0", - "nette/utils": "~2.4.0 || ~2.5.0", + "nette/di": "~2.4.0 || ^3.0.0", + "nette/utils": "~2.4.0 || ^3.0.0", "latte/latte": "~2.4.0", "kdyby/console": "^2.6.0", "sergiors/importing": "1.0.1" From 8f46739b071ec617a76025f69a9def653df7757c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 17 May 2019 08:37:31 +0200 Subject: [PATCH 25/52] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5a2d39f..a8ffc56 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=5.6", - "nette/di": "~2.4.0 || ^3.0.0", + "nette/di": "~2.4.0 || ^2.5.0", "nette/utils": "~2.4.0 || ^3.0.0", "latte/latte": "~2.4.0", "kdyby/console": "^2.6.0", From d0178fa641ed7341b953f98719ef3e3ebe522230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 17 May 2019 08:37:46 +0200 Subject: [PATCH 26/52] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a8ffc56..8bffc04 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": ">=5.6", "nette/di": "~2.4.0 || ^2.5.0", - "nette/utils": "~2.4.0 || ^3.0.0", + "nette/utils": "~2.4.0 || ^2.5.0", "latte/latte": "~2.4.0", "kdyby/console": "^2.6.0", "sergiors/importing": "1.0.1" From 106539e934625aa72383b73d92a7ee9aa8b8444c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 12 Jul 2019 12:06:48 +0200 Subject: [PATCH 27/52] Added glami (particulary heureka) --- src/Generators/Glami/CategoriesHelper.php | 56 +++++++++++++++++++++++ src/Generators/Heureka/Item.php | 4 +- src/Generators/Heureka/Parameter.php | 13 +++++- src/Generators/Heureka/latte/item.latte | 1 + 4 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 src/Generators/Glami/CategoriesHelper.php diff --git a/src/Generators/Glami/CategoriesHelper.php b/src/Generators/Glami/CategoriesHelper.php new file mode 100644 index 0000000..6a29324 --- /dev/null +++ b/src/Generators/Glami/CategoriesHelper.php @@ -0,0 +1,56 @@ +cache = new Cache($storage, __CLASS__); + } + } + + public function getCategories() + { + $categories = array(); + if (!$this->cache || !($categories = $this->cache->load('categories'))) { + $xml = file_get_contents(self::CATEGORY_URL); + $dom = new \DOMDocument(); + + $dom->loadXML($xml); + $xpath = new \DOMXPath($dom); + /** @var \DOMElement[] $_categories */ + $_categories = $xpath->query(".//CATEGORY"); + + foreach ($_categories as $category) { + $categoryIdElement = $xpath->query($category->getNodePath().'/CATEGORY_ID'); + $id = isset($categoryIdElement[0]) ? (int)$categoryIdElement[0]->nodeValue : null; + + $categoryFullNameElement = $xpath->query($category->getNodePath().'/CATEGORY_FULLNAME'); + $_cat = isset($categoryFullNameElement[0]) ? (string)$categoryFullNameElement[0]->nodeValue : null; + + if($id && $_cat) { + $_cat = str_replace('Glami.cz | ', '', $_cat); + $categories[$id] = $_cat; + } + } + + asort($categories); + + if ($this->cache) { + $this->cache->save('categories', $categories); + } + } + + return $categories; + } +} \ No newline at end of file diff --git a/src/Generators/Heureka/Item.php b/src/Generators/Heureka/Item.php index 6a7b176..ed6e19d 100644 --- a/src/Generators/Heureka/Item.php +++ b/src/Generators/Heureka/Item.php @@ -152,9 +152,9 @@ public function getDeliveries() * @param null $unit * @return Item */ - public function addParameter($name, $val, $unit = null) + public function addParameter($name, $val, $unit = null, $percentage = null) { - $this->parameters[] = new Parameter($name, $val, $unit); + $this->parameters[] = new Parameter($name, $val, $unit, $percentage); return $this; } diff --git a/src/Generators/Heureka/Parameter.php b/src/Generators/Heureka/Parameter.php index f42e1f5..7e405cc 100644 --- a/src/Generators/Heureka/Parameter.php +++ b/src/Generators/Heureka/Parameter.php @@ -17,6 +17,7 @@ class Parameter { protected $name; protected $value; protected $unit; + protected $percentage; /** * Parameter constructor. @@ -24,12 +25,13 @@ class Parameter { * @param $value * @param $unit */ - public function __construct($name, $value, $unit = null) + public function __construct($name, $value, $unit = null, $percentage = null) { $this->name = $name; $this->value = $value; $this->unit = $unit; + $this->percentage = $percentage; } /** @@ -55,5 +57,14 @@ public function getUnit() { return $this->unit; } + /** + * @return null + */ + public function getPercentage() { + return $this->percentage; + } + + + } diff --git a/src/Generators/Heureka/latte/item.latte b/src/Generators/Heureka/latte/item.latte index 06bdd3d..5fdc0ea 100644 --- a/src/Generators/Heureka/latte/item.latte +++ b/src/Generators/Heureka/latte/item.latte @@ -20,6 +20,7 @@ {$parameter->getName()} {$parameter->getValue()}{$parameter->getUnit()} + {$parameter->getPercentage()}% {/if} From 67c89efb2dca0cf0802fcd37ee7ce8e162b9cbe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 19 Jul 2019 10:08:01 +0200 Subject: [PATCH 28/52] Added Heureka Availability --- .../HeurekaAvailability/CategoriesHelper.php | 77 +++ .../HeurekaAvailability/Delivery.php | 123 ++++ src/Generators/HeurekaAvailability/Depot.php | 55 ++ .../HeurekaAvailability/Generator.php | 24 + src/Generators/HeurekaAvailability/Gift.php | 38 ++ src/Generators/HeurekaAvailability/Image.php | 40 ++ src/Generators/HeurekaAvailability/Item.php | 543 ++++++++++++++++++ .../HeurekaAvailability/Parameter.php | 70 +++ .../HeurekaAvailability/latte/footer.latte | 1 + .../HeurekaAvailability/latte/header.latte | 2 + .../HeurekaAvailability/latte/item.latte | 11 + 11 files changed, 984 insertions(+) create mode 100644 src/Generators/HeurekaAvailability/CategoriesHelper.php create mode 100644 src/Generators/HeurekaAvailability/Delivery.php create mode 100644 src/Generators/HeurekaAvailability/Depot.php create mode 100644 src/Generators/HeurekaAvailability/Generator.php create mode 100644 src/Generators/HeurekaAvailability/Gift.php create mode 100644 src/Generators/HeurekaAvailability/Image.php create mode 100644 src/Generators/HeurekaAvailability/Item.php create mode 100644 src/Generators/HeurekaAvailability/Parameter.php create mode 100644 src/Generators/HeurekaAvailability/latte/footer.latte create mode 100644 src/Generators/HeurekaAvailability/latte/header.latte create mode 100644 src/Generators/HeurekaAvailability/latte/item.latte diff --git a/src/Generators/HeurekaAvailability/CategoriesHelper.php b/src/Generators/HeurekaAvailability/CategoriesHelper.php new file mode 100644 index 0000000..2d55a78 --- /dev/null +++ b/src/Generators/HeurekaAvailability/CategoriesHelper.php @@ -0,0 +1,77 @@ +cache = new Cache($storage, __CLASS__); + } + $this->sk = false; + } + + /** + * @param bool $sk + * @return CategoriesHelper + */ + public function setSk(bool $sk): CategoriesHelper { + $this->sk = $sk; + return $this; + } + + + + + public function getCategories() + { + $categories = array(); + if (!$this->cache || !($categories = $this->cache->load('categories'))) { + if ($this->sk) { + $xml = file_get_contents(self::CATEGORY_SK_URL); + } else { + $xml = file_get_contents(self::CATEGORY_URL); + } + $dom = new \DOMDocument(); + + $dom->loadXML($xml); + $xpath = new \DOMXPath($dom); + /** @var \DOMElement[] $_categories */ + $_categories = $xpath->query(".//CATEGORY"); + + foreach ($_categories as $category) { + $categoryIdElement = $xpath->query($category->getNodePath().'/CATEGORY_ID'); + $id = isset($categoryIdElement[0]) ? (int)$categoryIdElement[0]->nodeValue : null; + + $categoryFullNameElement = $xpath->query($category->getNodePath().'/CATEGORY_FULLNAME'); + $_cat = isset($categoryFullNameElement[0]) ? (string)$categoryFullNameElement[0]->nodeValue : null; + + if($id && $_cat) { + $_cat = str_replace('Heureka.cz | ', '', $_cat); + $categories[$id] = $_cat; + } + } + + asort($categories); + + if ($this->cache) { + $this->cache->save('categories', $categories); + } + } + + return $categories; + } +} \ No newline at end of file diff --git a/src/Generators/HeurekaAvailability/Delivery.php b/src/Generators/HeurekaAvailability/Delivery.php new file mode 100644 index 0000000..e3e1d7d --- /dev/null +++ b/src/Generators/HeurekaAvailability/Delivery.php @@ -0,0 +1,123 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Delivery{ + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + CONST CESKA_POSTA = 'CESKA_POSTA', + CESKA_POSTA_NA_POSTU = 'CESKA_POSTA_NA_POSTU', + CESKA_POSTA_DOPORUCENA_ZASILKA = 'CESKA_POSTA_DOPORUCENA_ZASILKA', + CSAD_LOGISTIK_OSTRAVA = 'CSAD_LOGISTIK_OSTRAVA', + DPD = 'DPD', + DHL = 'DHL', + DSV = 'DSV', + EMS = 'EMS', + FOFR = 'FOFR', + GEBRUDER_WEISS = 'GEBRUDER_WEISS', + GEIS = 'GEIS', + GENERAL_PARCEL = 'GENERAL_PARCEL', + GLS = 'GLS', + HDS = 'HDS', + HEUREKAPOINT = 'HEUREKAPOINT', + INTIME = 'INTIME', + PPL = 'PPL', + RADIALKA = 'RADIALKA', + SEEGMULLER = 'SEEGMULLER', + TNT = 'TNT', + TOPTRANS = 'TOPTRANS', + UPS = 'UPS', + ULOZENKA = 'ULOZENKA', + VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA', + ZASILKOVNA = 'ZASILKOVNA', + + SLOVENSKA_POSTA = 'SLOVENSKA_POSTA'; + + + static $ids = array( + self::CESKA_POSTA, + self::CESKA_POSTA_NA_POSTU, + self::CESKA_POSTA_DOPORUCENA_ZASILKA, + self::CSAD_LOGISTIK_OSTRAVA, + self::DPD, + self::DHL, + self::DSV, + self::EMS, + self::FOFR, + self::GEBRUDER_WEISS, + self::GEIS, + self::GENERAL_PARCEL, + self::GLS, + self::HDS, + self::HEUREKAPOINT, + self::INTIME, + self::PPL, + self::RADIALKA, + self::SEEGMULLER, + self::TNT, + self::TOPTRANS, + self::UPS, + self::ULOZENKA, + self::VLASTNI_PREPRAVA, + self::ZASILKOVNA, + + self::SLOVENSKA_POSTA, + ); + + /** @var string */ + private $id; + /** @var float */ + private $price; + /** @var float|null */ + private $priceCod; + + /** + * Delivery constructor. + * @param $id + * @param $price + * @param null $priceCod + */ + public function __construct($id, $price, $priceCod = null) + { + if (!in_array($id, self::$ids)) { + throw new \InvalidArgumentException("Delivery with id $id doesn\t exist"); + } + $this->id = (string) $id; + $this->price = (float) $price; + $this->priceCod = isset($priceCod) ? (float) $priceCod : null; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return float + */ + public function getPrice() + { + return $this->price; + } + + /** + * @return float|null + */ + public function getPriceCod() + { + return $this->priceCod; + } + +} diff --git a/src/Generators/HeurekaAvailability/Depot.php b/src/Generators/HeurekaAvailability/Depot.php new file mode 100644 index 0000000..e4b6707 --- /dev/null +++ b/src/Generators/HeurekaAvailability/Depot.php @@ -0,0 +1,55 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Depot +{ + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + + + /** @var string */ + private $id; + /** + * @var int + */ + private $stock; + + /** + * Image constructor. + * @param string $url + */ + public function __construct($id, int $stock) + { + $this->id = $id; + $this->stock = $stock; + } + + /** + * @return string + */ + public function getId(): string { + return $this->id; + } + + /** + * @return int + */ + public function getStock(): int { + return $this->stock; + } + + + + + +} diff --git a/src/Generators/HeurekaAvailability/Generator.php b/src/Generators/HeurekaAvailability/Generator.php new file mode 100644 index 0000000..f65b1ad --- /dev/null +++ b/src/Generators/HeurekaAvailability/Generator.php @@ -0,0 +1,24 @@ + + * @package Mk\Feed\Generators + * @see http://sluzby.heureka.cz/napoveda/xml-feed/ Documentation + */ +abstract class Generator extends BaseGenerator { + + /** + * @param $name + * @return string + */ + protected function getTemplate($name) + { + $reflection = new \ReflectionClass(__CLASS__); + return dirname($reflection->getFileName()) . '/latte/' . $name . '.latte'; + } + +} \ No newline at end of file diff --git a/src/Generators/HeurekaAvailability/Gift.php b/src/Generators/HeurekaAvailability/Gift.php new file mode 100644 index 0000000..14a4852 --- /dev/null +++ b/src/Generators/HeurekaAvailability/Gift.php @@ -0,0 +1,38 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Gift { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + /** @var string */ + protected $name; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Gift constructor. + * @param $name + */ + public function __construct($name) + { + + $this->name = (string)$name; + } + +} diff --git a/src/Generators/HeurekaAvailability/Image.php b/src/Generators/HeurekaAvailability/Image.php new file mode 100644 index 0000000..64416fa --- /dev/null +++ b/src/Generators/HeurekaAvailability/Image.php @@ -0,0 +1,40 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Image +{ + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + /** @var string */ + private $url; + + /** + * Image constructor. + * @param string $url + */ + public function __construct($url) + { + $this->url = (string) $url; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + + +} diff --git a/src/Generators/HeurekaAvailability/Item.php b/src/Generators/HeurekaAvailability/Item.php new file mode 100644 index 0000000..d11d444 --- /dev/null +++ b/src/Generators/HeurekaAvailability/Item.php @@ -0,0 +1,543 @@ + + * @package Mk\Feed\Generators\Heureka + * @see http://sluzby.heureka.cz/napoveda/xml-feed/ Documentation + */ +class Item extends BaseItem { + + /** @var string @required */ + protected $itemId; + + /** @var string @required */ + protected $productName; + + /** @var string|null */ + protected $product; + + /** @var string @required */ + protected $description; + + /** @var string @required */ + protected $url; + + /** @var Image[] */ + protected $images = array(); + + /** @var Depot[] */ + protected $depots = []; + + /** @var string|null */ + protected $videoUrl; + + /** @var float @required */ + protected $priceVat; + + /** @var string|null */ + protected $itemType; + + /** @var Parameter[] */ + protected $parameters = array(); + + /** @var string|null */ + protected $manufacturer; + + /** @var string|null */ + protected $categoryText; + + /** @var string|null */ + protected $ean; + + /** @var string|null */ + protected $isbn; + + /** @var float|null */ + protected $heurekaCpc; + + /** @var \DateTime|int @required */ + protected $deliveryDate; + + /** @var Delivery[] */ + protected $deliveries = array(); + + /** @var string|null */ + protected $itemGroupId; + + /** @var array */ + protected $accessories = array(); + + /** @var float */ + protected $dues = 0; + + /** @var Gift[] */ + protected $gifts = array(); + + /** @var int */ + protected $stock; + + /** @var \DateTime */ + protected $orderDeadline; + + /** @var \DateTime */ + protected $orderDeliveryTime; + + /** + * @return float + */ + public function getDues() + { + return $this->dues; + } + + /** + * @param float $dues + * @return Item + */ + public function setDues($dues) + { + $this->dues = (float)$dues; + + return $this; + } + + /** + * @return string + */ + public function getVideoUrl() + { + return $this->videoUrl; + } + + /** + * @param string $videoUrl + * @return $this + */ + public function setVideoUrl($videoUrl) + { + $this->videoUrl = $videoUrl; + + return $this; + } + + /** + * @param $url + * @return $this + */ + public function addImage($url) + { + $this->images[] = new Image($url); + + return $this; + } + + public function addDepot($id, $stock) { + $this->depots[] = new Depot($id, $stock); + + return $this; + } + + /** + * @param $id + * @param $price + * @param null $priceCod + * @return $this + */ + public function addDelivery($id, $price, $priceCod = null) + { + $this->deliveries[] = new Delivery($id, $price, $priceCod); + + return $this; + } + + /** + * @return Delivery[] + */ + public function getDeliveries() + { + return $this->deliveries; + } + + /** + * @param $name + * @param $val + * @param null $unit + * @return Item + */ + public function addParameter($name, $val, $unit = null, $percentage = null) + { + $this->parameters[] = new Parameter($name, $val, $unit, $percentage); + + return $this; + } + + /** + * @param $name + * @return $this + */ + public function addGift($name) + { + $this->gifts[] = new Gift($name); + + return $this; + } + + /** + * @param $itemId + * @return $this + */ + public function addAccessory($itemId) + { + $this->accessories[] = $itemId; + + return $this; + } + + /** + * @return array + */ + public function getAccessories() + { + return $this->accessories; + } + + /** + * @return string + */ + public function getProductName() + { + return $this->productName; + } + + /** + * @param string $productName + * @return Item + */ + public function setProductName($productName) + { + $this->productName = (string)$productName; + + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + * @return Item + */ + public function setDescription($description) + { + $this->description = (string)$description; + + return $this; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + * @return Item + */ + public function setUrl($url) + { + $this->url = (string)$url; + + return $this; + } + + /** + * @return float + */ + public function getPriceVat() + { + return $this->priceVat; + } + + /** + * @param float $priceVat + * @return Item + */ + public function setPriceVat($priceVat) + { + $this->priceVat = (float)$priceVat; + + return $this; + } + + /** + * @return int|string + */ + public function getDeliveryDate() + { + return $this->deliveryDate instanceof \DateTime ? $this->deliveryDate->format('Y-m-d') : $this->deliveryDate; + } + + /** + * @param int|\DateTime $deliveryDate + * @return Item + */ + public function setDeliveryDate($deliveryDate) + { + if (!is_int($deliveryDate) && !($deliveryDate instanceof \DateTime)) { + throw new \InvalidArgumentException("Delivery date must be integer or DateTime"); + } + $this->deliveryDate = $deliveryDate; + + return $this; + } + + /** + * @return null|string + */ + public function getItemId() + { + return $this->itemId; + } + + /** + * @param null|string $itemId + * @return Item + */ + public function setItemId($itemId) + { + $this->itemId = $itemId; + + return $this; + } + + /** + * @return null|string + */ + public function getEan() + { + return $this->ean; + } + + /** + * @param null|string $ean + * @return Item + */ + public function setEan($ean) + { + $this->ean = $ean; + + return $this; + } + + /** + * @return null|string + */ + public function getIsbn() + { + return $this->isbn; + } + + /** + * @param null|string $isbn + * @return Item + */ + public function setIsbn($isbn) + { + $this->isbn = $isbn; + + return $this; + } + + /** + * @return null|string + */ + public function getItemGroupId() + { + return $this->itemGroupId; + } + + /** + * @param null|string $itemGroupId + * @return Item + */ + public function setItemGroupId($itemGroupId) + { + $this->itemGroupId = $itemGroupId; + + return $this; + } + + /** + * @return null|string + */ + public function getManufacturer() + { + return $this->manufacturer; + } + + /** + * @param null|string $manufacturer + * @return Item + */ + public function setManufacturer($manufacturer) + { + $this->manufacturer = $manufacturer; + + return $this; + } + + /** + * @return null|string + */ + public function getCategoryText() + { + return $this->categoryText; + } + + /** + * @param null|string $categoryText + * @return Item + */ + public function setCategoryText($categoryText) + { + $this->categoryText = $categoryText; + + return $this; + } + + /** + * @return null|string + */ + public function getProduct() + { + return $this->product; + } + + /** + * @param null|string $product + * @return Item + */ + public function setProduct($product) + { + $this->product = $product; + + return $this; + } + + /** + * @return null|string + */ + public function getItemType() + { + return $this->itemType; + } + + /** + * @return Image[] + */ + public function getImages() + { + return $this->images; + } + + /** + * @return Gift[] + */ + public function getGifts() + { + return $this->gifts; + } + + /** + * @return Parameter[] + */ + public function getParameters() + { + return $this->parameters; + } + + /** + * @return null|string + */ + public function getHeurekaCpc() + { + return $this->heurekaCpc; + } + + /** + * @param null|string $heurekaCpc + * @return $this + */ + public function setHeurekaCpc($heurekaCpc) + { + $this->heurekaCpc = $heurekaCpc; + + return $this; + } + + /** + * @return int + */ + public function getStock(): int { + return $this->stock; + } + + /** + * @param int $stock + * @return Item + */ + public function setStock(int $stock): Item { + $this->stock = $stock; + return $this; + } + + /** + * @return \DateTime + */ + public function getOrderDeadline(): \DateTime { + return $this->orderDeadline; + } + + /** + * @param \DateTime $orderDeadline + * @return Item + */ + public function setOrderDeadline(\DateTime $orderDeadline): Item { + $this->orderDeadline = $orderDeadline; + return $this; + } + + /** + * @return \DateTime + */ + public function getOrderDeliveryTime(): \DateTime { + return $this->orderDeliveryTime; + } + + /** + * @param \DateTime $orderDeliveryTime + * @return Item + */ + public function setOrderDeliveryTime(\DateTime $orderDeliveryTime): Item { + $this->orderDeliveryTime = $orderDeliveryTime; + return $this; + } + + + + +} diff --git a/src/Generators/HeurekaAvailability/Parameter.php b/src/Generators/HeurekaAvailability/Parameter.php new file mode 100644 index 0000000..7e405cc --- /dev/null +++ b/src/Generators/HeurekaAvailability/Parameter.php @@ -0,0 +1,70 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Parameter { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + protected $name; + protected $value; + protected $unit; + protected $percentage; + + /** + * Parameter constructor. + * @param $name + * @param $value + * @param $unit + */ + public function __construct($name, $value, $unit = null, $percentage = null) + { + $this->name = $name; + $this->value = $value; + + $this->unit = $unit; + $this->percentage = $percentage; + } + + /** + * @return mixed + */ + public function getName() + { + return $this->name; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @return mixed + */ + public function getUnit() { + return $this->unit; + } + + /** + * @return null + */ + public function getPercentage() { + return $this->percentage; + } + + + + +} diff --git a/src/Generators/HeurekaAvailability/latte/footer.latte b/src/Generators/HeurekaAvailability/latte/footer.latte new file mode 100644 index 0000000..5cfd1ab --- /dev/null +++ b/src/Generators/HeurekaAvailability/latte/footer.latte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Generators/HeurekaAvailability/latte/header.latte b/src/Generators/HeurekaAvailability/latte/header.latte new file mode 100644 index 0000000..900cb04 --- /dev/null +++ b/src/Generators/HeurekaAvailability/latte/header.latte @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/Generators/HeurekaAvailability/latte/item.latte b/src/Generators/HeurekaAvailability/latte/item.latte new file mode 100644 index 0000000..affa290 --- /dev/null +++ b/src/Generators/HeurekaAvailability/latte/item.latte @@ -0,0 +1,11 @@ +{contentType xml} + + + {$item->getStock()()} + {$item->getOrderDeliveryTime()|date:'Y-m-d H:i'} + + {$depot->getStock()} + + + + From 40f6dca4ba1ac9c93b8f94707d1db090968964e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 19 Jul 2019 11:46:01 +0200 Subject: [PATCH 29/52] Fixes namespaces --- .../HeurekaAvailability/CategoriesHelper.php | 2 +- .../HeurekaAvailability/Delivery.php | 2 +- src/Generators/HeurekaAvailability/Depot.php | 2 +- .../HeurekaAvailability/Generator.php | 2 +- src/Generators/HeurekaAvailability/Image.php | 2 +- src/Generators/HeurekaAvailability/Item.php | 8 ++++++++ .../HeurekaAvailability/Parameter.php | 2 +- .../HeurekaAvailability/latte/footer.latte | 2 +- .../HeurekaAvailability/latte/header.latte | 2 +- .../HeurekaAvailability/latte/item.latte | 18 +++++++++--------- 10 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/Generators/HeurekaAvailability/CategoriesHelper.php b/src/Generators/HeurekaAvailability/CategoriesHelper.php index 2d55a78..dd57848 100644 --- a/src/Generators/HeurekaAvailability/CategoriesHelper.php +++ b/src/Generators/HeurekaAvailability/CategoriesHelper.php @@ -1,6 +1,6 @@ depots; + } + + diff --git a/src/Generators/HeurekaAvailability/Parameter.php b/src/Generators/HeurekaAvailability/Parameter.php index 7e405cc..fe14bcd 100644 --- a/src/Generators/HeurekaAvailability/Parameter.php +++ b/src/Generators/HeurekaAvailability/Parameter.php @@ -1,6 +1,6 @@ \ No newline at end of file + \ No newline at end of file diff --git a/src/Generators/HeurekaAvailability/latte/header.latte b/src/Generators/HeurekaAvailability/latte/header.latte index 900cb04..1ca57df 100644 --- a/src/Generators/HeurekaAvailability/latte/header.latte +++ b/src/Generators/HeurekaAvailability/latte/header.latte @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/Generators/HeurekaAvailability/latte/item.latte b/src/Generators/HeurekaAvailability/latte/item.latte index affa290..e6ed797 100644 --- a/src/Generators/HeurekaAvailability/latte/item.latte +++ b/src/Generators/HeurekaAvailability/latte/item.latte @@ -1,11 +1,11 @@ {contentType xml} - - - {$item->getStock()()} - {$item->getOrderDeliveryTime()|date:'Y-m-d H:i'} - - {$depot->getStock()} - - - + + {$item->getStock()} + {$item->getOrderDeliveryTime()|date:'Y-m-d H:i'} + + {$depot->getStock()} + + + From d296548344bfc9e19483e2fc8d7d6fbc0c8ecfb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 19 Jul 2019 12:10:46 +0200 Subject: [PATCH 30/52] Added SK posta --- src/Generators/Zbozi/Delivery.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Generators/Zbozi/Delivery.php b/src/Generators/Zbozi/Delivery.php index 47b52a9..a79d790 100644 --- a/src/Generators/Zbozi/Delivery.php +++ b/src/Generators/Zbozi/Delivery.php @@ -17,6 +17,7 @@ class Delivery{ CONST CESKA_POSTA = 'CESKA_POSTA', CESKA_POSTA_NA_POSTU = 'CESKA_POSTA_NA_POSTU', CSAD_LOGISTIK_OSTRAVA = 'CSAD_LOGISTIK_OSTRAVA', + SLOVENSKA_POSTA = 'SLOVENSKA_POSTA', DPD = 'DPD', DHL = 'DHL', DSV = 'DSV', @@ -64,6 +65,7 @@ class Delivery{ self::ULOZENKA, self::VLASTNI_PREPRAVA, self::ZASILKOVNA, + self::SLOVENSKA_POSTA, ); /** @var string */ From b49d7b824be839a27d6150b01cdeaa2ff1d90417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 20 Aug 2019 08:00:32 +0200 Subject: [PATCH 31/52] Update composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 8bffc04..a669c7b 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,9 @@ "require": { "php": ">=5.6", - "nette/di": "~2.4.0 || ^2.5.0", - "nette/utils": "~2.4.0 || ^2.5.0", - "latte/latte": "~2.4.0", + "nette/di": "~2.4.0 || ^2.5.0 || ^3.0.0", + "nette/utils": "~2.4.0 || ^2.5.0 || ^3.0.0", + "latte/latte": "~2.5.0", "kdyby/console": "^2.6.0", "sergiors/importing": "1.0.1" }, From 63f9c7807e8870d81452042471411a576c8e461a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 20 Aug 2019 09:03:31 +0200 Subject: [PATCH 32/52] Fixes --- src/Generators/HeurekaAvailability/Gift.php | 2 +- src/Generators/Zbozi/Delivery.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Generators/HeurekaAvailability/Gift.php b/src/Generators/HeurekaAvailability/Gift.php index 14a4852..f95a3a2 100644 --- a/src/Generators/HeurekaAvailability/Gift.php +++ b/src/Generators/HeurekaAvailability/Gift.php @@ -1,6 +1,6 @@ Date: Tue, 20 Aug 2019 10:33:27 +0200 Subject: [PATCH 33/52] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a669c7b..212c73a 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "php": ">=5.6", "nette/di": "~2.4.0 || ^2.5.0 || ^3.0.0", "nette/utils": "~2.4.0 || ^2.5.0 || ^3.0.0", - "latte/latte": "~2.5.0", + "latte/latte": "^2.4 || ~2.5.0", "kdyby/console": "^2.6.0", "sergiors/importing": "1.0.1" }, From a76f0c21ff0277ba5d6b50e64181ace97d898535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Wed, 25 Sep 2019 08:34:22 +0200 Subject: [PATCH 34/52] Added pickup_time --- src/Generators/HeurekaAvailability/latte/item.latte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Generators/HeurekaAvailability/latte/item.latte b/src/Generators/HeurekaAvailability/latte/item.latte index e6ed797..21358ea 100644 --- a/src/Generators/HeurekaAvailability/latte/item.latte +++ b/src/Generators/HeurekaAvailability/latte/item.latte @@ -2,10 +2,10 @@ {$item->getStock()} - {$item->getOrderDeliveryTime()|date:'Y-m-d H:i'} + {$item->getOrderDeliveryTime()|date:'Y-m-d H:i'} {$depot->getStock()} + {$item->getOrderDeliveryTime()|date:'Y-m-d H:i'} From 63860eedd7a2340796af4b7a50bc530d376f6d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Wed, 25 Sep 2019 08:36:35 +0200 Subject: [PATCH 35/52] Fixed typo --- src/Generators/HeurekaAvailability/latte/item.latte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/HeurekaAvailability/latte/item.latte b/src/Generators/HeurekaAvailability/latte/item.latte index 21358ea..98d0467 100644 --- a/src/Generators/HeurekaAvailability/latte/item.latte +++ b/src/Generators/HeurekaAvailability/latte/item.latte @@ -1,7 +1,7 @@ {contentType xml} - {$item->getStock()} + {$item->getStock()} {$item->getOrderDeliveryTime()|date:'Y-m-d H:i'} {$depot->getStock()} From b850a2e51c395f7a0bafc4178a80bfdfd0ff067d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Wed, 25 Sep 2019 12:23:46 +0200 Subject: [PATCH 36/52] Added google feed currency --- src/Generators/Google/Item.php | 19 +++++++++++++++++++ src/Generators/Google/latte/item.latte | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Generators/Google/Item.php b/src/Generators/Google/Item.php index ae25608..4e1199a 100644 --- a/src/Generators/Google/Item.php +++ b/src/Generators/Google/Item.php @@ -95,6 +95,9 @@ class Item extends BaseItem { /** @var array */ protected $params; + /** @var string */ + protected $currency; + /** * @return string */ @@ -482,6 +485,22 @@ public function getParams(): array { return $this->params; } + /** + * @return string + */ + public function getCurrency(): string { + return $this->currency; + } + + /** + * @param string $currency + * @return Item + */ + public function setCurrency(string $currency): Item { + $this->currency = $currency; + return $this; + } + diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index 49c0f05..04f81c9 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -14,7 +14,7 @@ {$item->condition} {$item->availability} - {$item->price} CZK + {$item->price} {$item->currency} {$item->identifierExists ? 'TRUE' : 'FALSE'} {$item->salePrice} {if $item->gtin}{$item->gtin}{/if} From 76ab49fb03fd2f963a84e19c45ecf630f291dcdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 4 Oct 2019 08:38:26 +0200 Subject: [PATCH 37/52] Added heureka availability feed depot delivery time --- src/Generators/HeurekaAvailability/Depot.php | 53 +++++++++++++++++-- src/Generators/HeurekaAvailability/Item.php | 4 +- .../HeurekaAvailability/latte/item.latte | 2 +- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/Generators/HeurekaAvailability/Depot.php b/src/Generators/HeurekaAvailability/Depot.php index ae5a47b..bf15190 100644 --- a/src/Generators/HeurekaAvailability/Depot.php +++ b/src/Generators/HeurekaAvailability/Depot.php @@ -24,16 +24,29 @@ class Depot */ private $stock; + + + /** @var \DateTime */ + protected $orderDeadline; + + /** @var \DateTime */ + protected $orderDeliveryTime; + /** - * Image constructor. - * @param string $url + * Depot constructor. + * @param string $id + * @param int $stock + * @param \DateTime $orderDeadline + * @param \DateTime $orderDeliveryTime */ - public function __construct($id, int $stock) - { + public function __construct(string $id, int $stock, \DateTime $orderDeadline, \DateTime $orderDeliveryTime) { $this->id = $id; $this->stock = $stock; + $this->orderDeadline = $orderDeadline; + $this->orderDeliveryTime = $orderDeliveryTime; } + /** * @return string */ @@ -48,6 +61,38 @@ public function getStock(): int { return $this->stock; } + /** + * @return \DateTime + */ + public function getOrderDeadline(): \DateTime { + return $this->orderDeadline; + } + + /** + * @param \DateTime $orderDeadline + * @return Depot + */ + public function setOrderDeadline(\DateTime $orderDeadline): Depot { + $this->orderDeadline = $orderDeadline; + return $this; + } + + /** + * @return \DateTime + */ + public function getOrderDeliveryTime(): \DateTime { + return $this->orderDeliveryTime; + } + + /** + * @param \DateTime $orderDeliveryTime + * @return Depot + */ + public function setOrderDeliveryTime(\DateTime $orderDeliveryTime): Depot { + $this->orderDeliveryTime = $orderDeliveryTime; + return $this; + } + diff --git a/src/Generators/HeurekaAvailability/Item.php b/src/Generators/HeurekaAvailability/Item.php index 6c49f82..4fc9837 100644 --- a/src/Generators/HeurekaAvailability/Item.php +++ b/src/Generators/HeurekaAvailability/Item.php @@ -137,8 +137,8 @@ public function addImage($url) return $this; } - public function addDepot($id, $stock) { - $this->depots[] = new Depot($id, $stock); + public function addDepot($id, $stock, $orderDeadline, $orderDeliveryTime) { + $this->depots[] = new Depot($id, $stock, $orderDeadline, $orderDeliveryTime); return $this; } diff --git a/src/Generators/HeurekaAvailability/latte/item.latte b/src/Generators/HeurekaAvailability/latte/item.latte index 98d0467..8f3b4b6 100644 --- a/src/Generators/HeurekaAvailability/latte/item.latte +++ b/src/Generators/HeurekaAvailability/latte/item.latte @@ -5,7 +5,7 @@ {$item->getOrderDeliveryTime()|date:'Y-m-d H:i'} {$depot->getStock()} - {$item->getOrderDeliveryTime()|date:'Y-m-d H:i'} + {$depot->getOrderDeliveryTime()|date:'Y-m-d H:i'} From c5f0d362b6255dd01beb4e4ce1315350ddbbd6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Mon, 14 Oct 2019 08:03:05 +0200 Subject: [PATCH 38/52] Fixed delivery date --- src/Generators/Zbozi/latte/item.latte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/Zbozi/latte/item.latte b/src/Generators/Zbozi/latte/item.latte index cccdfe9..4fccadb 100644 --- a/src/Generators/Zbozi/latte/item.latte +++ b/src/Generators/Zbozi/latte/item.latte @@ -4,7 +4,7 @@ getDescription()|striptags|noescape}]]> {$item->getUrl()} {$item->getPriceVat()} - {$item->getDeliveryDate()} + {$item->getDeliveryDate()} {$delivery->id} {$delivery->price} From 7f9e60cc3e38ce10af8fce12b2cef95694836e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 5 Nov 2019 10:48:44 +0100 Subject: [PATCH 39/52] Added Shoptet feed --- src/Generators/Shoptet/CategoriesHelper.php | 77 ++++ src/Generators/Shoptet/Delivery.php | 123 +++++ src/Generators/Shoptet/Generator.php | 24 + src/Generators/Shoptet/Gift.php | 38 ++ src/Generators/Shoptet/Image.php | 40 ++ src/Generators/Shoptet/Item.php | 474 ++++++++++++++++++++ src/Generators/Shoptet/Parameter.php | 70 +++ src/Generators/Shoptet/latte/footer.latte | 1 + src/Generators/Shoptet/latte/header.latte | 2 + src/Generators/Shoptet/latte/item.latte | 52 +++ 10 files changed, 901 insertions(+) create mode 100644 src/Generators/Shoptet/CategoriesHelper.php create mode 100644 src/Generators/Shoptet/Delivery.php create mode 100644 src/Generators/Shoptet/Generator.php create mode 100644 src/Generators/Shoptet/Gift.php create mode 100644 src/Generators/Shoptet/Image.php create mode 100644 src/Generators/Shoptet/Item.php create mode 100644 src/Generators/Shoptet/Parameter.php create mode 100644 src/Generators/Shoptet/latte/footer.latte create mode 100644 src/Generators/Shoptet/latte/header.latte create mode 100644 src/Generators/Shoptet/latte/item.latte diff --git a/src/Generators/Shoptet/CategoriesHelper.php b/src/Generators/Shoptet/CategoriesHelper.php new file mode 100644 index 0000000..bd26d24 --- /dev/null +++ b/src/Generators/Shoptet/CategoriesHelper.php @@ -0,0 +1,77 @@ +cache = new Cache($storage, __CLASS__); + } + $this->sk = false; + } + + /** + * @param bool $sk + * @return CategoriesHelper + */ + public function setSk(bool $sk): CategoriesHelper { + $this->sk = $sk; + return $this; + } + + + + + public function getCategories() + { + $categories = array(); + if (!$this->cache || !($categories = $this->cache->load('categories'))) { + if ($this->sk) { + $xml = file_get_contents(self::CATEGORY_SK_URL); + } else { + $xml = file_get_contents(self::CATEGORY_URL); + } + $dom = new \DOMDocument(); + + $dom->loadXML($xml); + $xpath = new \DOMXPath($dom); + /** @var \DOMElement[] $_categories */ + $_categories = $xpath->query(".//CATEGORY"); + + foreach ($_categories as $category) { + $categoryIdElement = $xpath->query($category->getNodePath().'/CATEGORY_ID'); + $id = isset($categoryIdElement[0]) ? (int)$categoryIdElement[0]->nodeValue : null; + + $categoryFullNameElement = $xpath->query($category->getNodePath().'/CATEGORY_FULLNAME'); + $_cat = isset($categoryFullNameElement[0]) ? (string)$categoryFullNameElement[0]->nodeValue : null; + + if($id && $_cat) { + $_cat = str_replace('Heureka.cz | ', '', $_cat); + $categories[$id] = $_cat; + } + } + + asort($categories); + + if ($this->cache) { + $this->cache->save('categories', $categories); + } + } + + return $categories; + } +} \ No newline at end of file diff --git a/src/Generators/Shoptet/Delivery.php b/src/Generators/Shoptet/Delivery.php new file mode 100644 index 0000000..ff7afec --- /dev/null +++ b/src/Generators/Shoptet/Delivery.php @@ -0,0 +1,123 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Delivery{ + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + CONST CESKA_POSTA = 'CESKA_POSTA', + CESKA_POSTA_NA_POSTU = 'CESKA_POSTA_NA_POSTU', + CESKA_POSTA_DOPORUCENA_ZASILKA = 'CESKA_POSTA_DOPORUCENA_ZASILKA', + CSAD_LOGISTIK_OSTRAVA = 'CSAD_LOGISTIK_OSTRAVA', + DPD = 'DPD', + DHL = 'DHL', + DSV = 'DSV', + EMS = 'EMS', + FOFR = 'FOFR', + GEBRUDER_WEISS = 'GEBRUDER_WEISS', + GEIS = 'GEIS', + GENERAL_PARCEL = 'GENERAL_PARCEL', + GLS = 'GLS', + HDS = 'HDS', + HEUREKAPOINT = 'HEUREKAPOINT', + INTIME = 'INTIME', + PPL = 'PPL', + RADIALKA = 'RADIALKA', + SEEGMULLER = 'SEEGMULLER', + TNT = 'TNT', + TOPTRANS = 'TOPTRANS', + UPS = 'UPS', + ULOZENKA = 'ULOZENKA', + VLASTNI_PREPRAVA = 'VLASTNI_PREPRAVA', + ZASILKOVNA = 'ZASILKOVNA', + + SLOVENSKA_POSTA = 'SLOVENSKA_POSTA'; + + + static $ids = array( + self::CESKA_POSTA, + self::CESKA_POSTA_NA_POSTU, + self::CESKA_POSTA_DOPORUCENA_ZASILKA, + self::CSAD_LOGISTIK_OSTRAVA, + self::DPD, + self::DHL, + self::DSV, + self::EMS, + self::FOFR, + self::GEBRUDER_WEISS, + self::GEIS, + self::GENERAL_PARCEL, + self::GLS, + self::HDS, + self::HEUREKAPOINT, + self::INTIME, + self::PPL, + self::RADIALKA, + self::SEEGMULLER, + self::TNT, + self::TOPTRANS, + self::UPS, + self::ULOZENKA, + self::VLASTNI_PREPRAVA, + self::ZASILKOVNA, + + self::SLOVENSKA_POSTA, + ); + + /** @var string */ + private $id; + /** @var float */ + private $price; + /** @var float|null */ + private $priceCod; + + /** + * Delivery constructor. + * @param $id + * @param $price + * @param null $priceCod + */ + public function __construct($id, $price, $priceCod = null) + { + if (!in_array($id, self::$ids)) { + throw new \InvalidArgumentException("Delivery with id $id doesn\t exist"); + } + $this->id = (string) $id; + $this->price = (float) $price; + $this->priceCod = isset($priceCod) ? (float) $priceCod : null; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return float + */ + public function getPrice() + { + return $this->price; + } + + /** + * @return float|null + */ + public function getPriceCod() + { + return $this->priceCod; + } + +} diff --git a/src/Generators/Shoptet/Generator.php b/src/Generators/Shoptet/Generator.php new file mode 100644 index 0000000..f9b533a --- /dev/null +++ b/src/Generators/Shoptet/Generator.php @@ -0,0 +1,24 @@ + + * @package Mk\Feed\Generators + * @see http://sluzby.heureka.cz/napoveda/xml-feed/ Documentation + */ +abstract class Generator extends BaseGenerator { + + /** + * @param $name + * @return string + */ + protected function getTemplate($name) + { + $reflection = new \ReflectionClass(__CLASS__); + return dirname($reflection->getFileName()) . '/latte/' . $name . '.latte'; + } + +} \ No newline at end of file diff --git a/src/Generators/Shoptet/Gift.php b/src/Generators/Shoptet/Gift.php new file mode 100644 index 0000000..1202edb --- /dev/null +++ b/src/Generators/Shoptet/Gift.php @@ -0,0 +1,38 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Gift { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + /** @var string */ + protected $name; + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Gift constructor. + * @param $name + */ + public function __construct($name) + { + + $this->name = (string)$name; + } + +} diff --git a/src/Generators/Shoptet/Image.php b/src/Generators/Shoptet/Image.php new file mode 100644 index 0000000..8f84dd6 --- /dev/null +++ b/src/Generators/Shoptet/Image.php @@ -0,0 +1,40 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Image +{ + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + /** @var string */ + private $url; + + /** + * Image constructor. + * @param string $url + */ + public function __construct($url) + { + $this->url = (string) $url; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + + +} diff --git a/src/Generators/Shoptet/Item.php b/src/Generators/Shoptet/Item.php new file mode 100644 index 0000000..c059e3b --- /dev/null +++ b/src/Generators/Shoptet/Item.php @@ -0,0 +1,474 @@ + + * @package Mk\Feed\Generators\Heureka + * @see http://sluzby.heureka.cz/napoveda/xml-feed/ Documentation + */ +class Item extends BaseItem { + + /** @var string @required */ + protected $itemId; + + /** @var string @required */ + protected $productName; + + /** @var string|null */ + protected $product; + + /** @var string @required */ + protected $description; + + /** @var string @required */ + protected $url; + + /** @var Image[] */ + protected $images = array(); + + /** @var string|null */ + protected $videoUrl; + + /** @var float @required */ + protected $priceVat; + + /** @var string|null */ + protected $itemType; + + /** @var Parameter[] */ + protected $parameters = array(); + + /** @var string|null */ + protected $manufacturer; + + /** @var string|null */ + protected $categoryText; + + /** @var string|null */ + protected $ean; + + /** @var string|null */ + protected $isbn; + + /** @var float|null */ + protected $heurekaCpc; + + /** @var \DateTime|int @required */ + protected $deliveryDate; + + /** @var Delivery[] */ + protected $deliveries = array(); + + /** @var string|null */ + protected $itemGroupId; + + /** @var array */ + protected $accessories = array(); + + /** @var float */ + protected $dues = 0; + + /** @var Gift[] */ + protected $gifts = array(); + + /** + * @return float + */ + public function getDues() + { + return $this->dues; + } + + /** + * @param float $dues + * @return Item + */ + public function setDues($dues) + { + $this->dues = (float)$dues; + + return $this; + } + + /** + * @return string + */ + public function getVideoUrl() + { + return $this->videoUrl; + } + + /** + * @param string $videoUrl + * @return $this + */ + public function setVideoUrl($videoUrl) + { + $this->videoUrl = $videoUrl; + + return $this; + } + + /** + * @param $url + * @return $this + */ + public function addImage($url) + { + $this->images[] = new Image($url); + + return $this; + } + + /** + * @param $id + * @param $price + * @param null $priceCod + * @return $this + */ + public function addDelivery($id, $price, $priceCod = null) + { + $this->deliveries[] = new Delivery($id, $price, $priceCod); + + return $this; + } + + /** + * @return Delivery[] + */ + public function getDeliveries() + { + return $this->deliveries; + } + + /** + * @param $name + * @param $val + * @param null $unit + * @return Item + */ + public function addParameter($name, $val, $unit = null, $percentage = null) + { + $this->parameters[] = new Parameter($name, $val, $unit, $percentage); + + return $this; + } + + /** + * @param $name + * @return $this + */ + public function addGift($name) + { + $this->gifts[] = new Gift($name); + + return $this; + } + + /** + * @param $itemId + * @return $this + */ + public function addAccessory($itemId) + { + $this->accessories[] = $itemId; + + return $this; + } + + /** + * @return array + */ + public function getAccessories() + { + return $this->accessories; + } + + /** + * @return string + */ + public function getProductName() + { + return $this->productName; + } + + /** + * @param string $productName + * @return Item + */ + public function setProductName($productName) + { + $this->productName = (string)$productName; + + return $this; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @param string $description + * @return Item + */ + public function setDescription($description) + { + $this->description = (string)$description; + + return $this; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + * @return Item + */ + public function setUrl($url) + { + $this->url = (string)$url; + + return $this; + } + + /** + * @return float + */ + public function getPriceVat() + { + return $this->priceVat; + } + + /** + * @param float $priceVat + * @return Item + */ + public function setPriceVat($priceVat) + { + $this->priceVat = (float)$priceVat; + + return $this; + } + + /** + * @return int|string + */ + public function getDeliveryDate() + { + return $this->deliveryDate instanceof \DateTime ? $this->deliveryDate->format('Y-m-d') : $this->deliveryDate; + } + + /** + * @param int|\DateTime $deliveryDate + * @return Item + */ + public function setDeliveryDate($deliveryDate) + { + if (!is_int($deliveryDate) && !($deliveryDate instanceof \DateTime)) { + throw new \InvalidArgumentException("Delivery date must be integer or DateTime"); + } + $this->deliveryDate = $deliveryDate; + + return $this; + } + + /** + * @return null|string + */ + public function getItemId() + { + return $this->itemId; + } + + /** + * @param null|string $itemId + * @return Item + */ + public function setItemId($itemId) + { + $this->itemId = $itemId; + + return $this; + } + + /** + * @return null|string + */ + public function getEan() + { + return $this->ean; + } + + /** + * @param null|string $ean + * @return Item + */ + public function setEan($ean) + { + $this->ean = $ean; + + return $this; + } + + /** + * @return null|string + */ + public function getIsbn() + { + return $this->isbn; + } + + /** + * @param null|string $isbn + * @return Item + */ + public function setIsbn($isbn) + { + $this->isbn = $isbn; + + return $this; + } + + /** + * @return null|string + */ + public function getItemGroupId() + { + return $this->itemGroupId; + } + + /** + * @param null|string $itemGroupId + * @return Item + */ + public function setItemGroupId($itemGroupId) + { + $this->itemGroupId = $itemGroupId; + + return $this; + } + + /** + * @return null|string + */ + public function getManufacturer() + { + return $this->manufacturer; + } + + /** + * @param null|string $manufacturer + * @return Item + */ + public function setManufacturer($manufacturer) + { + $this->manufacturer = $manufacturer; + + return $this; + } + + /** + * @return null|string + */ + public function getCategoryText() + { + return $this->categoryText; + } + + /** + * @param null|string $categoryText + * @return Item + */ + public function setCategoryText($categoryText) + { + $this->categoryText = $categoryText; + + return $this; + } + + /** + * @return null|string + */ + public function getProduct() + { + return $this->product; + } + + /** + * @param null|string $product + * @return Item + */ + public function setProduct($product) + { + $this->product = $product; + + return $this; + } + + /** + * @return null|string + */ + public function getItemType() + { + return $this->itemType; + } + + /** + * @return Image[] + */ + public function getImages() + { + return $this->images; + } + + /** + * @return Gift[] + */ + public function getGifts() + { + return $this->gifts; + } + + /** + * @return Parameter[] + */ + public function getParameters() + { + return $this->parameters; + } + + /** + * @return null|string + */ + public function getHeurekaCpc() + { + return $this->heurekaCpc; + } + + /** + * @param null|string $heurekaCpc + * @return $this + */ + public function setHeurekaCpc($heurekaCpc) + { + $this->heurekaCpc = $heurekaCpc; + + return $this; + } + +} diff --git a/src/Generators/Shoptet/Parameter.php b/src/Generators/Shoptet/Parameter.php new file mode 100644 index 0000000..da39994 --- /dev/null +++ b/src/Generators/Shoptet/Parameter.php @@ -0,0 +1,70 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Parameter { + + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + protected $name; + protected $value; + protected $unit; + protected $percentage; + + /** + * Parameter constructor. + * @param $name + * @param $value + * @param $unit + */ + public function __construct($name, $value, $unit = null, $percentage = null) + { + $this->name = $name; + $this->value = $value; + + $this->unit = $unit; + $this->percentage = $percentage; + } + + /** + * @return mixed + */ + public function getName() + { + return $this->name; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @return mixed + */ + public function getUnit() { + return $this->unit; + } + + /** + * @return null + */ + public function getPercentage() { + return $this->percentage; + } + + + + +} diff --git a/src/Generators/Shoptet/latte/footer.latte b/src/Generators/Shoptet/latte/footer.latte new file mode 100644 index 0000000..5cfd1ab --- /dev/null +++ b/src/Generators/Shoptet/latte/footer.latte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Generators/Shoptet/latte/header.latte b/src/Generators/Shoptet/latte/header.latte new file mode 100644 index 0000000..900cb04 --- /dev/null +++ b/src/Generators/Shoptet/latte/header.latte @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/Generators/Shoptet/latte/item.latte b/src/Generators/Shoptet/latte/item.latte new file mode 100644 index 0000000..5fdc0ea --- /dev/null +++ b/src/Generators/Shoptet/latte/item.latte @@ -0,0 +1,52 @@ +{contentType xml} + + {$item->getItemId()} + getProductName()}]]> + getProduct()}]]> + getDescription()|striptags|noescape}]]> + {$item->getUrl()} + + {if !empty($images = $item->getImages())} + {foreach $images as $image} + {var tag = $iterator->first ? 'IMGURL' : 'IMGURL_ALTERNATIVE'} + <{$tag}>{$image->getUrl()} + {/foreach} + {/if} + + {$item->getVideoUrl()} + {$item->getPriceVat()} + + {if !empty($parameters = $item->getParameters())} + + {$parameter->getName()} + {$parameter->getValue()}{$parameter->getUnit()} + {$parameter->getPercentage()}% + + {/if} + + getManufacturer()}]]> + getCategoryText()}]]> + {$item->getEan()} + {$item->getIsbn()} + {$item->getHeurekaCpc()} + {$item->getDeliveryDate()} + + {if !empty($deliveries = $item->getDeliveries())} + + {$delivery->id} + {$delivery->price} + {$delivery->priceCod} + + {/if} + + {$item->getItemGroupId()} + + {if !empty($accessories = $item->getAccessories())} + {$itemId} + {/if} + + {$item->getDues()} + {if !empty($gifts = $item->getGifts())} + {$gift->name} + {/if} + From 4ea9a86757435fb6d3aa1d3108bec6d2afc2d92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 5 Nov 2019 11:46:40 +0100 Subject: [PATCH 40/52] Updated shoptet --- src/Generators/Shoptet/Item.php | 190 ++++++++++++++++++++++++ src/Generators/Shoptet/latte/item.latte | 70 ++++----- 2 files changed, 226 insertions(+), 34 deletions(-) diff --git a/src/Generators/Shoptet/Item.php b/src/Generators/Shoptet/Item.php index c059e3b..05c9689 100644 --- a/src/Generators/Shoptet/Item.php +++ b/src/Generators/Shoptet/Item.php @@ -19,18 +19,36 @@ class Item extends BaseItem { /** @var string @required */ protected $productName; + /** @var string @required */ + protected $name; + + /** @var string @required */ + protected $nameExt; + + /** @var string @required */ + protected $code; + /** @var string|null */ protected $product; /** @var string @required */ protected $description; + /** @var string @required */ + protected $shortDescription; + + /** @var string @required */ + protected $warranty; + /** @var string @required */ protected $url; /** @var Image[] */ protected $images = array(); + /** @var string[] */ + protected $categories = array(); + /** @var string|null */ protected $videoUrl; @@ -76,6 +94,18 @@ class Item extends BaseItem { /** @var Gift[] */ protected $gifts = array(); + /** @var string */ + protected $availability; + + /** @var string */ + protected $vat; + + /** @var float */ + protected $weight; + + /** @var string */ + protected $sku; + /** * @return float */ @@ -471,4 +501,164 @@ public function setHeurekaCpc($heurekaCpc) return $this; } + /** + * @return string + */ + public function getShortDescription(): string { + return $this->shortDescription; + } + + /** + * @param string $shortDescription + * @return Item + */ + public function setShortDescription(string $shortDescription): Item { + $this->shortDescription = $shortDescription; + return $this; + } + + /** + * @return string + */ + public function getWarranty(): ?string { + return $this->warranty; + } + + /** + * @param string $warranty + * @return Item + */ + public function setWarranty(string $warranty): Item { + $this->warranty = $warranty; + return $this; + } + + /** + * @return string + */ + public function getCode(): string { + return $this->code; + } + + /** + * @param string $code + * @return Item + */ + public function setCode(string $code): Item { + $this->code = $code; + return $this; + } + + public function addCategory(string $category) { + $this->categories[] = $category; + } + + /** + * @return string[] + */ + public function getCategories(): array { + return $this->categories; + } + + /** + * @return string + */ + public function getAvailability(): string { + return $this->availability; + } + + /** + * @param string $availability + * @return Item + */ + public function setAvailability(string $availability): Item { + $this->availability = $availability; + return $this; + } + + /** + * @return string + */ + public function getVat(): string { + return $this->vat; + } + + /** + * @param string $vat + * @return Item + */ + public function setVat(string $vat): Item { + $this->vat = $vat; + return $this; + } + + /** + * @return string + */ + public function getWeight(): string { + return $this->weight; + } + + /** + * @param float $weight + * @return Item + */ + public function setWeight(float $weight): Item { + $this->weight = $weight; + return $this; + } + + /** + * @return string + */ + public function getSku(): ?string { + return $this->sku; + } + + /** + * @param string $sku + * @return Item + */ + public function setSku(string $sku): Item { + $this->sku = $sku; + return $this; + } + + /** + * @return string + */ + public function getName(): ?string { + return $this->name; + } + + /** + * @param string $name + * @return Item + */ + public function setName(string $name): Item { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getNameExt(): ?string { + return $this->nameExt; + } + + /** + * @param string $nameExt + * @return Item + */ + public function setNameExt(string $nameExt): Item { + $this->nameExt = $nameExt; + return $this; + } + + + + + + } diff --git a/src/Generators/Shoptet/latte/item.latte b/src/Generators/Shoptet/latte/item.latte index 5fdc0ea..b987eef 100644 --- a/src/Generators/Shoptet/latte/item.latte +++ b/src/Generators/Shoptet/latte/item.latte @@ -3,50 +3,52 @@ {$item->getItemId()} getProductName()}]]> getProduct()}]]> - getDescription()|striptags|noescape}]]> + getShortDescription()|striptags|noescape}]]> + getDescription()|striptags|noescape}]]> {$item->getUrl()} - {if !empty($images = $item->getImages())} - {foreach $images as $image} - {var tag = $iterator->first ? 'IMGURL' : 'IMGURL_ALTERNATIVE'} - <{$tag}>{$image->getUrl()} - {/foreach} - {/if} + + + {$image->getUrl()} + + {$item->getVideoUrl()} {$item->getPriceVat()} {if !empty($parameters = $item->getParameters())} - - {$parameter->getName()} - {$parameter->getValue()}{$parameter->getUnit()} - {$parameter->getPercentage()}% - + + + {$parameter->getName()} + {$parameter->getValue()}{$parameter->getUnit()} + + {/if} + {$item->getWarranty()} + product + product getManufacturer()}]]> - getCategoryText()}]]> + + + {$category} + + {$item->getEan()} - {$item->getIsbn()} - {$item->getHeurekaCpc()} - {$item->getDeliveryDate()} - - {if !empty($deliveries = $item->getDeliveries())} - - {$delivery->id} - {$delivery->price} - {$delivery->priceCod} - - {/if} - +{* {$item->getIsbn()}*} +{* {$item->getHeurekaCpc()}*} +{* {$item->getDeliveryDate()}*} + +{* {if !empty($deliveries = $item->getDeliveries())}*} +{* *} +{* {$delivery->id}*} +{* {$delivery->price}*} +{* {$delivery->priceCod}*} +{* *} +{* {/if}*} + + {$item->getAvailability()} {$item->getItemGroupId()} - - {if !empty($accessories = $item->getAccessories())} - {$itemId} - {/if} - - {$item->getDues()} - {if !empty($gifts = $item->getGifts())} - {$gift->name} - {/if} + {$item->getWeight()} + {$item->getVat()} From e9c0ef3eab432b6b2fcca26412bb2361a97800f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 5 Nov 2019 12:03:54 +0100 Subject: [PATCH 41/52] Added variants to feed --- src/Generators/Shoptet/Item.php | 15 ++- src/Generators/Shoptet/Variant.php | 147 ++++++++++++++++++++++++ src/Generators/Shoptet/latte/item.latte | 22 +++- 3 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 src/Generators/Shoptet/Variant.php diff --git a/src/Generators/Shoptet/Item.php b/src/Generators/Shoptet/Item.php index 05c9689..195852c 100644 --- a/src/Generators/Shoptet/Item.php +++ b/src/Generators/Shoptet/Item.php @@ -103,8 +103,9 @@ class Item extends BaseItem { /** @var float */ protected $weight; - /** @var string */ - protected $sku; + /** @var Variant[] */ + protected $variants = []; + /** * @return float @@ -656,6 +657,16 @@ public function setNameExt(string $nameExt): Item { return $this; } + /** + * @return Variant[] + */ + public function getVariants(): array { + return $this->variants; + } + + public function addVariant(Variant $variant) { + $this->variants[] = $variant; + } diff --git a/src/Generators/Shoptet/Variant.php b/src/Generators/Shoptet/Variant.php new file mode 100644 index 0000000..8c7bc3f --- /dev/null +++ b/src/Generators/Shoptet/Variant.php @@ -0,0 +1,147 @@ + + * @package Mk\Feed\Generators\Heureka + */ +class Variant +{ + /* Použití smartobject viz php 7.2 to nette 2.4 */ + use \Nette\SmartObject; + + /** @var string */ + private $code; + + /** @var Parameter[] */ + protected $parameters = array(); + + /** @var string */ + protected $vat; + + /** @var float */ + protected $weight; + + /** @var float @required */ + protected $priceVat; + + /** @var string */ + protected $availability; + + /** + * @return string + */ + public function getCode(): string { + return $this->code; + } + + /** + * @param string $code + * @return Variant + */ + public function setCode(string $code): Variant { + $this->code = $code; + return $this; + } + + /** + * @return Parameter[] + */ + public function getParameters(): array { + return $this->parameters; + } + + /** + * @param Parameter[] $parameters + * @return Variant + */ + public function setParameters(array $parameters): Variant { + $this->parameters = $parameters; + return $this; + } + + /** + * @return string + */ + public function getVat(): ?string { + return $this->vat; + } + + /** + * @param string $vat + * @return Variant + */ + public function setVat(string $vat): Variant { + $this->vat = $vat; + return $this; + } + + /** + * @return float + */ + public function getWeight(): ?float { + return $this->weight; + } + + /** + * @param float $weight + * @return Variant + */ + public function setWeight(float $weight): Variant { + $this->weight = $weight; + return $this; + } + + /** + * @return float + */ + public function getPriceVat(): float { + return $this->priceVat; + } + + /** + * @param float $priceVat + * @return Variant + */ + public function setPriceVat(float $priceVat): Variant { + $this->priceVat = $priceVat; + return $this; + } + + /** + * @return string + */ + public function getAvailability(): ?string { + return $this->availability; + } + + /** + * @param string $availability + * @return Variant + */ + public function setAvailability(string $availability): Variant { + $this->availability = $availability; + return $this; + } + + /** + * @param $name + * @param $val + * @return Variant + */ + public function addParameter($name, $val) + { + $this->parameters[] = new Parameter($name, $val); + + return $this; + } + + + + +} diff --git a/src/Generators/Shoptet/latte/item.latte b/src/Generators/Shoptet/latte/item.latte index b987eef..c922d40 100644 --- a/src/Generators/Shoptet/latte/item.latte +++ b/src/Generators/Shoptet/latte/item.latte @@ -27,7 +27,7 @@ {$item->getWarranty()} product - product + {$item->getCode()} getManufacturer()}]]> @@ -51,4 +51,24 @@ {$item->getItemGroupId()} {$item->getWeight()} {$item->getVat()} + + + + {$variant->getCode()} + + {if !empty($parameters = $variant->getParameters())} + + + {$parameter->getName()} + {$parameter->getValue()}{$parameter->getUnit()} + + + {/if} + + CZK + {$variant->getVat()} + {$variant->getPriceVat()} + {$variant->getAvailability()} + + From 8ba1c4ad465db5e54c3bd4dd0be2e8591354d025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Tue, 5 Nov 2019 12:13:07 +0100 Subject: [PATCH 42/52] Fixed --- src/Generators/Shoptet/Item.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Generators/Shoptet/Item.php b/src/Generators/Shoptet/Item.php index 195852c..105b3e1 100644 --- a/src/Generators/Shoptet/Item.php +++ b/src/Generators/Shoptet/Item.php @@ -545,7 +545,7 @@ public function getCode(): string { * @param string $code * @return Item */ - public function setCode(string $code): Item { + public function setCode(?string $code): Item { $this->code = $code; return $this; } @@ -588,7 +588,7 @@ public function getVat(): string { * @param string $vat * @return Item */ - public function setVat(string $vat): Item { + public function setVat(?string $vat): Item { $this->vat = $vat; return $this; } @@ -604,7 +604,7 @@ public function getWeight(): string { * @param float $weight * @return Item */ - public function setWeight(float $weight): Item { + public function setWeight(?float $weight): Item { $this->weight = $weight; return $this; } @@ -620,7 +620,7 @@ public function getSku(): ?string { * @param string $sku * @return Item */ - public function setSku(string $sku): Item { + public function setSku(?string $sku): Item { $this->sku = $sku; return $this; } @@ -636,7 +636,7 @@ public function getName(): ?string { * @param string $name * @return Item */ - public function setName(string $name): Item { + public function setName(?string $name): Item { $this->name = $name; return $this; } From f643d6601a47317abc0d1ad0047a353ff9bdb781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 14 Nov 2019 08:57:55 +0100 Subject: [PATCH 43/52] Fixes --- src/Generators/Shoptet/Item.php | 18 +++++++++--------- src/Generators/Shoptet/Variant.php | 10 +++++----- src/Generators/Zbozi/latte/item.latte | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Generators/Shoptet/Item.php b/src/Generators/Shoptet/Item.php index 105b3e1..b6d788f 100644 --- a/src/Generators/Shoptet/Item.php +++ b/src/Generators/Shoptet/Item.php @@ -505,7 +505,7 @@ public function setHeurekaCpc($heurekaCpc) /** * @return string */ - public function getShortDescription(): string { + public function getShortDescription(): ?string { return $this->shortDescription; } @@ -513,7 +513,7 @@ public function getShortDescription(): string { * @param string $shortDescription * @return Item */ - public function setShortDescription(string $shortDescription): Item { + public function setShortDescription(?string $shortDescription): Item { $this->shortDescription = $shortDescription; return $this; } @@ -529,7 +529,7 @@ public function getWarranty(): ?string { * @param string $warranty * @return Item */ - public function setWarranty(string $warranty): Item { + public function setWarranty(?string $warranty): Item { $this->warranty = $warranty; return $this; } @@ -537,7 +537,7 @@ public function setWarranty(string $warranty): Item { /** * @return string */ - public function getCode(): string { + public function getCode(): ?string { return $this->code; } @@ -564,7 +564,7 @@ public function getCategories(): array { /** * @return string */ - public function getAvailability(): string { + public function getAvailability(): ?string { return $this->availability; } @@ -572,7 +572,7 @@ public function getAvailability(): string { * @param string $availability * @return Item */ - public function setAvailability(string $availability): Item { + public function setAvailability(?string $availability): Item { $this->availability = $availability; return $this; } @@ -580,7 +580,7 @@ public function setAvailability(string $availability): Item { /** * @return string */ - public function getVat(): string { + public function getVat(): ?string { return $this->vat; } @@ -596,7 +596,7 @@ public function setVat(?string $vat): Item { /** * @return string */ - public function getWeight(): string { + public function getWeight(): ?string { return $this->weight; } @@ -652,7 +652,7 @@ public function getNameExt(): ?string { * @param string $nameExt * @return Item */ - public function setNameExt(string $nameExt): Item { + public function setNameExt(?string $nameExt): Item { $this->nameExt = $nameExt; return $this; } diff --git a/src/Generators/Shoptet/Variant.php b/src/Generators/Shoptet/Variant.php index 8c7bc3f..0b46ede 100644 --- a/src/Generators/Shoptet/Variant.php +++ b/src/Generators/Shoptet/Variant.php @@ -36,7 +36,7 @@ class Variant /** * @return string */ - public function getCode(): string { + public function getCode(): ?string { return $this->code; } @@ -44,7 +44,7 @@ public function getCode(): string { * @param string $code * @return Variant */ - public function setCode(string $code): Variant { + public function setCode(?string $code): Variant { $this->code = $code; return $this; } @@ -76,7 +76,7 @@ public function getVat(): ?string { * @param string $vat * @return Variant */ - public function setVat(string $vat): Variant { + public function setVat(?string $vat): Variant { $this->vat = $vat; return $this; } @@ -92,7 +92,7 @@ public function getWeight(): ?float { * @param float $weight * @return Variant */ - public function setWeight(float $weight): Variant { + public function setWeight(?float $weight): Variant { $this->weight = $weight; return $this; } @@ -124,7 +124,7 @@ public function getAvailability(): ?string { * @param string $availability * @return Variant */ - public function setAvailability(string $availability): Variant { + public function setAvailability(?string $availability): Variant { $this->availability = $availability; return $this; } diff --git a/src/Generators/Zbozi/latte/item.latte b/src/Generators/Zbozi/latte/item.latte index 4fccadb..dd0d659 100644 --- a/src/Generators/Zbozi/latte/item.latte +++ b/src/Generators/Zbozi/latte/item.latte @@ -4,7 +4,7 @@ getDescription()|striptags|noescape}]]> {$item->getUrl()} {$item->getPriceVat()} - {$item->getDeliveryDate()} + {$item->getDeliveryDate()} {$delivery->id} {$delivery->price} From 49d5f25979e9b7659994f6d80a5b80ea56434e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Wed, 15 Jan 2020 21:14:52 +0100 Subject: [PATCH 44/52] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 212c73a..2b97004 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "nette/di": "~2.4.0 || ^2.5.0 || ^3.0.0", "nette/utils": "~2.4.0 || ^2.5.0 || ^3.0.0", "latte/latte": "^2.4 || ~2.5.0", - "kdyby/console": "^2.6.0", + "kdyby/console": "dev-master", "sergiors/importing": "1.0.1" }, "require-dev": { From e2bc5d954f53d51f373106b861d4b8a8cc8cf221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Wed, 15 Jan 2020 21:20:13 +0100 Subject: [PATCH 45/52] Update composer.json --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 2b97004..dbc0c9d 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,9 @@ "require": { "php": ">=5.6", - "nette/di": "~2.4.0 || ^2.5.0 || ^3.0.0", - "nette/utils": "~2.4.0 || ^2.5.0 || ^3.0.0", - "latte/latte": "^2.4 || ~2.5.0", + "nette/di": "^3.0.0", + "nette/utils": "^3.0.0", + "latte/latte": "~2.5.0", "kdyby/console": "dev-master", "sergiors/importing": "1.0.1" }, From d136c19432d07ae9f34ebb40b63252f5d8512d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 16 Jan 2020 08:38:29 +0100 Subject: [PATCH 46/52] Update composer.json --- composer.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index dbc0c9d..9e5f690 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,12 @@ ], "require": { + "php": ">=5.6", - "nette/di": "^3.0.0", - "nette/utils": "^3.0.0", - "latte/latte": "~2.5.0", - "kdyby/console": "dev-master", + "nette/di": "~2.4.0 || ^2.5.0 || ^3.0.0", + "nette/utils": "~2.4.0 || ^2.5.0 || ^3.0.0", + "latte/latte": "^2.4 || ~2.6.0", + "contributte/console": "^0.8.0", "sergiors/importing": "1.0.1" }, "require-dev": { From 82b90575a5a97b661391d80107661eabba9411ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 16 Jan 2020 09:00:35 +0100 Subject: [PATCH 47/52] Update composer.json --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9e5f690..6b80550 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,7 @@ "nette/di": "~2.4.0 || ^2.5.0 || ^3.0.0", "nette/utils": "~2.4.0 || ^2.5.0 || ^3.0.0", "latte/latte": "^2.4 || ~2.6.0", - "contributte/console": "^0.8.0", - "sergiors/importing": "1.0.1" + "contributte/console": "^0.8.0" }, "require-dev": { "nette/tester": "@dev" From accc6d7d1927d83256e5ad5853e334cc622012db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 16 Jan 2020 09:01:26 +0100 Subject: [PATCH 48/52] Update CategoriesHelper.php --- src/Generators/Zbozi/CategoriesHelper.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Generators/Zbozi/CategoriesHelper.php b/src/Generators/Zbozi/CategoriesHelper.php index 394ee4e..64a7c01 100644 --- a/src/Generators/Zbozi/CategoriesHelper.php +++ b/src/Generators/Zbozi/CategoriesHelper.php @@ -5,7 +5,6 @@ use Nette\Caching\Cache; use Nette\Caching\IStorage; -use Sergiors\Importing\Loader\Excel5FileLoader; use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\Loader\DelegatingLoader; use Symfony\Component\Config\Loader\LoaderResolver; From 0f6483586a05a1cd784bd28d89dc938a4ca92fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Fri, 17 Jan 2020 13:20:05 +0100 Subject: [PATCH 49/52] Support for nette 3 & php 7.4 --- src/Generators/Custom/Item.php | 2 + src/Generators/Custom/latte/item.latte | 8 ++-- src/Generators/Google/Image.php | 1 + src/Generators/Google/Item.php | 17 ++++++++ src/Generators/Google/ProductType.php | 1 + src/Generators/Google/latte/item.latte | 46 ++++++++++----------- src/Generators/Heureka/latte/item.latte | 8 ++-- src/Generators/HeurekaAvailability/Item.php | 4 +- src/Generators/Shoptet/Delivery.php | 2 +- src/Generators/Shoptet/latte/item.latte | 14 +------ src/Generators/Zbozi/latte/item.latte | 6 +-- 11 files changed, 60 insertions(+), 49 deletions(-) diff --git a/src/Generators/Custom/Item.php b/src/Generators/Custom/Item.php index 8f77d37..4c402e6 100644 --- a/src/Generators/Custom/Item.php +++ b/src/Generators/Custom/Item.php @@ -7,6 +7,8 @@ /** * Class Item + * @property itemId + * @property heurekaCpc * @author Martin Knor * @package Mk\Feed\Generators\Heureka * @see http://sluzby.heureka.cz/napoveda/xml-feed/ Documentation diff --git a/src/Generators/Custom/latte/item.latte b/src/Generators/Custom/latte/item.latte index 2cb1677..2bfc7f0 100644 --- a/src/Generators/Custom/latte/item.latte +++ b/src/Generators/Custom/latte/item.latte @@ -64,9 +64,9 @@ {if !empty($deliveries = $item->getDeliveries())} - {$delivery->id} - {$delivery->price} - {$delivery->priceCod} + {$delivery->getId()} + {$delivery->getPrice()} + {$delivery->getPriceCod()} {/if} @@ -78,6 +78,6 @@ {$item->getDues()} {if !empty($gifts = $item->getGifts())} - {$gift->name} + {$gift->getName()} {/if} diff --git a/src/Generators/Google/Image.php b/src/Generators/Google/Image.php index 7ac706b..8ca6fe7 100644 --- a/src/Generators/Google/Image.php +++ b/src/Generators/Google/Image.php @@ -6,6 +6,7 @@ use Mk, Nette; /** + * @property $url * Class Image * @author Martin Knor * @package Mk\Feed\Generators\Google diff --git a/src/Generators/Google/Item.php b/src/Generators/Google/Item.php index 4e1199a..72925e8 100644 --- a/src/Generators/Google/Item.php +++ b/src/Generators/Google/Item.php @@ -8,6 +8,23 @@ /** * Class Item * @property string $id + * @property $title + * @property $description + * @property $link + * @property $images + * @property $condition + * @property $availability + * @property $price + * @property $currency + * @property $identifierExists + * @property $salePrice + * @property $gtin + * @property $brand + * @property $labels + * @property $mpn + * @property $productTypes + * @property $googleProductCategory + * @property $itemGroupId * @author Martin Knor * @package Mk\Feed\Generators\Google */ diff --git a/src/Generators/Google/ProductType.php b/src/Generators/Google/ProductType.php index 498130d..65e6d44 100644 --- a/src/Generators/Google/ProductType.php +++ b/src/Generators/Google/ProductType.php @@ -6,6 +6,7 @@ use Nette; /** + * @property $text * Class ProductType * @author Martin Knor * @package Mk\Feed\Generators\Google diff --git a/src/Generators/Google/latte/item.latte b/src/Generators/Google/latte/item.latte index 04f81c9..0f5941c 100644 --- a/src/Generators/Google/latte/item.latte +++ b/src/Generators/Google/latte/item.latte @@ -1,42 +1,42 @@ {contentType xml} - {$item->id} - <![CDATA[{$item->title}]]> - description|striptags|noescape}]]> - link}]]> + {$item->getId()} + <![CDATA[{$item->getTitle()}]]> + getDescription()|striptags|noescape}]]> + getLink()}]]> - {if !empty($images = $item->images)} + {if !empty($images = $item->getImages())} {foreach $images as $image} {var tag = $iterator->first ? 'g:image_link' : 'g:additional_image_link'} - <{$tag}>url}]]> + <{$tag}>getUrl()}]]> {/foreach} {/if} - {$item->condition} - {$item->availability} - {$item->price} {$item->currency} - {$item->identifierExists ? 'TRUE' : 'FALSE'} - {$item->salePrice} - {if $item->gtin}{$item->gtin}{/if} - {$item->brand} - {$item->labels[0]} - {$item->labels[1]} - {$item->labels[2]} - {$item->labels[3]} - {$item->labels[4]} + {$item->getCondition()} + {$item->getAvailability()} + {$item->getPrice()} {$item->getCurrency()} + {$item->isIdentifierExists() ? 'TRUE' : 'FALSE'} + {$item->getSalePrice()} + {if $item->getGtin()}{$item->getGtin()}{/if} + {$item->getBrand()} + {$item->getLabels()[0]} + {$item->getLabels()[1]} + {$item->getLabels()[2]} + {$item->getLabels()[3]} + {$item->getLabels()[4]} {*Female Adult Navy 8 Standard*} - {if $item->mpn}{$item->mpn}{/if} + {if $item->getMpn()}{$item->getMpn()}{/if} - {if !empty($productTypes = $item->productTypes)} - {$productType->text} + {if !empty($productTypes = $item->getProductTypes())} + {$productType->getText()} {/if} - {$item->googleProductCategory} + {$item->getGoogleProductCategory()} - {$item->itemGroupId} + {$item->getItemGroupId()} {*{$value}*} \ No newline at end of file diff --git a/src/Generators/Heureka/latte/item.latte b/src/Generators/Heureka/latte/item.latte index 5fdc0ea..b848994 100644 --- a/src/Generators/Heureka/latte/item.latte +++ b/src/Generators/Heureka/latte/item.latte @@ -33,9 +33,9 @@ {if !empty($deliveries = $item->getDeliveries())} - {$delivery->id} - {$delivery->price} - {$delivery->priceCod} + {$delivery->getId()} + {$delivery->getPrice()} + {$delivery->getPriceCod()} {/if} @@ -47,6 +47,6 @@ {$item->getDues()} {if !empty($gifts = $item->getGifts())} - {$gift->name} + {$gift->getName()} {/if} diff --git a/src/Generators/HeurekaAvailability/Item.php b/src/Generators/HeurekaAvailability/Item.php index 4fc9837..b5a51a8 100644 --- a/src/Generators/HeurekaAvailability/Item.php +++ b/src/Generators/HeurekaAvailability/Item.php @@ -508,7 +508,7 @@ public function setStock(int $stock): Item { /** * @return \DateTime */ - public function getOrderDeadline(): \DateTime { + public function getOrderDeadline(): ?\DateTime { return $this->orderDeadline; } @@ -524,7 +524,7 @@ public function setOrderDeadline(\DateTime $orderDeadline): Item { /** * @return \DateTime */ - public function getOrderDeliveryTime(): \DateTime { + public function getOrderDeliveryTime(): ?\DateTime { return $this->orderDeliveryTime; } diff --git a/src/Generators/Shoptet/Delivery.php b/src/Generators/Shoptet/Delivery.php index ff7afec..dc1e865 100644 --- a/src/Generators/Shoptet/Delivery.php +++ b/src/Generators/Shoptet/Delivery.php @@ -93,7 +93,7 @@ public function __construct($id, $price, $priceCod = null) } $this->id = (string) $id; $this->price = (float) $price; - $this->priceCod = isset($priceCod) ? (float) $priceCod : null; + $this->priceCod = $priceCod !== null ? (float) $priceCod : null; } /** diff --git a/src/Generators/Shoptet/latte/item.latte b/src/Generators/Shoptet/latte/item.latte index c922d40..287cefd 100644 --- a/src/Generators/Shoptet/latte/item.latte +++ b/src/Generators/Shoptet/latte/item.latte @@ -1,6 +1,6 @@ {contentType xml} - {$item->getItemId()} + {$item->getItemId()} getProductName()}]]> getProduct()}]]> getShortDescription()|striptags|noescape}]]> @@ -30,22 +30,12 @@ {$item->getCode()} getManufacturer()}]]> - + {$category} {$item->getEan()} -{* {$item->getIsbn()}*} -{* {$item->getHeurekaCpc()}*} -{* {$item->getDeliveryDate()}*} -{* {if !empty($deliveries = $item->getDeliveries())}*} -{* *} -{* {$delivery->id}*} -{* {$delivery->price}*} -{* {$delivery->priceCod}*} -{* *} -{* {/if}*} {$item->getAvailability()} {$item->getItemGroupId()} diff --git a/src/Generators/Zbozi/latte/item.latte b/src/Generators/Zbozi/latte/item.latte index dd0d659..33222c9 100644 --- a/src/Generators/Zbozi/latte/item.latte +++ b/src/Generators/Zbozi/latte/item.latte @@ -6,9 +6,9 @@ {$item->getPriceVat()} {$item->getDeliveryDate()} - {$delivery->id} - {$delivery->price} - {$delivery->priceCod} + {$delivery->getId()} + {$delivery->getPrice()} + {$delivery->getPriceCod()} {$item->getItemId()} From db7b11a6732905002f75d65c6783c19fe67e5428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 5 Mar 2020 08:37:25 +0100 Subject: [PATCH 50/52] Fixed heureka item id --- src/Generators/Heureka/latte/item.latte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/Heureka/latte/item.latte b/src/Generators/Heureka/latte/item.latte index b848994..27dc334 100644 --- a/src/Generators/Heureka/latte/item.latte +++ b/src/Generators/Heureka/latte/item.latte @@ -1,6 +1,6 @@ {contentType xml} - {$item->getItemId()} + {$item->getItemId()} getProductName()}]]> getProduct()}]]> getDescription()|striptags|noescape}]]> From 3cdd93d83543bb0822979c9b06acab6e2232895f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20T=C3=AD=C5=BEek?= Date: Thu, 5 Mar 2020 08:40:56 +0100 Subject: [PATCH 51/52] Fixed isset --- src/Generators/Heureka/latte/item.latte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/Heureka/latte/item.latte b/src/Generators/Heureka/latte/item.latte index 27dc334..882327c 100644 --- a/src/Generators/Heureka/latte/item.latte +++ b/src/Generators/Heureka/latte/item.latte @@ -1,6 +1,6 @@ {contentType xml} - {$item->getItemId()} + {$item->getItemId()} getProductName()}]]> getProduct()}]]> getDescription()|striptags|noescape}]]> From 1b8e6035d9a6059f21de496c5c9f0b0de15dcb1f Mon Sep 17 00:00:00 2001 From: Pavel Date: Fri, 24 Apr 2020 12:50:45 +0200 Subject: [PATCH 52/52] Fixed images --- src/Generators/Shoptet/latte/item.latte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/Shoptet/latte/item.latte b/src/Generators/Shoptet/latte/item.latte index 287cefd..a2a791b 100644 --- a/src/Generators/Shoptet/latte/item.latte +++ b/src/Generators/Shoptet/latte/item.latte @@ -8,7 +8,7 @@ {$item->getUrl()} - + {$image->getUrl()}