diff --git a/src/Factory/Xml/Product/GlobalProductFactory.php b/src/Factory/Xml/Product/GlobalProductFactory.php index 41dc14e..25c6050 100644 --- a/src/Factory/Xml/Product/GlobalProductFactory.php +++ b/src/Factory/Xml/Product/GlobalProductFactory.php @@ -59,7 +59,8 @@ public static function make(SimpleXMLElement $element): GlobalProduct (string) $element->TaxClass, $productData, $images ?? null, - (string) $element->QCStatus ?? null + (string) $element->QCStatus ?? null, + (int) $element->ContentScore ?? null ); if (!empty($element->ShopSku)) { diff --git a/src/Model/Product/GlobalProduct.php b/src/Model/Product/GlobalProduct.php index 530a45b..509225d 100644 --- a/src/Model/Product/GlobalProduct.php +++ b/src/Model/Product/GlobalProduct.php @@ -44,6 +44,11 @@ class GlobalProduct extends BaseProduct implements JsonSerializable, ProductInte */ protected $talla; + /** + * @var int|null + */ + protected $contentScore; + public function __construct() { $this->productData = new ProductData(); @@ -65,7 +70,8 @@ public static function fromBasicData( ?string $taxClass, ProductData $productData, ?Images $images = null, - ?string $qcStatus = null + ?string $qcStatus = null, + ?int $contentScore = null ): self { self::ValidateArguments($sellerSku, $name, $description, $productId); @@ -96,6 +102,10 @@ public static function fromBasicData( $product->setQcStatus($qcStatus); } + if (!empty($contentScore)) { + $product->setContentScore($contentScore); + } + return $product; } @@ -133,6 +143,11 @@ public function getTalla(): ?string return $this->talla; } + public function getContentScore(): ?int + { + return $this->contentScore; + } + public function setQcStatus(string $qcStatus): void { $this->qcStatus = $qcStatus; @@ -163,6 +178,11 @@ public function setTalla(string $talla): void $this->talla = $talla; } + public function setContentScore(int $contentScore): void + { + $this->contentScore = $contentScore; + } + /** * @return mixed[] */ diff --git a/tests/Unit/Product/GlobalProductTest.php b/tests/Unit/Product/GlobalProductTest.php index 3005adb..56bb4cb 100644 --- a/tests/Unit/Product/GlobalProductTest.php +++ b/tests/Unit/Product/GlobalProductTest.php @@ -57,6 +57,8 @@ class GlobalProductTest extends LinioTestCase protected $mainImage; protected $images; + protected $contentScore = 40; + protected $conditionType = 'Nuevo'; protected $packageHeight = 3; protected $packageWidth = 0; @@ -124,7 +126,9 @@ public function testItCreatesAGlobalProductWithMandatoryParameters(): void $this->productId, $this->taxClass, $this->productData, - $this->images + $this->images, + null, + $this->contentScore ); $this->assertInstanceOf(GlobalProduct::class, $product); @@ -138,6 +142,7 @@ public function testItCreatesAGlobalProductWithMandatoryParameters(): void $this->assertEquals($product->getTaxClass(), $this->taxClass); $this->assertEquals($product->getProductData(), $this->productData); $this->assertEquals($product->getQcStatus(), null); + $this->assertEquals($product->getContentScore(), $this->contentScore); $this->assertInstanceOf(Images::class, $product->getImages()); $this->assertInstanceOf(BusinessUnits::class, $product->getBusinessUnits()); } diff --git a/tests/_schemas/Product/GlobalProduct.xml b/tests/_schemas/Product/GlobalProduct.xml index a358b96..9069350 100644 --- a/tests/_schemas/Product/GlobalProduct.xml +++ b/tests/_schemas/Product/GlobalProduct.xml @@ -20,6 +20,7 @@ https://i.linio.com.co/p/4a3e6ac763e2289c2952e0b00fd7b4a5-catalog.jpg https://i.linio.com.co/p/4a3e6ac763e2289c2952e0b00fd7b4a6-catalog.jpg + 26 Beige Beige L diff --git a/tests/_schemas/Product/GlobalProductsResponse.xml b/tests/_schemas/Product/GlobalProductsResponse.xml index 26e9613..e29815f 100644 --- a/tests/_schemas/Product/GlobalProductsResponse.xml +++ b/tests/_schemas/Product/GlobalProductsResponse.xml @@ -36,6 +36,7 @@ http://static.somesite.com/p/image2.jpg http://static.somesite.com/p/image3.jpg + 26 fdsfdsfds<span></span> IVA 19% GENERIC @@ -122,6 +123,7 @@ http://static.somesite.com/p/image2.jpg http://static.somesite.com/p/image3.jpg + 26 fdsfdsfds<span></span> IVA 19% GENERIC