From 6982f19c4b62e5576bbb665cd288088a1e99c618 Mon Sep 17 00:00:00 2001 From: Alastair Mucklow Date: Mon, 25 Mar 2019 11:08:02 +0000 Subject: [PATCH 1/4] Merged PR 12647: Skip product attributes if their keys are not valid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip product attributes if their keys are not valid. The EC API has some restrictions on key names for insight data. During catalog sync, if we have invalid keys and attempt to sync single products, the import fails. This fix ensures that the product is synced, and any invalid keys are skipped when collecting the insight data payload. To test a bundle product [id 447]: - At L.149 insert `$options[24]->setDefaultTitle('Vælg dato');` To test a configurable product [id 417]: - At L.182 insert `$productAttributeOptions[0]['label'] = 'Vælg dato';` Related work items: #85311 --- .../Email/Model/Connector/Product.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/code/Dotdigitalgroup/Email/Model/Connector/Product.php b/code/Dotdigitalgroup/Email/Model/Connector/Product.php index 9a762b0fa..816e16ebf 100755 --- a/code/Dotdigitalgroup/Email/Model/Connector/Product.php +++ b/code/Dotdigitalgroup/Email/Model/Connector/Product.php @@ -146,6 +146,9 @@ public function __construct(Mage_Catalog_Model_Product $product) foreach ($options as $option) { $count = 0; $title = str_replace(' ', '', $option->getDefaultTitle()); + if (!$this->textIsValidForInsightDataKey($title)) { + continue; + } $selections = $option->getSelections(); $sOptions = array(); foreach ($selections as $selection) { @@ -176,6 +179,9 @@ public function __construct(Mage_Catalog_Model_Product $product) $label = strtolower( str_replace(' ', '', $productAttribute['label']) ); + if (!$this->textIsValidForInsightDataKey($label)) { + continue; + } $options = array(); foreach ($productAttribute['values'] as $attribute) { $options[$count]['option'] = $attribute['default_label']; @@ -341,4 +347,17 @@ private function formatPriceValues() '' ); } + + /** + * Ensure text matches insight data key restrictions + * https://support.dotmailer.com/hc/en-gb/articles/212214538-Using-Insight-data-developers-guide-#restrictkeys + * + * @param string $text + * + * @return false|int + */ + private function textIsValidForInsightDataKey($text) + { + return preg_match('/^[a-zA-Z_\\\\-][a-zA-Z0-9_\\\\-]*$/', $text); + } } From 68687011718ea4095fdcc261fd1257208674d1e0 Mon Sep 17 00:00:00 2001 From: Adeel Qamar Date: Mon, 25 Mar 2019 15:05:51 +0000 Subject: [PATCH 2/4] Merged PR 12646: remove support for emojis in template subject We have already removed encoding and decoding from m2 connector sometime ago. We need to remove in m1 connector too. utf-8 encoding was added to support emojis in the subject line. We removed support for emojis from subject hence not needing to encode and decode subject line. Related work items: #85166 --- .../Adminhtml/Column/Renderer/Template.php | 23 ------ .../Block/Adminhtml/System/Email/Grid.php | 75 ------------------- .../Email/Model/Adminhtml/Email/Template.php | 2 +- .../Email/Model/Email/Template.php | 2 +- code/Dotdigitalgroup/Email/Model/Template.php | 4 +- code/Dotdigitalgroup/Email/etc/config.xml | 5 -- 6 files changed, 4 insertions(+), 107 deletions(-) delete mode 100755 code/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Template.php delete mode 100755 code/Dotdigitalgroup/Email/Block/Adminhtml/System/Email/Grid.php diff --git a/code/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Template.php b/code/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Template.php deleted file mode 100755 index 119d620f9..000000000 --- a/code/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Template.php +++ /dev/null @@ -1,23 +0,0 @@ -isDotmailerTemplate($row->getTemplateCode())) { - - return utf8_decode($row->getTemplateSubject()); - } - - return Mage::helper('adminhtml')->__($row->getTemplateSubject()); - } -} diff --git a/code/Dotdigitalgroup/Email/Block/Adminhtml/System/Email/Grid.php b/code/Dotdigitalgroup/Email/Block/Adminhtml/System/Email/Grid.php deleted file mode 100755 index bf8c33a46..000000000 --- a/code/Dotdigitalgroup/Email/Block/Adminhtml/System/Email/Grid.php +++ /dev/null @@ -1,75 +0,0 @@ -addColumn('template_id', - array( - 'header'=>Mage::helper('adminhtml')->__('ID'), - 'index'=>'template_id' - ) - ); - - $this->addColumn('code', - array( - 'header'=>Mage::helper('adminhtml')->__('Template Name'), - 'index'=>'template_code' - )); - - $this->addColumn('added_at', - array( - 'header'=>Mage::helper('adminhtml')->__('Date Added'), - 'index'=>'added_at', - 'gmtoffset' => true, - 'type'=>'datetime' - )); - - $this->addColumn('modified_at', - array( - 'header'=>Mage::helper('adminhtml')->__('Date Updated'), - 'index'=>'modified_at', - 'gmtoffset' => true, - 'type'=>'datetime' - )); - - $this->addColumn('subject', - array( - 'header'=>Mage::helper('adminhtml')->__('Subject'), - 'index'=>'template_subject', - 'renderer' => 'ddg_automation/adminhtml_column_renderer_template', - )); - /* - $this->addColumn('sender', - array( - 'header'=>Mage::helper('adminhtml')->__('Sender'), - 'index'=>'template_sender_email', - 'renderer' => 'adminhtml/system_email_template_grid_renderer_sender' - )); - */ - $this->addColumn('type', - array( - 'header'=>Mage::helper('adminhtml')->__('Template Type'), - 'index'=>'template_type', - 'filter' => 'adminhtml/system_email_template_grid_filter_type', - 'renderer' => 'adminhtml/system_email_template_grid_renderer_type' - )); - - $this->addColumn('action', - array( - 'header' => Mage::helper('adminhtml')->__('Action'), - 'index' => 'template_id', - 'sortable' => false, - 'filter' => false, - 'width' => '100px', - 'renderer' => 'adminhtml/system_email_template_grid_renderer_action' - )); - - return $this; - } -} - diff --git a/code/Dotdigitalgroup/Email/Model/Adminhtml/Email/Template.php b/code/Dotdigitalgroup/Email/Model/Adminhtml/Email/Template.php index f1bb931e6..eca46c56c 100755 --- a/code/Dotdigitalgroup/Email/Model/Adminhtml/Email/Template.php +++ b/code/Dotdigitalgroup/Email/Model/Adminhtml/Email/Template.php @@ -10,7 +10,7 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Email_Template extends Mage_Adminhtm protected function _afterLoad() { //decompress the title - $this->setTemplateSubject(utf8_decode($this->getTemplateSubject())); + $this->setTemplateSubject($this->getTemplateSubject()); $templateText = $this->getTemplateText(); $transactionalHelper = Mage::helper('ddg/transactional'); if ($transactionalHelper->isStringCompressed($templateText)) { diff --git a/code/Dotdigitalgroup/Email/Model/Email/Template.php b/code/Dotdigitalgroup/Email/Model/Email/Template.php index 450f65c5b..d7b43ee5e 100755 --- a/code/Dotdigitalgroup/Email/Model/Email/Template.php +++ b/code/Dotdigitalgroup/Email/Model/Email/Template.php @@ -155,7 +155,7 @@ protected function _beforeSave() protected function _afterLoad() { //decompress the subject - $this->setTemplateSubject(utf8_decode($this->getTemplateSubject())); + $this->setTemplateSubject($this->getTemplateSubject()); $templateText = $this->getTemplateText(); $transactionalHelper = Mage::helper('ddg/transactional'); //decompress the content body diff --git a/code/Dotdigitalgroup/Email/Model/Template.php b/code/Dotdigitalgroup/Email/Model/Template.php index 01e2df693..75929b950 100755 --- a/code/Dotdigitalgroup/Email/Model/Template.php +++ b/code/Dotdigitalgroup/Email/Model/Template.php @@ -279,7 +279,7 @@ public function saveTemplate($template, $dmCampaign, $campaignId, $origTemplateC try { $template->setTemplateCode($templateName) ->setOrigTemplateCode($origTemplateCode) - ->setTemplateSubject(utf8_encode($dmCampaign->subject)) + ->setTemplateSubject($dmCampaign->subject) ->setTemplateText($dmCampaign->processedHtmlContent) ->setTemplateType(Mage_Core_Model_Template::TYPE_HTML) ->setTemplateSenderName($dmCampaign->fromName) @@ -313,7 +313,7 @@ private function updateTemplateById($dmCampaign, $campaignId, $templateId, $orig ->setTemplateSenderName($dmCampaign->fromName) ->setTemplateText($dmCampaign->processedHtmlContent) ->setTemplateType(Mage_Core_Model_Template::TYPE_HTML) - ->setTemplateSubject(utf8_encode($dmCampaign->subject)) + ->setTemplateSubject($dmCampaign->subject) ->setTemplateSenderEmail($dmCampaign->fromAddress->email); $template->save(); diff --git a/code/Dotdigitalgroup/Email/etc/config.xml b/code/Dotdigitalgroup/Email/etc/config.xml index 3f8fd6b77..b152134ad 100755 --- a/code/Dotdigitalgroup/Email/etc/config.xml +++ b/code/Dotdigitalgroup/Email/etc/config.xml @@ -158,11 +158,6 @@ Dotdigitalgroup_Email_Block - - - Dotdigitalgroup_Email_Block_Adminhtml_System_Email_Grid - - From 4bc576e9c72ea8dd880b38995eaa717b0934f9f9 Mon Sep 17 00:00:00 2001 From: Alastair Mucklow Date: Tue, 26 Mar 2019 11:26:39 +0000 Subject: [PATCH 3/4] Merged PR 12743: Fix error with template sync (and typos) The `processedCampaigns` property previously defaulted to `null`, which caused an error (logged to var/log/system.log) when calling `in_array()` at line 235. Also cleans up the template sync code and fixes a small typo in the admin. Related work items: #85616 --- code/Dotdigitalgroup/Email/Model/Template.php | 26 ++++++++----------- code/Dotdigitalgroup/Email/etc/system.xml | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/code/Dotdigitalgroup/Email/Model/Template.php b/code/Dotdigitalgroup/Email/Model/Template.php index 75929b950..54dfa2da0 100755 --- a/code/Dotdigitalgroup/Email/Model/Template.php +++ b/code/Dotdigitalgroup/Email/Model/Template.php @@ -168,11 +168,6 @@ class Dotdigitalgroup_Email_Model_Template extends Mage_Core_Model_Abstract 'product_price_alert_template' => self::XML_PATH_DDG_TEMPLATE_PRODUCT_PRICE_ALERT ]; - /** - * @var array - */ - public $proccessedCampaings; - /** * Load email_template by code/name. * @@ -212,30 +207,31 @@ public function deleteTemplateByCode($templatecode) public function sync() { $result = ['store' => 'Stores : ', 'message' => 'Done.']; - $lastWebsiteId = '0'; $helper = Mage::helper('ddg'); + $processedCampaigns = []; + /** @var Mage_Core_Model_Store $store */ foreach (Mage::app()->getStores(true) as $store) { - //store not enabled to sync - if (! $helper->isStoreEnabled($store)) { + + if (!$helper->isStoreEnabled($store)) { continue; } - //reset the campaign ids for each website + $websiteId = $store->getWebsiteId(); - if ($websiteId != $lastWebsiteId) { - $this->proccessedCampaings = []; - $lastWebsiteId = $websiteId; + if (empty($processedCampaigns[$websiteId])) { + $processedCampaigns[$websiteId] = []; } + foreach($this->templateConfigIdToDotmailerConfigPath as $configTemplateId => $dotConfigPath) { $campaignId = $store->getConfig($dotConfigPath); $configPath = $this->templateConfigMapping[$configTemplateId]; $emailTemplateId = $store->getConfig($configPath); - if ($campaignId && $emailTemplateId && ! in_array($campaignId, $this->proccessedCampaings)) { + if ($campaignId && $emailTemplateId && !in_array($campaignId, $processedCampaigns[$websiteId])) { $this->syncEmailTemplate($campaignId, $emailTemplateId, $store); $result['store'] .= ', ' . $store->getCode(); - $this->proccessedCampaings[$campaignId] = $campaignId; + $processedCampaigns[$websiteId][$campaignId] = $campaignId; } } } @@ -355,4 +351,4 @@ public function saveTemplateWithConfigPath($templateConfigPath, $campaignId, $sc return $this->saveTemplate($template, $dmCampaign, $campaignId, $templateConfigPath); } -} \ No newline at end of file +} diff --git a/code/Dotdigitalgroup/Email/etc/system.xml b/code/Dotdigitalgroup/Email/etc/system.xml index 7777b38b6..83f8a1002 100755 --- a/code/Dotdigitalgroup/Email/etc/system.xml +++ b/code/Dotdigitalgroup/Email/etc/system.xml @@ -2300,7 +2300,7 @@ 1 - + select ddg_automation/adminhtml_source_campaigns ddg_automation/adminhtml_backend_template From 899f6dfceaee80cb20d4925ebef33a29098d8d3d Mon Sep 17 00:00:00 2001 From: Adeel Qamar Date: Tue, 26 Mar 2019 13:11:12 +0000 Subject: [PATCH 4/4] Merged PR 12759: update version and remove authors from composer update version and remove authors from composer --- README.md | 18 ++++++++++++------ code/Dotdigitalgroup/Email/etc/config.xml | 2 +- composer.json | 6 ------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e9c5e6a8a..588115f77 100755 --- a/README.md +++ b/README.md @@ -34,17 +34,23 @@ 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) +# V6.4.13 + +##### Bug Fixes +- We've fixed a bug that caused the catalog sync to skip products if invalid data keys were supplied. +- We've fixed a bug related to the use of `utf8_decode` in email templates (note this discontinues support for emojis in email subject lines). +- We've fixed a minor error thrown during the Engagement Cloud template sync. + # V6.4.12 ##### Improvements - - * We've improved the performance of the product sync process by setting a limit when querying products before import - * Resubscribed contacts weren't added back to the "subscriber" address book; they are now - * Configurable, grouped, and bundled products are now correctly synced to Engagement Cloud with the lowest relevant price of their children +- We've improved the performance of the product sync process by setting a limit when querying products before import +- Resubscribed contacts weren't added back to the "subscriber" address book; they are now +- Configurable, grouped, and bundled products are now correctly synced to Engagement Cloud with the lowest relevant price of their children ##### Bug Fixes - * We've fixed incorrect syntax in the Order model (#309) - * We've fixed an issue that caused errors within the Sweet Tooth (Smile.io) integration +- We've fixed incorrect syntax in the Order model (#309) +- We've fixed an issue that caused errors within the Sweet Tooth (Smile.io) integration # V6.4.11 diff --git a/code/Dotdigitalgroup/Email/etc/config.xml b/code/Dotdigitalgroup/Email/etc/config.xml index b152134ad..8b9ef48a0 100755 --- a/code/Dotdigitalgroup/Email/etc/config.xml +++ b/code/Dotdigitalgroup/Email/etc/config.xml @@ -2,7 +2,7 @@ - 6.4.12 + 6.4.13 diff --git a/composer.json b/composer.json index 76caeb123..ad3fb71b5 100755 --- a/composer.json +++ b/composer.json @@ -4,12 +4,6 @@ "license":"OSL-3.0", "homepage":"https://github.com/dotmailer/dotmailer-magento-extension", "description":"Marketing automation for magento.", - "authors":[ - { - "name":"Calin Diacon", - "email":"calin.diacon@dotmailer.com" - } - ], "require":{ "magento-hackathon/magento-composer-installer":"*" }