/**
  * Adds plugin data.
  *
  * @param \Aimeos\MShop\Common\Manager\Iface $pluginManager Plugin manager
  * @param array $data Associative list of plugin data
  */
 protected function addPluginData(\Aimeos\MShop\Common\Manager\Iface $pluginManager, array $data)
 {
     $this->msg('Adding data for MShop plugins', 1);
     $types = array();
     $manager = $pluginManager->getSubManager('type');
     foreach ($manager->searchItems($manager->createSearch()) as $item) {
         $types['plugin/' . $item->getCode()] = $item;
     }
     $num = $total = 0;
     $item = $pluginManager->createItem();
     foreach ($data as $key => $dataset) {
         $total++;
         if (!isset($types[$dataset['typeid']])) {
             throw new \RuntimeException(sprintf('No plugin type "%1$s" found', $dataset['typeid']));
         }
         $item->setId(null);
         $item->setTypeId($types[$dataset['typeid']]->getId());
         $item->setProvider($dataset['provider']);
         $item->setLabel($dataset['label']);
         $item->setConfig($dataset['config']);
         $item->setStatus($dataset['status']);
         if (isset($dataset['position'])) {
             $item->setPosition($dataset['position']);
         }
         try {
             $pluginManager->saveItem($item);
             $num++;
         } catch (\Exception $e) {
         }
         // if plugin configuration was already available
     }
     $this->status($num > 0 ? $num . '/' . $total : 'OK');
 }
Beispiel #2
0
 /**
  * Adds the order test data.
  *
  * @param \Aimeos\MShop\Order\Manager\Iface $orderManager Order Manager
  * @param array $baseIds List of ids
  * @param array $testdata Associative list of key/list pairs
  * @throws \Aimeos\MW\Setup\Exception If no type ID is found
  */
 protected function addOrderData(\Aimeos\MShop\Common\Manager\Iface $orderManager, array $baseIds, array $testdata)
 {
     $orderStatusManager = $orderManager->getSubManager('status', 'Standard');
     $ords = array();
     $ordItem = $orderManager->createItem();
     $this->conn->begin();
     foreach ($testdata['order'] as $key => $dataset) {
         if (!isset($baseIds[$dataset['baseid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No base ID found for "%1$s"', $dataset['baseid']));
         }
         $ordItem->setId(null);
         $ordItem->setBaseId($baseIds[$dataset['baseid']]);
         $ordItem->setType($dataset['type']);
         $ordItem->setDateDelivery($dataset['datedelivery']);
         $ordItem->setDatePayment($dataset['datepayment']);
         $ordItem->setDeliveryStatus($dataset['statusdelivery']);
         $ordItem->setPaymentStatus($dataset['statuspayment']);
         $ordItem->setRelatedId($dataset['relatedid']);
         $orderManager->saveItem($ordItem);
         $ords[$key] = $ordItem->getId();
     }
     $ordStat = $orderStatusManager->createItem();
     foreach ($testdata['order/status'] as $dataset) {
         if (!isset($ords[$dataset['parentid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No order ID found for "%1$s"', $dataset['parentid']));
         }
         $ordStat->setId(null);
         $ordStat->setParentId($ords[$dataset['parentid']]);
         $ordStat->setType($dataset['type']);
         $ordStat->setValue($dataset['value']);
         $orderStatusManager->saveItem($ordStat, false);
     }
     $this->conn->commit();
 }
 /**
  * Adds locale data.
  *
  * @param \Aimeos\MShop\Common\Manager\Iface $localeItemManager Locale manager
  * @param array $data Associative list of locale data
  */
 protected function addLocaleData(\Aimeos\MShop\Common\Manager\Iface $localeItemManager, array $data, array $siteIds)
 {
     $this->msg('Adding data for MShop locales', 1);
     $localeItem = $localeItemManager->createItem();
     foreach ($data as $key => $dataset) {
         if (!isset($siteIds[$dataset['siteid']])) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No ID for site for key "%1$s" found', $dataset['siteid']));
         }
         $localeItem->setId(null);
         $localeItem->setSiteId($siteIds[$dataset['siteid']]);
         $localeItem->setLanguageId($dataset['langid']);
         $localeItem->setCurrencyId($dataset['currencyid']);
         $localeItem->setPosition($dataset['pos']);
         $localeItem->setStatus($dataset['status']);
         try {
             $localeItemManager->saveItem($localeItem);
         } catch (\Exception $e) {
         }
         // if locale combination was already available
     }
     $this->status('done');
 }
Beispiel #4
0
 /**
  * Saves and returns the new or updated item
  *
  * @param \Aimeos\MShop\Common\Manager\Iface $manager Manager responsible for the items
  * @param \stdClass $entry Object including "id" and "attributes" elements
  * @return \Aimeos\MShop\Common\Item\Iface New or updated item
  */
 protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry)
 {
     if (isset($entry->id)) {
         $item = $manager->getItem($entry->id);
     } else {
         $item = $manager->createItem();
     }
     $item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
     $manager->saveItem($item);
     if (isset($entry->relationships)) {
         $this->saveRelationships($manager, $item, $entry->relationships);
     }
     return $manager->getItem($item->getId());
 }
