示例#1
0
 /**
  * Adds the required text test data for text.
  *
  * @param array $testdata Associative list of key/list pairs
  * @throws \Aimeos\MW\Setup\Exception If no type ID is found
  */
 private function addTextData(array $testdata)
 {
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->additional, 'Standard');
     $textTypeManager = $textManager->getSubManager('type', 'Standard');
     $ttypeIds = array();
     $ttype = $textTypeManager->createItem();
     $this->conn->begin();
     foreach ($testdata['text/type'] as $key => $dataset) {
         $ttype->setId(null);
         $ttype->setCode($dataset['code']);
         $ttype->setDomain($dataset['domain']);
         $ttype->setLabel($dataset['label']);
         $ttype->setStatus($dataset['status']);
         $textTypeManager->saveItem($ttype);
         $ttypeIds[$key] = $ttype->getId();
     }
     $text = $textManager->createItem();
     foreach ($testdata['text'] as $key => $dataset) {
         if (!isset($ttypeIds[$dataset['typeid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No text type ID found for "%1$s"', $dataset['typeid']));
         }
         $text->setId(null);
         $text->setLanguageId($dataset['langid']);
         $text->setTypeId($ttypeIds[$dataset['typeid']]);
         $text->setDomain($dataset['domain']);
         $text->setLabel($dataset['label']);
         $text->setContent($dataset['content']);
         $text->setStatus($dataset['status']);
         $textManager->saveItem($text, false);
     }
     $this->conn->commit();
 }
