/**
  * @param string $sourceGridDocumentName
  * @return \Magento\Framework\DB\Select
  */
 protected function getEntityIdsSelect($sourceGridDocumentName)
 {
     /** @var \Migration\ResourceModel\Adapter\Mysql $adapter */
     $adapter = $this->source->getAdapter();
     /** @var \Magento\Framework\DB\Select $select */
     $select = $adapter->getSelect();
     $schema = $this->config->getSource()['database']['name'];
     $select->from($this->source->addDocumentPrefix($sourceGridDocumentName), 'entity_id', $schema);
     return $select;
 }
 /**
  * @param Document $sourceDocument
  * @param Document $destinationDocument
  * @return bool
  */
 protected function isCopiedDirectly(Document $sourceDocument, Document $destinationDocument)
 {
     if (!$this->copyDirectly) {
         return;
     }
     $result = true;
     $schema = $this->config->getSource()['database']['name'];
     /** @var \Magento\Framework\DB\Select $select */
     $select = $this->source->getAdapter()->getSelect();
     $select->from($this->source->addDocumentPrefix($sourceDocument->getName()), '*', $schema);
     try {
         $this->destination->getAdapter()->insertFromSelect($select, $this->destination->addDocumentPrefix($destinationDocument->getName()), array_keys($sourceDocument->getStructure()->getFields()));
     } catch (\Exception $e) {
         $this->copyDirectly = false;
         $this->logger->error('Document ' . $sourceDocument->getName() . ' can not be copied directly because of error: ' . $e->getMessage());
         $result = false;
     }
     return $result;
 }
 /**
  * @param Config $config
  * @param Source $source
  * @param string $map
  * @param string $attributeCode
  * @throws Exception
  */
 public function __construct(Config $config, Source $source, $map, $attributeCode)
 {
     $this->source = $source;
     $this->attributeCode = $attributeCode;
     $this->canStart = $config->getSource()['type'] == DatabaseStage::SOURCE_TYPE;
     if ($this->canStart) {
         $map = rtrim($map, ']');
         $map = ltrim($map, '[');
         $map = explode(';', $map);
         $resultMap = [];
         foreach ($map as $mapRecord) {
             $explodedRecord = explode(':', trim($mapRecord));
             if (count($explodedRecord) != 2) {
                 throw new Exception('Invalid map provided to convert handler');
             }
             list($key, $value) = $explodedRecord;
             $resultMap[$key] = $value;
         }
         $this->map = $resultMap;
     }
 }
 /**
  * Check Step can be started
  *
  * @return bool
  */
 protected function canStart()
 {
     return $this->configReader->getSource()['type'] == self::SOURCE_TYPE;
 }
Exemple #5
0
 /**
  * @param Config $config
  * @param Source $source
  * @throws Exception
  */
 public function __construct(Config $config, Source $source)
 {
     $this->canStart = $config->getSource()['type'] == DatabaseStage::SOURCE_TYPE;
     $this->source = $source;
 }