-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathFeedProductMapper.php
More file actions
38 lines (31 loc) · 1.06 KB
/
FeedProductMapper.php
File metadata and controls
38 lines (31 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Hypeit\TradeTracker\Mapper;
use Hypeit\TradeTracker\Model\FeedProduct;
class FeedProductMapper implements MapperInterface
{
/**
* {@inheritdoc}
*
* @return FeedProduct
*/
public function hydrate($value)
{
$feedProduct = new FeedProduct();
$feedProduct->setIdentifier($value->identifier);
$feedProduct->setName($value->name);
$feedProduct->setProductCategoryName($value->productCategoryName);
$feedProduct->setDescription($value->description);
$feedProduct->setPrice($value->price);
$feedProduct->setProductUrl($value->productURL);
$feedProduct->setImageUrl($value->imageURL);
if (is_array($value->additional)) {
$data = [];
$feedProductAdditionalMapper = new FeedProductAdditionalMapper();
foreach ($value->additional as $additional) {
$data[] = $feedProductAdditionalMapper->hydrate($additional);
}
$feedProduct->setAdditional($data);
}
return $feedProduct;
}
}