示例#2
0
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->editor = \TestHelperMShop::getContext()->getEditor();
     $manager = \Aimeos\MShop\Text\Manager\Factory::createManager(\TestHelperMShop::getContext());
     $listManager = $manager->getSubManager('lists');
     $this->object = $listManager->getSubManager('type');
 }
 /**
  * Insert catalog nodes and product/catalog relations.
  */
 public function migrate()
 {
     $this->msg('Adding catalog text performance data', 0);
     $context = $this->getContext();
     $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($context);
     $catalogListManager = $catalogManager->getSubManager('lists');
     $catalogListTypeManager = $catalogListManager->getSubManager('type');
     $search = $catalogListTypeManager->createSearch();
     $expr = array($search->compare('==', 'catalog.lists.type.domain', 'text'), $search->compare('==', 'catalog.lists.type.code', 'default'));
     $search->setConditions($search->combine('&&', $expr));
     $types = $catalogListTypeManager->searchItems($search);
     if (($typeItem = reset($types)) === false) {
         throw new \Exception('Catalog list type item not found');
     }
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($context);
     $textTypeManager = $textManager->getSubManager('type');
     $search = $textTypeManager->createSearch();
     $expr = array($search->compare('==', 'text.type.domain', 'catalog'), $search->compare('==', 'text.type.code', 'name'));
     $search->setConditions($search->combine('&&', $expr));
     $types = $textTypeManager->searchItems($search);
     if (($textTypeItem = reset($types)) === false) {
         throw new \Exception('Text type item not found');
     }
     $textItem = $textManager->createItem();
     $textItem->setTypeId($textTypeItem->getId());
     $textItem->setLanguageId('en');
     $textItem->setDomain('catalog');
     $textItem->setStatus(1);
     $listItem = $catalogListManager->createItem();
     $listItem->setTypeId($typeItem->getId());
     $listItem->setDomain('text');
     $this->txBegin();
     $start = $pos = 0;
     $search = $catalogManager->createSearch();
     $search->setSortations(array($search->sort('+', 'catalog.id')));
     do {
         $result = $catalogManager->searchItems($search);
         foreach ($result as $id => $item) {
             $textItem->setId(null);
             $textItem->setLabel($item->getLabel());
             $textItem->setContent(str_replace('-', ' ', $item->getLabel()));
             $textManager->saveItem($textItem);
             $listItem->setId(null);
             $listItem->setParentId($id);
             $listItem->setRefId($textItem->getId());
             $listItem->setPosition($pos++);
             $catalogListManager->saveItem($listItem, false);
         }
         $count = count($result);
         $start += $count;
         $search->setSlice($start);
     } while ($count == $search->getSliceSize());
     $this->txCommit();
     $this->status('done');
 }
 /**
  * Gets required text item ids.
  *
  * @param array $keys List of keys for search
  * @throws \Aimeos\MW\Setup\Exception If no type ID is found
  */
 private function getTextData(array $keys)
 {
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->additional, 'Standard');
     $labels = array();
     foreach ($keys as $dataset) {
         if (($pos = strpos($dataset, '/')) === false || ($str = substr($dataset, $pos + 1)) === false) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('Some keys for ref text are set wrong "%1$s"', $dataset));
         }
         $labels[] = $str;
     }
     $search = $textManager->createSearch();
     $search->setConditions($search->compare('==', 'text.label', $labels));
     $refIds = array();
     foreach ($textManager->searchItems($search) as $item) {
         $refIds['text/' . $item->getLabel()] = $item->getId();
     }
     return $refIds;
 }
 /**
  * Adds the text-list test data.
  *
  * @param array $testdata Associative list of key/list pairs
  * @param array $refIds Associative list of domains and the keys/IDs of the inserted items
  * @throws \Aimeos\MW\Setup\Exception If a required ID is not available
  */
 private function addTextData(array $testdata, array $refIds)
 {
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->additional, 'Standard');
     $textListManager = $textManager->getSubManager('lists', 'Standard');
     $textListTypeManager = $textListManager->getSubmanager('type', 'Standard');
     $labels = array();
     foreach ($testdata['text/lists'] as $dataset) {
         if (($pos = strpos($dataset['parentid'], '/')) === false || ($str = substr($dataset['parentid'], $pos + 1)) === false) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('Some keys for parentid are set wrong "%1$s"', $dataset['parentid']));
         }
         $labels[] = $str;
     }
     $search = $textManager->createSearch();
     $search->setConditions($search->compare('==', 'text.label', $labels));
     $parentIds = array();
     foreach ($textManager->searchItems($search) as $item) {
         $parentIds['text/' . $item->getLabel()] = $item->getId();
     }
     $tListTypeIds = array();
     $tListType = $textListTypeManager->createItem();
     $this->conn->begin();
     foreach ($testdata['text/lists/type'] as $key => $dataset) {
         $tListType->setId(null);
         $tListType->setCode($dataset['code']);
         $tListType->setDomain($dataset['domain']);
         $tListType->setLabel($dataset['label']);
         $tListType->setStatus($dataset['status']);
         $textListTypeManager->saveItem($tListType);
         $tListTypeIds[$key] = $tListType->getId();
     }
     $tList = $textListManager->createItem();
     foreach ($testdata['text/lists'] as $dataset) {
         if (!isset($parentIds[$dataset['parentid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No text ID found for "%1$s"', $dataset['parentid']));
         }
         if (!isset($tListTypeIds[$dataset['typeid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No text list type ID found for "%1$s"', $dataset['typeid']));
         }
         if (!isset($refIds[$dataset['domain']][$dataset['refid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No "%1$s" ref ID found for "%2$s"', $dataset['refid'], $dataset['domain']));
         }
         $tList->setId(null);
         $tList->setParentId($parentIds[$dataset['parentid']]);
         $tList->setTypeId($tListTypeIds[$dataset['typeid']]);
         $tList->setRefId($refIds[$dataset['domain']][$dataset['refid']]);
         $tList->setDomain($dataset['domain']);
         $tList->setDateStart($dataset['start']);
         $tList->setDateEnd($dataset['end']);
         $tList->setConfig($dataset['config']);
         $tList->setPosition($dataset['pos']);
         $tList->setStatus($dataset['status']);
         $textListManager->saveItem($tList, false);
     }
     $this->conn->commit();
 }
示例#6
0
 public function testImportFromCSVFile()
 {
     $data = array();
     $data[] = '"Language ID","Type","Code","List type","Text type","Text ID","Text"' . "\n";
     $data[] = '"en","color","white","default","name","","unittest: white"' . "\n";
     $data[] = '"en","color","blue","default","name","","unittest: blue"' . "\n";
     $data[] = '"en","color","red","default","name","","unittest: red"' . "\n";
     $data[] = '"en","size","l","default","name","","unittest: l"' . "\n";
     $data[] = '"en","size","xl","default","name","","unittest: xl"' . "\n";
     $data[] = '"en","size","xxl","default","name","","unittest: xxl"' . "\n";
     $data[] = ' ';
     $ds = DIRECTORY_SEPARATOR;
     $csv = 'en-attribute-test.csv';
     $filename = PATH_TESTS . $ds . 'tmp' . $ds . 'attribute-import.zip';
     if (file_put_contents(PATH_TESTS . $ds . 'tmp' . $ds . $csv, implode('', $data)) === false) {
         throw new \Exception(sprintf('Unable to write test file "%1$s"', $csv));
     }
     $zip = new \ZipArchive();
     $zip->open($filename, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
     $zip->addFile(PATH_TESTS . $ds . 'tmp' . $ds . $csv, $csv);
     $zip->close();
     if (unlink(PATH_TESTS . $ds . 'tmp' . $ds . $csv) === false) {
         throw new \Exception('Unable to remove export file');
     }
     $params = new \stdClass();
     $params->site = $this->context->getLocale()->getSite()->getCode();
     $params->items = basename($filename);
     $this->object->importFile($params);
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->context);
     $criteria = $textManager->createSearch();
     $expr = array();
     $expr[] = $criteria->compare('==', 'text.domain', 'attribute');
     $expr[] = $criteria->compare('==', 'text.languageid', 'en');
     $expr[] = $criteria->compare('==', 'text.status', 1);
     $expr[] = $criteria->compare('~=', 'text.content', 'unittest:');
     $criteria->setConditions($criteria->combine('&&', $expr));
     $textItems = $textManager->searchItems($criteria);
     $textIds = array();
     foreach ($textItems as $item) {
         $textManager->deleteItem($item->getId());
         $textIds[] = $item->getId();
     }
     $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager($this->context);
     $listManager = $attributeManager->getSubManager('lists');
     $criteria = $listManager->createSearch();
     $expr = array();
     $expr[] = $criteria->compare('==', 'attribute.lists.domain', 'text');
     $expr[] = $criteria->compare('==', 'attribute.lists.refid', $textIds);
     $criteria->setConditions($criteria->combine('&&', $expr));
     $listItems = $listManager->searchItems($criteria);
     foreach ($listItems as $item) {
         $listManager->deleteItem($item->getId());
     }
     foreach ($textItems as $item) {
         $this->assertEquals('unittest:', substr($item->getContent(), 0, 9));
     }
     $this->assertEquals(6, count($textItems));
     $this->assertEquals(6, count($listItems));
     if (file_exists($filename) !== false) {
         throw new \Exception('Import file was not removed');
     }
 }
 protected function getListItems()
 {
     $manager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->context, 'Standard');
     $search = $manager->createSearch();
     $expr = array($search->compare('==', 'text.label', 'cafe_long_desc'), $search->compare('==', 'text.domain', 'catalog'), $search->compare('==', 'text.type.code', 'long'));
     $search->setConditions($search->combine('&&', $expr));
     $search->setSlice(0, 1);
     $results = $manager->searchItems($search);
     if (($item = reset($results)) === false) {
         throw new \Exception('No text item found');
     }
     $search = $this->object->createSearch();
     $expr = array($search->compare('==', 'text.lists.parentid', $item->getId()), $search->compare('==', 'text.lists.domain', 'media'), $search->compare('==', 'text.lists.editor', $this->editor), $search->compare('==', 'text.lists.type.code', 'align-left'));
     $search->setConditions($search->combine('&&', $expr));
     $search->setSortations(array($search->sort('+', 'text.lists.position')));
     return $this->object->searchItems($search);
 }
示例#8
0
 public function testImportFromXLSFile()
 {
     $this->object = new \Aimeos\Controller\ExtJS\Product\Import\Text\Standard($this->context);
     $filename = PATH_TESTS . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'product-import-test.xlsx';
     $phpExcel = new \PHPExcel();
     $phpExcel->setActiveSheetIndex(0);
     $sheet = $phpExcel->getActiveSheet();
     $sheet->setCellValueByColumnAndRow(0, 2, 'en');
     $sheet->setCellValueByColumnAndRow(0, 3, 'en');
     $sheet->setCellValueByColumnAndRow(0, 4, 'en');
     $sheet->setCellValueByColumnAndRow(0, 5, 'en');
     $sheet->setCellValueByColumnAndRow(0, 6, 'en');
     $sheet->setCellValueByColumnAndRow(0, 7, 'en');
     $sheet->setCellValueByColumnAndRow(1, 2, 'product');
     $sheet->setCellValueByColumnAndRow(1, 3, 'product');
     $sheet->setCellValueByColumnAndRow(1, 4, 'product');
     $sheet->setCellValueByColumnAndRow(1, 5, 'product');
     $sheet->setCellValueByColumnAndRow(1, 6, 'product');
     $sheet->setCellValueByColumnAndRow(1, 7, 'product');
     $sheet->setCellValueByColumnAndRow(2, 2, 'ABCD');
     $sheet->setCellValueByColumnAndRow(2, 3, 'ABCD');
     $sheet->setCellValueByColumnAndRow(2, 4, 'ABCD');
     $sheet->setCellValueByColumnAndRow(2, 5, 'ABCD');
     $sheet->setCellValueByColumnAndRow(2, 6, 'ABCD');
     $sheet->setCellValueByColumnAndRow(2, 7, 'ABCD');
     $sheet->setCellValueByColumnAndRow(3, 2, 'default');
     $sheet->setCellValueByColumnAndRow(3, 3, 'default');
     $sheet->setCellValueByColumnAndRow(3, 4, 'default');
     $sheet->setCellValueByColumnAndRow(3, 5, 'default');
     $sheet->setCellValueByColumnAndRow(3, 6, 'default');
     $sheet->setCellValueByColumnAndRow(3, 7, 'default');
     $sheet->setCellValueByColumnAndRow(4, 2, 'long');
     $sheet->setCellValueByColumnAndRow(4, 3, 'meta-description');
     $sheet->setCellValueByColumnAndRow(4, 4, 'meta-keyword');
     $sheet->setCellValueByColumnAndRow(4, 5, 'metatitle');
     $sheet->setCellValueByColumnAndRow(4, 6, 'name');
     $sheet->setCellValueByColumnAndRow(4, 7, 'short');
     $sheet->setCellValueByColumnAndRow(6, 2, 'ABCD: long');
     $sheet->setCellValueByColumnAndRow(6, 3, 'ABCD: meta desc');
     $sheet->setCellValueByColumnAndRow(6, 4, 'ABCD: meta keywords');
     $sheet->setCellValueByColumnAndRow(6, 5, 'ABCD: meta title');
     $sheet->setCellValueByColumnAndRow(6, 6, 'ABCD: name');
     $sheet->setCellValueByColumnAndRow(6, 7, 'ABCD: short');
     $objWriter = \PHPExcel_IOFactory::createWriter($phpExcel, 'Excel2007');
     $objWriter->save($filename);
     $params = new \stdClass();
     $params->site = $this->context->getLocale()->getSite()->getCode();
     $params->items = basename($filename);
     $this->object->importFile($params);
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->context);
     $criteria = $textManager->createSearch();
     $expr = array();
     $expr[] = $criteria->compare('==', 'text.domain', 'product');
     $expr[] = $criteria->compare('==', 'text.languageid', 'en');
     $expr[] = $criteria->compare('==', 'text.status', 1);
     $expr[] = $criteria->compare('~=', 'text.content', 'ABCD:');
     $criteria->setConditions($criteria->combine('&&', $expr));
     $textItems = $textManager->searchItems($criteria);
     $textIds = array();
     foreach ($textItems as $item) {
         $textManager->deleteItem($item->getId());
         $textIds[] = $item->getId();
     }
     $productManager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
     $listManager = $productManager->getSubManager('lists');
     $criteria = $listManager->createSearch();
     $expr = array();
     $expr[] = $criteria->compare('==', 'product.lists.domain', 'text');
     $expr[] = $criteria->compare('==', 'product.lists.refid', $textIds);
     $criteria->setConditions($criteria->combine('&&', $expr));
     $listItems = $listManager->searchItems($criteria);
     foreach ($listItems as $item) {
         $listManager->deleteItem($item->getId());
     }
     foreach ($textItems as $item) {
         $this->assertEquals('ABCD:', substr($item->getContent(), 0, 5));
     }
     $this->assertEquals(6, count($textItems));
     $this->assertEquals(6, count($listItems));
     if (file_exists($filename) !== false) {
         throw new \RuntimeException('Import file was not removed');
     }
 }
