Skip to content

Commit

Permalink
Merge pull request #348 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
Victor-Mageplaza authored Nov 9, 2021
2 parents 3e459bb + b8deb8a commit 49d82c7
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Block/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function productAbandoned()
'priceTax' => $this->getPrice($product, true),
'productType' => $product->getTypeId(),
'tags' => [],
'title' => $product->getName(),
'title' => $this->escapeHtml($product->getName()),
'url' => $product->getProductUrl(),
'vendor' => 'magento'
];
Expand Down
71 changes: 70 additions & 1 deletion Helper/EmailMarketing.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@
use Magento\Directory\Model\Currency;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Component\ComponentRegistrarInterface;
use Magento\Framework\DataObject;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Framework\Escaper;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\HTTP\Client\CurlFactory;
use Magento\Framework\HTTP\Client\Curl;
use Magento\Framework\ObjectManagerInterface;
Expand Down Expand Up @@ -267,11 +271,26 @@ class EmailMarketing extends Data
*/
protected $quoteItemFactory;

/**
* @var ComponentRegistrarInterface
*/
protected $componentRegistrar;

/**
* @var ReadFactory
*/
protected $readFactory;

/**
* @var bool
*/
protected $isPUT = false;

/**
* @var string
*/
protected $smtpVersion = '';

/**
* EmailMarketing constructor.
*
Expand Down Expand Up @@ -336,7 +355,9 @@ public function __construct(
ResourceConnection $resourceConnection,
Region $region,
Collection $abandonedCartCollection,
ItemFactory $quoteItemFactory
ItemFactory $quoteItemFactory,
ComponentRegistrarInterface $componentRegistrar,
ReadFactory $readFactory
) {
$this->frontendUrl = $frontendUrl;
$this->escaper = $escaper;
Expand Down Expand Up @@ -365,6 +386,8 @@ public function __construct(
$this->region = $region;
$this->abandonedCartCollection = $abandonedCartCollection;
$this->quoteItemFactory = $quoteItemFactory;
$this->componentRegistrar = $componentRegistrar;
$this->readFactory = $readFactory;

parent::__construct($context, $objectManager, $storeManager);
}
Expand Down Expand Up @@ -1243,10 +1266,56 @@ public function setHeaders($data, $url = '', $appID = '', $secretKey = '', $isTe
$this->_curl->addHeader('X-EmailMarketing-App-Id', $appID);
$this->_curl->addHeader('X-EmailMarketing-Connection-Test', $isTest);
$this->_curl->addHeader('X-EmailMarketing-Integration-Key', $this->getConnectToken($storeId));
$this->_curl->addHeader('X-EmailMarketing-M2-Version', $this->getMagentoVersion());
$this->_curl->addHeader('X-EmailMarketing-SMTP-Version', $this->getSMTPVersion());

return $body;
}

/**
* @return \Magento\Framework\Phrase|string|void
*/
public function getSMTPVersion()
{
if (!$this->smtpVersion) {
$this->smtpVersion = $this->getModuleVersion('Mageplaza_Smtp');
}

return $this->smtpVersion;
}

/**
* Get module composer version
*
* @param string $moduleName
* @return \Magento\Framework\Phrase|string|void
*/
public function getModuleVersion($moduleName)
{
try {
$path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
$directoryRead = $this->readFactory->create($path);
$composerJsonData = $directoryRead->readFile('composer.json');
$data = json_decode($composerJsonData);

return !empty($data->version) ? $data->version : __('UNKNOWN');
} catch (Exception $e) {
return 'error';
}
}

/**
* Get Product version
*
* @return string
*/
public function getMagentoVersion()
{
$productMetadata = $this->objectManager->get(ProductMetadataInterface::class);

return $productMetadata->getVersion();
}

/**
* @return int|string
* @throws NoSuchEntityException
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mageplaza/module-core": "^1.4.11"
},
"type": "magento2-module",
"version": "4.6.2",
"version": "4.6.3",
"license": "proprietary",
"authors": [
{
Expand Down
72 changes: 39 additions & 33 deletions etc/csp_whitelist.xml
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Smtp
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
<policies>
<policy id="script-src">
<values>
<value id="avada" type="host">*.avada.io</value>
</values>
</policy>
</policies>
</csp_whitelist>

<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Smtp
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
<policies>
<policy id="script-src">
<values>
<value id="avada" type="host">*.avada.io</value>
</values>
</policy>
<policy id="connect-src">
<values>
<value id="geojs" type="host">https://get.geojs.io</value>
<value id="avada" type="host">*.avada.io</value>
</values>
</policy>
</policies>
</csp_whitelist>

0 comments on commit 49d82c7

Please sign in to comment.