Exemplo n.º 1
0
 /**
  * Save product prices.
  *
  * @param array $priceData
  * @param string $table
  * @return $this
  */
 protected function saveProductPrices(array $priceData, $table)
 {
     if ($priceData) {
         $tableName = $this->_resourceFactory->create()->getTable($table);
         $priceIn = [];
         foreach ($priceData as $sku => $priceRows) {
             $productId = $this->_oldSkus[$sku];
             foreach ($priceRows as $row) {
                 $row['entity_id'] = $productId;
                 $priceIn[] = $row;
             }
         }
         if ($priceIn) {
             $this->_connection->insertOnDuplicate($tableName, $priceIn, ['value']);
         }
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Save product websites.
  *
  * @param array $websiteData
  * @return $this
  */
 protected function _saveProductWebsites(array $websiteData)
 {
     static $tableName = null;
     if (!$tableName) {
         $tableName = $this->_resourceFactory->create()->getProductWebsiteTable();
     }
     if ($websiteData) {
         $websitesData = array();
         $delProductId = array();
         foreach ($websiteData as $delSku => $websites) {
             $productId = $this->_newSku[$delSku]['entity_id'];
             $delProductId[] = $productId;
             foreach (array_keys($websites) as $websiteId) {
                 $websitesData[] = array('product_id' => $productId, 'website_id' => $websiteId);
             }
         }
         if (\Magento\ImportExport\Model\Import::BEHAVIOR_APPEND != $this->getBehavior()) {
             $this->_connection->delete($tableName, $this->_connection->quoteInto('product_id IN (?)', $delProductId));
         }
         if ($websitesData) {
             $this->_connection->insertOnDuplicate($tableName, $websitesData);
         }
     }
     return $this;
 }