示例#9
0
 protected function delete(\Aimeos\MShop\Product\Item\Iface $product)
 {
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->context);
     $manager = \Aimeos\MShop\Product\Manager\Factory::createManager($this->context);
     $listManager = $manager->getSubManager('lists');
     foreach ($product->getListItems('text') as $listItem) {
         $textManager->deleteItem($listItem->getRefItem()->getId());
         $listManager->deleteItem($listItem->getId());
     }
     $manager->deleteItem($product->getId());
 }
示例#10
0
 public function testImportFromCSVFile()
 {
     $catalogManager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($this->context);
     $search = $catalogManager->createSearch();
     $search->setConditions($search->compare('==', 'catalog.code', 'root'));
     $items = $catalogManager->searchItems($search);
     if (($root = reset($items)) === false) {
         throw new \Aimeos\Controller\ExtJS\Exception('No item found for catalog code "root"');
     }
     $id = $root->getId();
     $data = array();
     $data[] = '"Language ID","Catalog code","Catalog ID","List type","Text type","Text ID","Text"' . "\n";
     $data[] = '"en","Root","' . $id . '","default","name","","Root: long"' . "\n";
     $data[] = '"en","Root","' . $id . '","default","name","","Root: meta desc"' . "\n";
     $data[] = '"en","Root","' . $id . '","default","name","","Root: meta keywords"' . "\n";
     $data[] = '"en","Root","' . $id . '","default","name","","Root: meta title"' . "\n";
     $data[] = '"en","Root","' . $id . '","default","name","","Root: name"' . "\n";
     $data[] = '"en","Root","' . $id . '","default","name","","Root: short"' . "\n";
     $data[] = ' ';
     $ds = DIRECTORY_SEPARATOR;
     $csv = 'en-catalog-test.csv';
     $filename = PATH_TESTS . $ds . 'tmp' . $ds . 'catalog-import.zip';
     if (file_put_contents(PATH_TESTS . $ds . 'tmp' . $ds . $csv, implode('', $data)) === false) {
         throw new \Exception(sprintf('Unable to write test file "%1$s"', $csv));
     }
     $zip = new \ZipArchive();
     $zip->open($filename, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
     $zip->addFile(PATH_TESTS . $ds . 'tmp' . $ds . $csv, $csv);
     $zip->close();
     if (unlink(PATH_TESTS . $ds . 'tmp' . $ds . $csv) === false) {
         throw new \Exception('Unable to remove export file');
     }
     $params = new \stdClass();
     $params->site = $this->context->getLocale()->getSite()->getCode();
     $params->items = $filename;
     $this->object->importFile($params);
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->context);
     $criteria = $textManager->createSearch();
     $expr = array();
     $expr[] = $criteria->compare('==', 'text.domain', 'catalog');
     $expr[] = $criteria->compare('==', 'text.languageid', 'en');
     $expr[] = $criteria->compare('==', 'text.status', 1);
     $expr[] = $criteria->compare('~=', 'text.content', 'Root:');
     $criteria->setConditions($criteria->combine('&&', $expr));
     $textItems = $textManager->searchItems($criteria);
     $textIds = array();
     foreach ($textItems as $item) {
         $textManager->deleteItem($item->getId());
         $textIds[] = $item->getId();
     }
     $listManager = $catalogManager->getSubManager('lists');
     $criteria = $listManager->createSearch();
     $expr = array();
     $expr[] = $criteria->compare('==', 'catalog.lists.domain', 'text');
     $expr[] = $criteria->compare('==', 'catalog.lists.refid', $textIds);
     $criteria->setConditions($criteria->combine('&&', $expr));
     $listItems = $listManager->searchItems($criteria);
     foreach ($listItems as $item) {
         $listManager->deleteItem($item->getId());
     }
     foreach ($textItems as $item) {
         $this->assertEquals('Root:', substr($item->getContent(), 0, 5));
     }
     $this->assertEquals(6, count($textItems));
     $this->assertEquals(6, count($listItems));
     if (file_exists($filename) !== false) {
         throw new \Exception('Import file was not removed');
     }
 }
