Skip to content

Commit

Permalink
select only necessary fields for carts #1391 for magento 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzaloebiz committed May 19, 2022
1 parent e2fd4c9 commit 80a97b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Model/Api/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ protected function _getConvertedQuotes($mailchimpStoreId, $magentoStoreId)
// get only the converted quotes
$convertedCarts->addFieldToFilter('store_id', ['eq' => $magentoStoreId]);
$convertedCarts->addFieldToFilter('is_active', ['eq' => 0]);
$convertedCarts->getSelect()->reset(\Zend_Db_Select::COLUMNS)->columns(['entity_id']);

//join with mailchimp_ecommerce_sync_data table to filter by sync data.
$convertedCarts->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
Expand Down Expand Up @@ -223,6 +225,8 @@ protected function _getModifiedQuotes($mailchimpStoreId, $magentoStoreId)
$modifiedCarts->addFieldToFilter('is_active', ['eq'=>1]);
// select carts for the current Magento store id
$modifiedCarts->addFieldToFilter('store_id', ['eq' => $magentoStoreId]);
$modifiedCarts->getSelect()->reset(\Zend_Db_Select::COLUMNS)->columns(['entity_id']);

//join with mailchimp_ecommerce_sync_data table to filter by sync data.
$modifiedCarts->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
Expand All @@ -237,7 +241,6 @@ protected function _getModifiedQuotes($mailchimpStoreId, $magentoStoreId)
);
// limit the collection
$modifiedCarts->getSelect()->limit(self::BATCH_LIMIT);

/**
* @var $cart \Magento\Quote\Model\Quote
*/
Expand Down Expand Up @@ -356,6 +359,8 @@ protected function _getNewQuotes($mailchimpStoreId, $magentoStoreId)
if ($this->_firstDate) {
$newCarts->addFieldToFilter('created_at', ['gt' => $this->_firstDate]);
}
$newCarts->getSelect()->reset(\Zend_Db_Select::COLUMNS)->columns(['entity_id']);

//join with mailchimp_ecommerce_sync_data table to filter by sync data.
$newCarts->getSelect()->joinLeft(
['m4m' => $this->_helper->getTableName('mailchimp_sync_ecommerce')],
Expand All @@ -365,7 +370,6 @@ protected function _getNewQuotes($mailchimpStoreId, $magentoStoreId)
);
// be sure that the quotes are already in mailchimp and not deleted
$newCarts->getSelect()->where("m4m.mailchimp_sync_delta IS NULL");

// limit the collection
$newCarts->getSelect()->limit(self::BATCH_LIMIT);
/**
Expand Down

0 comments on commit 80a97b2

Please sign in to comment.