Пример #1
0
 /**
  * Adds locale data.
  *
  * @param MShop_Common_Manager_Interface $localeItemManager Locale manager
  * @param array $data Associative list of locale data
  */
 protected function _addLocaleData(MShop_Common_Manager_Interface $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 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');
 }
 /**
  * Adds the customer address test data.
  *
  * @param array $testdata Associative list of key/list pairs
  * @param MShop_Common_Manager_Interface $customerAddressManager Customer address manager
  * @param array $parentIds Associative list of keys of the customer test data and customer IDs
  * @throws MW_Setup_Exception If a required ID is not available
  */
 protected function _addCustomerAddressData(array $testdata, MShop_Common_Manager_Interface $customerAddressManager, array $parentIds)
 {
     $address = $customerAddressManager->createItem();
     foreach ($testdata['customer/address'] as $dataset) {
         if (!isset($parentIds[$dataset['refid']])) {
             throw new MW_Setup_Exception(sprintf('No customer ID found for "%1$s"', $dataset['refid']));
         }
         $address->setId(null);
         $address->setCompany($dataset['company']);
         $address->setVatID(isset($dataset['vatid']) ? $dataset['vatid'] : '');
         $address->setSalutation($dataset['salutation']);
         $address->setTitle($dataset['title']);
         $address->setFirstname($dataset['firstname']);
         $address->setLastname($dataset['lastname']);
         $address->setAddress1($dataset['address1']);
         $address->setAddress2($dataset['address2']);
         $address->setAddress3($dataset['address3']);
         $address->setPostal($dataset['postal']);
         $address->setCity($dataset['city']);
         $address->setState($dataset['state']);
         $address->setCountryId($dataset['countryid']);
         $address->setTelephone($dataset['telephone']);
         $address->setEmail($dataset['email']);
         $address->setTelefax($dataset['telefax']);
         $address->setWebsite($dataset['website']);
         $address->setLanguageId($dataset['langid']);
         $address->setFlag($dataset['flag']);
         $address->setPosition($dataset['pos']);
         $address->setRefId($parentIds[$dataset['refid']]);
         $customerAddressManager->saveItem($address, false);
     }
 }
Пример #3
0
 /**
  * Adds plugin data.
  *
  * @param MShop_Common_Manager_Interface $pluginManager Plugin manager
  * @param array $data Associative list of plugin data
  */
 protected function _addPluginData(MShop_Common_Manager_Interface $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 Exception(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');
 }
Пример #4
0
 /**
  * Adds the order test data.
  *
  * @param MShop_Order_Manager_Interface $orderManager Order Manager
  * @param array $baseIds List of ids
  * @param array $testdata Associative list of key/list pairs
  * @throws MW_Setup_Exception If no type ID is found
  */
 protected function _addOrderData(MShop_Common_Manager_Interface $orderManager, array $baseIds, array $testdata)
 {
     $orderStatusManager = $orderManager->getSubManager('status', 'Default');
     $ords = array();
     $ordItem = $orderManager->createItem();
     $this->_conn->begin();
     foreach ($testdata['order'] as $key => $dataset) {
         if (!isset($baseIds[$dataset['baseid']])) {
             throw new 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 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();
 }
Пример #5
0
 /**
  * Saves a text item from the given data.
  *
  * @param MShop_Common_Manager_Interface $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(MShop_Common_Manager_Interface $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 MShop_Common_Manager_Interface $customerGroupManager Customer group manager
  * @param array $parentIds Associative list of keys of the customer test data and customer IDs
  * @throws MW_Setup_Exception If a required ID is not available
  */
 protected function _addCustomerGroupData(array $testdata, MShop_Common_Manager_Interface $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);
     }
 }
Пример #7
0
 /**
  * Adds products to the product list as suggested.
  *
  * @param int $productId Product id
  * @param array $productList List of suggestion products
  * @param int $listTypeId Product list type id
  * @param MShop_Common_Manager_Interface $productListManager Manager for list types of product domain
  */
 protected function _createProductListSuggestions($productId, array $productList, $listTypeId, MShop_Common_Manager_Interface $productListManager)
 {
     if (empty($productList)) {
         return;
     }
     $listItem = $productListManager->createItem();
     foreach ($productList as $key => $id) {
         $listItem->setId(null);
         $listItem->setParentId($productId);
         $listItem->setDomain('product');
         $listItem->setTypeId($listTypeId);
         $listItem->setRefId($id);
         $listItem->setStatus(1);
         $listItem->setPosition($key);
         $productListManager->saveItem($listItem);
     }
 }