public function testBatchModeShouldBeSuccessful() { $data = $this->getSimpleArticleData(); $data['mainDetail'] = $this->getSimpleVariantData(); $configuratorSet = $this->getSimpleConfiguratorSet(); $data['configuratorSet'] = $configuratorSet; $article = $this->resourceArticle->create($data); $this->assertCount(0, $article->getDetails()); // Create 5 new variants $batchData = array(); for ($i = 0; $i < 5; $i++) { $create = $this->getSimpleVariantData(); $create['articleId'] = $article->getId(); $create['configuratorOptions'] = $this->getVariantOptionsOfSet($configuratorSet); $batchData[] = $create; } // Update the price of the existing variant $existingVariant = $data['mainDetail']; $existingVariant['prices'] = array(array('customerGroupKey' => 'EK', 'from' => 1, 'to' => '-', 'price' => 473.99)); $batchData[] = $existingVariant; // Run batch operations $this->resource->batch($batchData); // Check results $this->resourceArticle->setResultMode(\Shopware\Components\Api\Resource\Variant::HYDRATE_ARRAY); $id = $article->getId(); $article = $this->resourceArticle->getOne($id); $this->assertCount(5, $article['details']); $this->assertEquals(398, round($article['mainDetail']['prices'][0]['price'])); }
public function testSeoCategory() { $this->dispatch("/"); $data = $this->getSimpleTestData(); $data['categories'] = Shopware()->Db()->fetchAll("SELECT DISTINCT id FROM s_categories LIMIT 5, 10"); $first = $data['categories'][3]; $second = $data['categories'][4]; $data['seoCategories'] = array(array('shopId' => 1, 'categoryId' => $first['id']), array('shopId' => 2, 'categoryId' => $second['id'])); $article = $this->resource->create($data); $this->resource->setResultMode(Shopware\Components\Api\Resource\Resource::HYDRATE_OBJECT); /**@var $article Shopware\Models\Article\Article*/ $article = $this->resource->getOne($article->getId()); $german = Shopware()->Modules()->Categories()->sGetCategoryIdByArticleId($article->getId(), null, 1); $english = Shopware()->Modules()->Categories()->sGetCategoryIdByArticleId($article->getId(), null, 2); $this->assertEquals($first['id'], $german); $this->assertEquals($second['id'], $english); }
public function testArticleGrossPrices() { $data = $this->getSimpleTestData(); $article = $this->resource->create($data); $this->assertInstanceOf('Shopware\\Models\\Article\\Article', $article); /**@var $price \Shopware\Models\Article\Price */ $price = $article->getMainDetail()->getPrices()->first(); $net = 400 / (($article->getTax()->getTax() + 100) / 100); $this->assertEquals($net, $price->getPrice(), 'Customer group price not calculated'); $this->resource->setResultMode(2); $data = $this->resource->getOne($article->getId(), array('considerTaxInput' => true)); $price = $data['mainDetail']['prices'][0]; $this->assertEquals(400, $price['price']); $this->assertEquals($net, $price['net']); }