Skip to content

Commit

Permalink
closes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed May 3, 2017
1 parent f74e3ae commit fa420ab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Model/Api/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ protected function _getModifiedOrders($magentoStoreId)
$orderId = $item->getEntityId();
$order = $this->_order->get($orderId);
//create missing products first
$productData = $this->_apiProduct->sendModifiedProduct($order, $mailchimpStoreId);
$productData = $this->_apiProduct->sendModifiedProduct($order, $mailchimpStoreId,$magentoStoreId);
if (count($productData)) {
foreach ($productData as $p) {
$batchArray[$this->_counter] = $p;
Expand Down Expand Up @@ -229,7 +229,7 @@ protected function _getNewOrders($magentoStoreId)
$orderId = $item->getEntityId();
$order = $this->_order->get($orderId);
//create missing products first
$productData = $this->_apiProduct->sendModifiedProduct($order, $mailchimpStoreId);
$productData = $this->_apiProduct->sendModifiedProduct($order, $mailchimpStoreId,$magentoStoreId);
if (count($productData)) {
foreach ($productData as $p) {
$batchArray[$this->_counter] = $p;
Expand Down
5 changes: 2 additions & 3 deletions Model/Api/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,11 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId ,
$line = explode('_', $item->operation_id);
$type = $line[0];
$id = $line[2];
$this->_helper->log("type [$type] id [$id] store[$storeId]");

$mailchimpErrors = $this->_chimpErrors->create();

//parse error
$response = json_decode($item->response);
$this->_helper->log($response);
$errorDetails = "";
if (!empty($response->errors)) {
foreach ($response->errors as $error) {
Expand All @@ -155,7 +153,6 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId ,
* @var \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $chimpSync
*/
$chimpSync = $this->_helper->getChimpSyncEcommerce($mailchimpStoreId,$id,$type);
$this->_helper->log($chimpSync);
$chimpSync->setData("mailchimp_sync_error", $error);
$chimpSync->getResource()->save($chimpSync);
$mailchimpErrors->setType($response->type);
Expand All @@ -166,6 +163,8 @@ protected function processEachResponseFile($files, $batchId, $mailchimpStoreId ,
$mailchimpErrors->setOriginalId($id);
$mailchimpErrors->setBatchId($batchId);
$mailchimpErrors->setMailchimpStoreId($mailchimpStoreId);
$mailchimpErrors->setOriginalId($id);
$mailchimpErrors->setBatchId($batchId);
$mailchimpErrors->getResource()->save($mailchimpErrors);
}
}
Expand Down
23 changes: 23 additions & 0 deletions Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,29 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
]
);

}
if (version_compare($context->getVersion(), '1.0.8') < 0) {
$installer->getConnection()->addColumn(
$installer->getTable('mailchimp_errors'),
'original_id',
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
'length' => 11,
'default' => null,
'comment' => 'Associated object ID'
]
);
$installer->getConnection()->addColumn(
$installer->getTable('mailchimp_errors'),
'batch_id',
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 64,
'default' => null,
'comment' => 'Mailchimp Batch ID'
]
);

}
$installer->endSetup();

Expand Down

0 comments on commit fa420ab

Please sign in to comment.