Esempio n. 1
0
 /**
  * Returns the rows from the CSV file up to the maximum count
  *
  * @param MW_Container_Content_Interface $content CSV content object
  * @param integer $maxcnt Maximum number of rows that should be retrieved at once
  * @return array List of arrays with product codes as keys and list of values from the CSV file
  */
 protected function _getData(MW_Container_Content_Interface $content, $maxcnt)
 {
     $count = 0;
     $data = array();
     while ($content->valid() && $count++ < $maxcnt) {
         $row = $content->current();
         $data[$row[0]] = $row;
         $content->next();
     }
     return $data;
 }
Esempio n. 2
0
 /**
  * Adds all texts belonging to an catalog item.
  *
  * @param MW_Container_Content_Interface $contentItem Content item
  * @param MShop_Catalog_Item_Interface $item product item object
  * @param string $langid Language id
  */
 protected function _addItem(MW_Container_Content_Interface $contentItem, MShop_Catalog_Item_Interface $item, $langid)
 {
     $listTypes = array();
     foreach ($item->getListItems('text') as $listItem) {
         $listTypes[$listItem->getRefId()] = $listItem->getType();
     }
     foreach ($this->_getTextTypes('catalog') as $textTypeItem) {
         $textItems = $item->getRefItems('text', $textTypeItem->getCode());
         if (!empty($textItems)) {
             foreach ($textItems as $textItem) {
                 $listType = isset($listTypes[$textItem->getId()]) ? $listTypes[$textItem->getId()] : '';
                 $items = array($langid, $item->getLabel(), $item->getId(), $listType, $textTypeItem->getCode(), '', '');
                 // use language of the text item because it may be null
                 if (($textItem->getLanguageId() == $langid || is_null($textItem->getLanguageId())) && $textItem->getTypeId() == $textTypeItem->getId()) {
                     $items[0] = $textItem->getLanguageId();
                     $items[5] = $textItem->getId();
                     $items[6] = $textItem->getContent();
                 }
                 $contentItem->add($items);
             }
         } else {
             $items = array($langid, $item->getLabel(), $item->getId(), 'default', $textTypeItem->getCode(), '', '');
             $contentItem->add($items);
         }
     }
 }
Esempio n. 3
0
 /**
  * Closes the site map content object
  *
  * @param MW_Container_Content_Interface $content
  */
 protected function _closeContent(MW_Container_Content_Interface $content)
 {
     $config = $this->_getContext()->getConfig();
     /** controller/jobs/product/export/sitemap/default/template-footer
      * Relative path to the XML site map footer template of the product site map job controller.
      *
      * The template file contains the XML code and processing instructions
      * to generate the site map footer. The configuration string is the path
      * to the template file relative to the layouts directory (usually in
      * controller/jobs/layouts).
      *
      * You can overwrite the template file configuration in extensions and
      * provide alternative templates. These alternative templates should be
      * named like the default one but with the string "default" replaced by
      * an unique name. You may use the name of your project for this. If
      * you've implemented an alternative client class as well, "default"
      * should be replaced by the name of the new class.
      *
      * @param string Relative path to the template creating XML code for the site map footer
      * @since 2015.01
      * @category Developer
      * @see controller/jobs/product/export/sitemap/default/template-header
      * @see controller/jobs/product/export/sitemap/default/template-items
      * @see controller/jobs/product/export/sitemap/default/template-index
      */
     $tplconf = 'controller/jobs/product/export/sitemap/default/template-footer';
     $default = 'product/export/sitemap-items-footer-default.xml';
     $view = $this->_getContext()->getView();
     $content->add($view->render($this->_getTemplate($tplconf, $default)));
 }
Esempio n. 4
0
 /**
  * Imports the text content using the given text types.
  *
  * @param MW_Container_Content_Interface $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(MW_Container_Content_Interface $contentItem, array $textTypeMap, $domain)
 {
     $count = 0;
     $codeIdMap = array();
     $context = $this->_getContext();
     $textManager = MShop_Text_Manager_Factory::createManager($context);
     $manager = 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);
     }
 }