/** * Import data rows * * @return boolean * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _importData() { $this->_initProductsSku(); $nextOptionId = $this->_resourceHelper->getNextAutoincrement($this->_tables['catalog_product_option']); $nextValueId = $this->_resourceHelper->getNextAutoincrement($this->_tables['catalog_product_option_type_value']); $prevOptionId = 0; while ($bunch = $this->_dataSourceModel->getNextBunch()) { $products = []; $options = []; $titles = []; $prices = []; $typeValues = []; $typePrices = []; $typeTitles = []; $parentCount = []; $childCount = []; foreach ($bunch as $rowNumber => $rowData) { $multiRowData = $this->_getMultiRowFormat($rowData); foreach ($multiRowData as $optionData) { $combinedData = array_merge($rowData, $optionData); if (!$this->isRowAllowedToImport($combinedData, $rowNumber)) { continue; } if (!$this->_parseRequiredData($combinedData)) { continue; } $optionData = $this->_collectOptionMainData($combinedData, $prevOptionId, $nextOptionId, $products, $prices); if ($optionData != null) { $options[] = $optionData; } $this->_collectOptionTypeData($combinedData, $prevOptionId, $nextValueId, $typeValues, $typePrices, $typeTitles, $parentCount, $childCount); $this->_collectOptionTitle($combinedData, $prevOptionId, $titles); } } // Save prepared custom options data !!! if ($this->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) { $this->_deleteEntities(array_keys($products)); } if ($this->_isReadyForSaving($options, $titles, $typeValues)) { if ($this->getBehavior() == \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) { $this->_compareOptionsWithExisting($options, $titles, $prices, $typeValues); } $this->_saveOptions($options)->_saveTitles($titles)->_savePrices($prices)->_saveSpecificTypeValues($typeValues)->_saveSpecificTypePrices($typePrices)->_saveSpecificTypeTitles($typeTitles)->_updateProducts($products); } } return true; }
/** * Get new supper attribute id. * * @return int */ protected function _getNextAttrId() { if (!$this->_nextAttrId) { $mainTable = $this->_resource->getTableName('catalog_product_super_attribute'); $this->_nextAttrId = $this->_resourceHelper->getNextAutoincrement($mainTable); } $this->_nextAttrId++; return $this->_nextAttrId; }
/** * Get next address entity ID * * @return int */ protected function _getNextEntityId() { if (!$this->_nextEntityId) { /** @var $addressResource \Magento\Customer\Model\ResourceModel\Address */ $addressResource = $this->_addressFactory->create()->getResource(); $addressTable = $addressResource->getEntityTable(); $this->_nextEntityId = $this->_resourceHelper->getNextAutoincrement($addressTable); } return $this->_nextEntityId++; }
/** * Retrieve next customer entity id * * @return int */ protected function _getNextEntityId() { if (!$this->_nextEntityId) { $this->_nextEntityId = $this->_resourceHelper->getNextAutoincrement($this->_entityTable); } return $this->_nextEntityId++; }