Skip to content

Commit

Permalink
Merge branch 'develop' into release/6.4.28
Browse files Browse the repository at this point in the history
  • Loading branch information
sta1r committed Apr 22, 2020
2 parents 4171a5c + db3b961 commit 12a4a1c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 29 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ You are welcome to contribute to Engagement Cloud for Magento! You can either:
- Fix a bug: please fork this repo and submit the Pull Request to our [Develop branch](https://github.com/dotmailer/dotmailer-magento-extension/tree/develop)
Request a feature on our [roadmap](https://roadmap.dotdigital.com)

# 6.4.28

###### Bug fixes
- We fixed a problem with product image paths in catalog sync. The default level base media URL was always used, instead of the value set at website or store level. [8f6fd296a4111f5272c4183959b3b11fcaf3345f]
- We've added batching when removing orphaned products at the start of catalog sync. This should prevent occasional SQL locking issues. [a383793c85e4f68db7dd6c84112671ed6c71c830]

# 6.4.27

###### Bug fixes
Expand Down
72 changes: 47 additions & 25 deletions code/Dotdigitalgroup/Email/Model/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,8 @@ public function sync()
);

if ($enabled && $sync) {
//remove product with product id set and no product
$coreResource = Mage::getSingleton('core/resource');
$write = $coreResource->getConnection('core_write');
$catalogTable = $coreResource->getTableName(
'ddg_automation/catalog'
);
//@codingStandardsIgnoreStart
$select = $write->select();
$select->reset()
->from(
array('c' => $catalogTable),
array('c.product_id')
)
->joinLeft(
array('e' => $coreResource->getTableName(
'catalog/product'
)),
"c.product_id = e.entity_id"
)
->where('e.entity_id is NULL');
//delete sql statement
$deleteSql = $select->deleteFromSelect('c');
//run query
$write->query($deleteSql);
//@codingStandardsIgnoreEnd

$this->removeOrphanedProducts();

$scope = Mage::getStoreConfig(
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CATALOG_VALUES
Expand Down Expand Up @@ -469,4 +446,49 @@ public function handleConfigSaveAfter(Varien_Event_Observer $observer)

return $this;
}

/**
* Remove orphaned records from email_catalog table.
* These are rows in email_catalog for which there is no longer a matching product in catalog_product_entity.
*/
protected function removeOrphanedProducts()
{
$coreResource = Mage::getSingleton('core/resource');
$write = $coreResource->getConnection('core_write');
$catalogTable = $coreResource->getTableName(
'ddg_automation/catalog'
);

$batchSize = 500;
$startPoint = 0;
$endPoint = $startPoint + $batchSize;

do {
$select = $write->select();
$batching = $select->reset()
->from(
array('c' => $catalogTable),
array('c.id', 'c.product_id')
)
->joinLeft(
array('e' => $coreResource->getTableName(
'catalog/product'
)),
"c.product_id = e.entity_id"
)
->where('c.id >= ?', $startPoint)
->where('c.id < ?', $endPoint);

$rowCount = $write->query($batching)->rowCount();

$select = $batching->where('e.entity_id is NULL');

$deleteSql = $select->deleteFromSelect('c');
$write->query($deleteSql);

$startPoint += $batchSize;
$endPoint += $batchSize;

} while ($rowCount > 0);
}
}
5 changes: 2 additions & 3 deletions code/Dotdigitalgroup/Email/Model/Catalog/Urlfinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ public function getProductImageUrl($product)
$product = $parentProduct;
}

return Mage::getModel('catalog/product_media_config')
->getMediaUrl($product->getSmallImage());

return Mage::helper('catalog/product')
->getSmallImageUrl($product);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion code/Dotdigitalgroup/Email/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Dotdigitalgroup_Email>
<version>6.4.27</version>
<version>6.4.28</version>
</Dotdigitalgroup_Email>
</modules>
<frontend>
Expand Down

0 comments on commit 12a4a1c

Please sign in to comment.