/** * Adds the tag test data. * * @param array $testdata Associative list of key/list pairs * @throws \Aimeos\MW\Setup\Exception If no type ID is found */ private function addTagData(array $testdata) { $tagManager = \Aimeos\MShop\Tag\Manager\Factory::createManager($this->additional, 'Standard'); $tagTypeManager = $tagManager->getSubManager('type', 'Standard'); $typeIds = array(); $typeItem = $tagTypeManager->createItem(); $this->conn->begin(); foreach ($testdata['tag/type'] as $key => $dataset) { $typeItem->setId(null); $typeItem->setCode($dataset['code']); $typeItem->setDomain($dataset['domain']); $typeItem->setLabel($dataset['label']); $typeItem->setStatus($dataset['status']); $tagTypeManager->saveItem($typeItem); $typeIds[$key] = $typeItem->getId(); } $tagItem = $tagManager->createItem(); foreach ($testdata['tag'] as $key => $dataset) { if (!isset($typeIds[$dataset['typeid']])) { throw new \Aimeos\MW\Setup\Exception(sprintf('No tag type ID found for "%1$s"', $dataset['typeid'])); } $tagItem->setId(null); $tagItem->setDomain($dataset['domain']); $tagItem->setLanguageId($dataset['langid']); $tagItem->setTypeId($typeIds[$dataset['typeid']]); $tagItem->setLabel($dataset['label']); $tagManager->saveItem($tagItem, false); } $this->conn->commit(); }
/** * Returns the product tag test data. * * @param array $keys List of keys for tag lookup * @return array $refIds List with referenced Ids * @throws \Aimeos\MW\Setup\Exception If no type ID is found */ protected function getTagData(array $keys) { $tagManager = \Aimeos\MShop\Tag\Manager\Factory::createManager($this->additional, 'Standard'); $prodTag = array(); foreach ($keys as $key) { $exp = explode('/', $key); if (count($exp) != 2) { throw new \Aimeos\MW\Setup\Exception(sprintf('Some keys for ref product tag are set wrong "%1$s"', $key)); } $prodTag[] = $exp[1]; } $search = $tagManager->createSearch(); $search->setConditions($search->compare('==', 'tag.label', $prodTag)); $refIds = array(); foreach ($tagManager->searchItems($search) as $item) { $refIds['tag/' . $item->getLabel()] = $item->getId(); } return $refIds; }
protected function setUp() { $this->editor = \TestHelperMShop::getContext()->getEditor(); $manager = \Aimeos\MShop\Tag\Manager\Factory::createManager(\TestHelperMShop::getContext()); $this->object = $manager->getSubManager('type'); }