Skip to content

Commit

Permalink
add outlets for SberMegaMarket (#49)
Browse files Browse the repository at this point in the history
* add outlets for SberMegaMarket


---------

Co-authored-by: Diman <[email protected]>
  • Loading branch information
dimawar and Diman committed Mar 22, 2023
1 parent 1a806fa commit 9d91f54
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Bukashk0zzz\YmlGenerator\Model\Offer\OfferCondition;
use Bukashk0zzz\YmlGenerator\Model\Offer\OfferGroupAwareInterface;
use Bukashk0zzz\YmlGenerator\Model\Offer\OfferInterface;
use Bukashk0zzz\YmlGenerator\Model\Offer\OfferOutlet;
use Bukashk0zzz\YmlGenerator\Model\Offer\OfferParam;
use Bukashk0zzz\YmlGenerator\Model\ShopInfo;

Expand Down Expand Up @@ -217,6 +218,7 @@ protected function addOffer(OfferInterface $offer)
$this->addOfferElement($name, $value);
}
}
$this->addOfferOutlets($offer);
$this->addOfferParams($offer);
$this->addOfferDeliveryOptions($offer);
$this->addOfferCondition($offer);
Expand Down Expand Up @@ -332,6 +334,28 @@ private function addOfferParams(OfferInterface $offer)
}
}

/**
* @param OfferInterface $offer
*/
private function addOfferOutlets(OfferInterface $offer)
{
if ($offer->getOutlets() && sizeof($offer->getOutlets())) {
$this->writer->startElement('outlets');
/** @var OfferOutlet $outlet */
foreach ($offer->getOutlets() as $outlet) {
if ($outlet instanceof OfferOutlet) {
$this->writer->startElement('outlet');

$this->writer->writeAttribute('id', $outlet->getId());
$this->writer->writeAttribute('instock', $outlet->getInStock());

$this->writer->endElement();
}
}
$this->writer->fullEndElement();
}
}

/**
* @param OfferInterface $offer
*/
Expand Down
25 changes: 25 additions & 0 deletions src/Model/Offer/AbstractOffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ abstract class AbstractOffer implements OfferInterface
*/
private $params = [];

/**
* @var array
*/
private $outlets = [];

/**
* @var bool
*/
Expand Down Expand Up @@ -712,6 +717,26 @@ public function addParam(OfferParam $param)
return $this;
}

/**
* @return array
*/
public function getOutlets()
{
return $this->outlets;
}

/**
* @param OfferOutlet $outlet
*
* @return $this
*/
public function addOutlet(OfferOutlet $outlet)
{
$this->outlets[] = $outlet;

return $this;
}

/**
* Add picture
*
Expand Down
5 changes: 5 additions & 0 deletions src/Model/Offer/OfferInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public function getDeliveryOptions();
*/
public function getParams();

/**
* @return array
*/
public function getOutlets();

/**
* @return object
*/
Expand Down
69 changes: 69 additions & 0 deletions src/Model/Offer/OfferOutlet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

/*
* This file is part of the Bukashk0zzzYmlGenerator
*
* (c) Denis Golubovskiy <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Bukashk0zzz\YmlGenerator\Model\Offer;

/**
* Class OfferOutlet
*/
class OfferOutlet
{
/**
* @var string
*/
private $id;

/**
* @var string
*/
private $inStock;

/**
* @return string
*/
public function getId()
{
return $this->id;
}

/**
* @param string $id
*
* @return OfferOutlet
*/
public function setId($id)
{
$this->id = $id;

return $this;
}

/**
* @return string
*/
public function getInStock()
{
return $this->inStock;
}

/**
* @param string $inStock
*
* @return OfferOutlet
*/
public function setInStock($inStock)
{
$this->inStock = $inStock;

return $this;
}

}

0 comments on commit 9d91f54

Please sign in to comment.