/** * {@inheritdoc} */ public function perform() { $this->progress->start($this->getIterationsCount()); foreach ($this->helper->getDocumentList() as $documentName) { $this->progress->advance(); $documentColumns = $this->helper->getDocumentColumns($documentName); $destinationDocumentStructure = array_keys($this->destination->getStructure($documentName)->getFields()); foreach (array_diff($documentColumns, $destinationDocumentStructure) as $columnDiff) { $message = sprintf('%s table does not contain field: %s', $documentName, $columnDiff); $this->logger->error($message); } } $this->progress->finish(); return $this->checkForErrors(); }
/** * Integrity check * * @return bool */ protected function integrity() { $result = true; $this->progress->start(1); $result &= array_keys($this->source->getStructure(self::SOURCE)->getFields()) == $this->structure[MapInterface::TYPE_SOURCE][self::SOURCE]; $result &= array_keys($this->destination->getStructure(self::DESTINATION)->getFields()) == $this->structure[MapInterface::TYPE_DEST][self::DESTINATION]; $this->progress->advance(); $this->progress->finish(); return (bool) $result; }
/** * @return array */ protected function getSalesCreditMemoColumnsGrid() { $paymentSelect = sprintf('(SELECT `sales_order_payment`.`method` FROM `%s` as sales_order_payment WHERE (`parent_id` = sales_order.entity_id) LIMIT 1)', $this->destination->addDocumentPrefix('sales_order_payment')); $fields = array_keys($this->destination->getStructure('sales_creditmemo_grid')->getFields()); $result = []; $fields = array_fill_keys($fields, null); $columns = ['entity_id' => 'sales_creditmemo.entity_id', 'increment_id' => 'sales_creditmemo.increment_id', 'created_at' => 'sales_creditmemo.created_at', 'updated_at' => 'sales_creditmemo.updated_at', 'order_id' => 'sales_order.entity_id', 'order_increment_id' => 'sales_order.increment_id', 'order_created_at' => 'sales_order.created_at', 'billing_name' => 'trim(concat(ifnull(sales_billing_address.firstname, \'\'), \' \' ' . ',ifnull(sales_billing_address.lastname, \'\')))', 'state' => 'sales_creditmemo.state', 'base_grand_total' => 'sales_creditmemo.base_grand_total', 'order_status' => 'sales_order.status', 'store_id' => 'sales_creditmemo.store_id', 'billing_address' => 'trim(concat(ifnull(sales_billing_address.street, \'\'), \', \' ' . ',ifnull(sales_billing_address.city, \'\'), \', \' ,ifnull(sales_billing_address.region,' . ' \'\'), \', \' ,ifnull(sales_billing_address.postcode, \'\')))', 'shipping_address' => 'trim(concat(ifnull(sales_shipping_address.street, \'\'), \', \' ' . ',ifnull(sales_shipping_address.city, \'\'), \', \' ,ifnull(sales_shipping_address.region,' . ' \'\'), \', \' ,ifnull(sales_shipping_address.postcode, \'\')))', 'customer_name' => 'trim(concat(ifnull(sales_order.customer_firstname, \'\'), \' \' ' . ',ifnull(sales_order.customer_lastname, \'\')))', 'customer_email' => 'sales_order.customer_email', 'customer_group_id' => 'sales_order.customer_group_id', 'payment_method' => $paymentSelect, 'shipping_information' => 'sales_order.shipping_description', 'subtotal' => 'sales_creditmemo.subtotal', 'shipping_and_handling' => 'sales_creditmemo.shipping_amount', 'adjustment_positive' => 'sales_creditmemo.adjustment_positive', 'adjustment_negative' => 'sales_creditmemo.adjustment_negative', 'order_base_grand_total' => 'sales_order.base_grand_total']; foreach (array_keys($fields) as $key) { $result[$key] = isset($columns[$key]) ? $columns[$key] : 'null'; } return $result; }
/** * Integrity check * * @return bool */ protected function integrity() { $result = true; $this->progress->start(1); $this->progress->advance(); $sourceFieldsDiff = array_diff($this->structure[MapInterface::TYPE_SOURCE][self::SOURCE], array_keys($this->source->getStructure(self::SOURCE)->getFields())); $destinationFieldsDiff = array_diff($this->structure[MapInterface::TYPE_DEST][self::DESTINATION], array_keys($this->destination->getStructure(self::DESTINATION)->getFields())); if ($sourceFieldsDiff) { $this->logger->error(sprintf('Source fields are missing. Document: %s. Fields: %s', self::SOURCE, implode(',', $sourceFieldsDiff))); $result = false; } if ($destinationFieldsDiff) { $this->logger->error(sprintf('Destination fields are missing. Document: %s. Fields: %s', self::DESTINATION, implode(',', $destinationFieldsDiff))); $result = false; } if ($result) { $this->progress->finish(); } return (bool) $result; }