示例#11
0
 public function testImportFromXLSFile()
 {
     $attributeManager = \Aimeos\MShop\Attribute\Manager\Factory::createManager($this->context);
     $search = $attributeManager->createSearch();
     $search->setConditions($search->compare('==', 'attribute.type.code', 'color'));
     $ids = array();
     foreach ($attributeManager->searchItems($search) as $item) {
         $ids[] = $item->getId();
     }
     if (empty($ids)) {
         throw new \RuntimeException('Empty id list');
     }
     $params = new \stdClass();
     $params->lang = array('en');
     $params->items = $ids;
     $params->site = $this->context->getLocale()->getSite()->getCode();
     $exporter = new \Aimeos\Controller\ExtJS\Attribute\Export\Text\Standard($this->context);
     $result = $exporter->exportFile($params);
     $this->assertTrue(array_key_exists('file', $result));
     $filename = substr($result['file'], 9, -14);
     $this->assertTrue(file_exists($filename));
     $filename2 = PATH_TESTS . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'attribute-import.xls';
     $phpExcel = \PHPExcel_IOFactory::load($filename);
     if (unlink($filename) !== true) {
         throw new \RuntimeException(sprintf('Deleting file "%1$s" failed', $filename));
     }
     $sheet = $phpExcel->getSheet(0);
     $sheet->setCellValueByColumnAndRow(6, 2, 'Root: delivery info');
     $sheet->setCellValueByColumnAndRow(6, 3, 'Root: long');
     $sheet->setCellValueByColumnAndRow(6, 4, 'Root: name');
     $sheet->setCellValueByColumnAndRow(6, 5, 'Root: payment info');
     $sheet->setCellValueByColumnAndRow(6, 6, 'Root: short');
     $objWriter = \PHPExcel_IOFactory::createWriter($phpExcel, 'Excel5');
     $objWriter->save($filename2);
     $params = new \stdClass();
     $params->site = $this->context->getLocale()->getSite()->getCode();
     $params->items = basename($filename2);
     $this->object->importFile($params);
     if (file_exists($filename2) !== false) {
         throw new \RuntimeException('Import file was not removed');
     }
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->context);
     $criteria = $textManager->createSearch();
     $expr = array();
     $expr[] = $criteria->compare('==', 'text.languageid', 'en');
     $expr[] = $criteria->compare('==', 'text.status', 1);
     $expr[] = $criteria->compare('~=', 'text.content', 'Root:');
     $criteria->setConditions($criteria->combine('&&', $expr));
     $textItems = $textManager->searchItems($criteria);
     $textIds = array();
     foreach ($textItems as $item) {
         $textManager->deleteItem($item->getId());
         $textIds[] = $item->getId();
     }
     $listManager = $attributeManager->getSubManager('lists');
     $criteria = $listManager->createSearch();
     $expr = array();
     $expr[] = $criteria->compare('==', 'attribute.lists.domain', 'text');
     $expr[] = $criteria->compare('==', 'attribute.lists.refid', $textIds);
     $criteria->setConditions($criteria->combine('&&', $expr));
     $listItems = $listManager->searchItems($criteria);
     foreach ($listItems as $item) {
         $listManager->deleteItem($item->getId());
     }
     $this->assertEquals(5, count($textItems));
     $this->assertEquals(5, count($listItems));
     foreach ($textItems as $item) {
         $this->assertEquals('Root:', substr($item->getContent(), 0, 5));
     }
 }
