Esempio n. 1
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);
     }
 }
Esempio n. 2
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;
 }