Beispiel #5
0
 /**
  * Saves a text item from the given data.
  *
  * @param \Aimeos\MShop\Common\Manager\Iface $textManager Text manager object
  * @param array $row Row from import file
  * @param array $textTypeMap Associative list of text type IDs as keys and text type codes as values
  * @param array $codeIdMap Two dimensional associated list of codes and text IDs as key
  * @param string $domain Name of the domain this text belongs to, e.g. product, catalog, attribute
  * @return array Updated two dimensional associated list of codes and text IDs as key
  */
 private function saveTextItem(\Aimeos\MShop\Common\Manager\Iface $textManager, array $row, array $textTypeMap, array $codeIdMap, $domain)
 {
     $value = isset($row[6]) ? $row[6] : '';
     $textId = isset($row[5]) ? $row[5] : '';
     if ($textId != '' || $value != '') {
         $item = $textManager->createItem();
         if ($textId != '') {
             $item->setId($textId);
         }
         $item->setLanguageId($row[0] != '' ? $row[0] : null);
         $item->setTypeId($textTypeMap[$row[4]]);
         $item->setDomain($domain);
         $item->setLabel(mb_strcut($value, 0, 255));
         $item->setContent($value);
         $item->setStatus(1);
         $textManager->saveItem($item);
         $codeIdMap[$row[2]][$item->getId()] = $row[3];
     }
     return $codeIdMap;
 }
 /**
  * Adds the customer group test data.
  *
  * @param array $testdata Associative list of key/list pairs
  * @param \Aimeos\MShop\Common\Manager\Iface $customerGroupManager Customer group manager
  * @throws \Aimeos\MW\Setup\Exception If a required ID is not available
  */
 protected function addCustomerGroupData(array $testdata, \Aimeos\MShop\Common\Manager\Iface $customerGroupManager)
 {
     $group = $customerGroupManager->createItem();
     foreach ($testdata['customer/group'] as $dataset) {
         $group->setId(null);
         $group->setCode($dataset['code']);
         $group->setLabel($dataset['label']);
         try {
             $customerGroupManager->saveItem($group, false);
         } catch (\Exception $e) {
         }
         // ignore duplicates
     }
 }
 /**
  * Adds the customer group test data.
  *
  * @param array $testdata Associative list of key/list pairs
  * @param \Aimeos\MShop\Common\Manager\Iface $customerGroupManager Customer group manager
  * @param array $parentIds Associative list of keys of the customer test data and customer IDs
  * @throws \Aimeos\MW\Setup\Exception If a required ID is not available
  */
 protected function addCustomerGroupData(array $testdata, \Aimeos\MShop\Common\Manager\Iface $customerGroupManager, array $parentIds)
 {
     $group = $customerGroupManager->createItem();
     foreach ($testdata['customer/group'] as $dataset) {
         $group->setId(null);
         $group->setCode($dataset['code']);
         $group->setLabel($dataset['label']);
         $customerGroupManager->saveItem($group, false);
     }
 }
Beispiel #8
0
 /**
  * Adds one or more list items to the given user
  *
  * @param \Aimeos\MShop\Common\Manager\Iface $manager Customer list manager
  * @param array $listItems Associative list of the reference IDs as keys and the list items as values
  * @param array $ids List of referenced IDs
  * @param string $typeId List type ID of the referenced items
  * @param string $userId Unique user ID
  */
 protected function addItems(\Aimeos\MShop\Common\Manager\Iface $manager, array $listItems, array $ids, $typeId, $userId)
 {
     $item = $manager->createItem();
     $item->setParentId($userId);
     $item->setTypeId($typeId);
     $item->setDomain('product');
     $item->setStatus(1);
     foreach ($ids as $id) {
         if (!isset($listItems[$id])) {
             $item->setId(null);
             $item->setRefId($id);
             $manager->saveItem($item);
             $manager->moveItem($item->getId());
         }
     }
 }