Skip to content

Commit

Permalink
closes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed Jun 21, 2016
1 parent 4927227 commit 24c4fd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
22 changes: 4 additions & 18 deletions app/code/community/Ebizmarts/MailChimp/Model/Api/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public function createBatchJson($mailchimpStoreId)
->addAttributeToFilter(array(
array('attribute' => 'mailchimp_sync_delta', 'null' => true),
array('attribute' => 'mailchimp_sync_delta', 'eq' => ''),
array('attribute' => 'mailchimp_sync_delta', 'lt' => Mage::helper('mailchimp')->getMCMinSyncDateFlag())
array('attribute' => 'mailchimp_sync_delta', 'lt' => Mage::helper('mailchimp')->getMCMinSyncDateFlag()),
array('attribute' => 'mailchimp_sync_modified', 'eq' => 1)
), '', 'left');
$collection->getSelect()->limit(self::BATCH_LIMIT);

Expand All @@ -46,24 +47,7 @@ public function createBatchJson($mailchimpStoreId)
//define variants and root products
$variantProducts = array();
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
//check if parent exists
// $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
// if (!empty($parentIds)) {
// /**
// * this product will be uploaded within his parent so we abort the data build
// * we update the delta anyway
// */
//
// //update product delta
// $product->setData("mailchimp_sync_delta", Varien_Date::now());
// $product->setData("mailchimp_sync_error", "");
// $product->save();
//
// continue;
// } else {
//a simple product has only one variant (itself)
$variantProducts[] = $product;
// }
} else if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
//get children
$childProducts = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
Expand Down Expand Up @@ -107,6 +91,8 @@ public function createBatchJson($mailchimpStoreId)
//update product delta
$product->setData("mailchimp_sync_delta", Varien_Date::now());
$product->setData("mailchimp_sync_error", "");
$product->setData('mailchimp_sync_modified',0);
$product->setMailchimpUpdateObserverRan(true);
$product->save();
}
$counter += 1;
Expand Down
5 changes: 3 additions & 2 deletions app/code/community/Ebizmarts/MailChimp/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ public function productSaveBefore(Varien_Event_Observer $observer)

if($product->getMailchimpUpdateObserverRan())
{
return;
return $observer;
}else{
$product->setMailchimpUpdateObserverRan(true);
}

//update mailchimp ecommerce data for that product variant
// Mage::getModel('mailchimp/api_products')->update($product);
Mage::getModel('mailchimp/api_products')->update($product);
return $observer;
}
}

0 comments on commit 24c4fd0

Please sign in to comment.