示例#12
0
文件: Base.php 项目: mvnp/aimeos-core
 /**
  * Imports the text content using the given text types.
  *
  * @param \Aimeos\MW\Container\Content\Iface $contentItem Content item containing texts and associated data
  * @param array $textTypeMap Associative list of text type IDs as keys and text type codes as values
  * @param string $domain Name of the domain this text belongs to, e.g. product, catalog, attribute
  * @return void
  */
 protected function importTextsFromContent(\Aimeos\MW\Container\Content\Iface $contentItem, array $textTypeMap, $domain)
 {
     $count = 0;
     $codeIdMap = array();
     $context = $this->getContext();
     $textManager = \Aimeos\MShop\Text\Manager\Factory::createManager($context);
     $manager = \Aimeos\MShop\Factory::createManager($context, $domain);
     $contentItem->next();
     // skip description row
     while (($row = $contentItem->current()) !== null) {
         $codeIdMap = $this->importTextRow($textManager, $row, $textTypeMap, $codeIdMap, $domain);
         if (++$count == 1000) {
             $this->importReferences($manager, $codeIdMap, $domain);
             $codeIdMap = array();
             $count = 0;
         }
         $contentItem->next();
     }
     if (!empty($codeIdMap)) {
         $this->importReferences($manager, $codeIdMap, $domain);
     }
 }
示例#13
0
 protected function cleanupText()
 {
     $manager = \Aimeos\MShop\Text\Manager\Factory::createManager($this->context);
     $search = $manager->createSearch();
     $expr = array($search->compare('==', 'text.domain', 'product'), $search->compare('==', 'text.label', 'import-%'));
     $search->setConditions($search->combine('&&', $expr));
     $search->setSortations(array($search->sort('+', 'text.id')));
     $start = 0;
     do {
         $result = $manager->searchItems($search);
         $manager->deleteItems(array_keys($result));
         $count = count($result);
         $start += $count;
         $search->setSlice($start);
     } while ($count == $search->getSliceSize());
 }
示例#14
0
 public function testCreateManagerNotExisting()
 {
     $this->setExpectedException('\\Aimeos\\MShop\\Exception');
     \Aimeos\MShop\Text\Manager\Factory::createManager(\TestHelper::getContext(), 'unknown');
 }