public function testItemLogisticsPartialProductAttributes() { $itemLogistics = new ItemLogistics(); $itemLogistics->setLegacyDistributorId('FOOBAR-TRADEPLACE'); $attributes = $itemLogistics->getProductAttributes(); $this->assertCount(1, $attributes); $this->assertEquals('FOOBAR-TRADEPLACE', $attributes[0]->getValue()[0]); }
public function setUp() { $feed = new Feed('2015-01-01 12:34:56'); $variations = [['sku' => 'SKU123', 'upc' => '5000000000123', 'productId' => 'P123', 'primary' => true], ['sku' => 'SKU456', 'upc' => '5000000000456', 'productId' => 'P123', 'primary' => false], ['sku' => 'SKU787', 'upc' => '5000000000789', 'productId' => 'P123', 'primary' => false]]; $colours = [new VariantMetaDataAttribute('colour', 'red', 'LOCATOR', 0), new VariantMetaDataAttribute('colour', 'orange', 'LOCATOR', 1), new VariantMetaDataAttribute('colour', 'yellow', 'LOCATOR', 2), new VariantMetaDataAttribute('colour', 'green', 'LOCATOR', 3), new VariantMetaDataAttribute('colour', 'blue', 'LOCATOR', 4), new VariantMetaDataAttribute('colour', 'indigo', 'LOCATOR', 5), new VariantMetaDataAttribute('colour', 'violet', 'LOCATOR', 6)]; $sizes = [new VariantMetaDataAttribute('size', 'XS', 'DEFAULT', 0), new VariantMetaDataAttribute('size', 'S', 'DEFAULT', 1), new VariantMetaDataAttribute('size', 'M', 'DEFAULT', 2), new VariantMetaDataAttribute('size', 'L', 'DEFAULT', 3), new VariantMetaDataAttribute('size', 'XL', 'DEFAULT', 4), new VariantMetaDataAttribute('size', 'XXL', 'DEFAULT', 5)]; foreach ($variations as $i => $variation) { $item = new Item($variation['sku'], $variation['upc']); $item->setTitle('Sample item'); $item->setBrand('Brandtastic'); $item->setDescriptions('Short description', 'Longer description about the item... •', true); $item->setTaxCode(20); $item->setDates('2015-01-01', '2025-01-01'); $item->setPublishStatus('UNPUBLISHED'); $item->setLifecycleStatus('ACTIVE'); $item->setDimensions(50, 1.5, 74.67, 'CM'); $item->setWeight(0.5, 'G'); $item->setPricing(14.99, 9.99, 12.49, '2015-01-01'); $item->addAttributes('Product', ['availability_flag' => true, 'catalog_id' => 'TestCatalog', 'barcode_list' => ['5000000000123', '5000000000456'], 'online_from' => '2015-01-01 12:34:56', 'stock_quantity' => 123, 'profit_margin' => 12.34, 'export_excluded' => null, 'export_include' => '']); $item->setProductSetupType($variation['primary'] ? 'PRIMARY' : 'VARIANT'); $item->setVariantGroupId($variation['productId']); $item->addVariantMetaDataAttributes($colours); $item->addVariantMetaDataAttributes($sizes); $item->addAttributes('Compliance', ['over_18_age' => true]); // example of some common attributes duplicated in multiple attribute groups, with an addition in the second... $common = ['sku' => 'SKU12345', 'is_international' => true]; $item->addAttributes('MarketInProduct', $common); $item->addAttributes('MarketInOffer', array_merge(['addition' => true], $common)); $item->addAttributes('Offer', ['pre_order' => true]); $item->setAssets(['1.png', '2.png', '3.png'], 'http://example.com/image'); $itemLogistics = new ItemLogistics(); $itemLogistics->setUnitCost(123.99, 'GBP'); $itemLogistics->setShipNodeSupply(12345678, 123456); $itemLogistics->setAssumeInfiniteInventory(true); $itemLogistics->setOnHandSafetyFactorQuantity(5, 'EA'); $itemLogistics->setInventoryAvailabilityThreshold(1, 5, 999); $itemLogistics->setLegacyDistributorId('FOOBAR-TRADEPLACE'); $itemLogistics->addPreferredDistributor(1, 'FOOBAR-TRADEPLACE', '2012-12-11 11:11:11', '2012-12-12 12:12:12'); $itemLogistics->addPreferredDistributor(2, 'FOOBAR-CLIPPER', '2012-12-13 13:13:13', '2012-12-14 14:14:14'); $item->setItemLogistics($itemLogistics); $feed->addItem($item); if ($i === 0) { $this->item = $item; } } $this->feed = $feed; }