Skip to content

Commit

Permalink
Merge pull request #1469 from mailchimp/Version-102.3.46
Browse files Browse the repository at this point in the history
Version 102.3.46
  • Loading branch information
gonzaloebiz authored Jul 19, 2022
2 parents 4125657 + 0a49375 commit 6909c5d
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 2 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Change Log

## [102.3.46](https://github.com/mailchimp/mc-magento2/tree/102.3.46) (2022-07-19)

[Full Changelog](https://github.com/mailchimp/mc-magento2/compare/102.3.45...102.3.46)

**Implemented enhancements:**

- Rewrite "This MailChimp account is not connected to Magento" label to make it more clear [\#1448](https://github.com/mailchimp/mc-magento2/issues/1448)
- Add a synchorization column in the customer grid [\#1439](https://github.com/mailchimp/mc-magento2/issues/1439)
- Add a synchorization column in the product grid [\#1438](https://github.com/mailchimp/mc-magento2/issues/1438)
- Add button on backend to create the abandoned cart automation [\#1432](https://github.com/mailchimp/mc-magento2/issues/1432)

**Fixed bugs:**

- Missing fields in Cart.php on db call [\#1460](https://github.com/mailchimp/mc-magento2/issues/1460)
- Wrong field map value when is null [\#1425](https://github.com/mailchimp/mc-magento2/issues/1425)
- Can't get the response file from a batch [\#1414](https://github.com/mailchimp/mc-magento2/issues/1414)
- Unmark the modified flag in the ecommerce table when an object is synced [\#1408](https://github.com/mailchimp/mc-magento2/issues/1408)
- Don't use Zend\_Db\_Select::COLUMNS [\#1405](https://github.com/mailchimp/mc-magento2/issues/1405)

## [102.3.45](https://github.com/mailchimp/mc-magento2/tree/102.3.45)

[Full Changelog](https://github.com/mailchimp/mc-magento2/compare/102.3.44...102.3.45)
Expand Down
2 changes: 2 additions & 0 deletions Ui/Component/Listing/Column/Customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public function prepareDataSource(array $dataSource)
$customer = $this->_customerFactory->create()->load($item['entity_id']);
$params = ['_secure' => $this->_requestInterface->isSecure()];
$alt = '';
$url = '';
$text = '';
if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE, $customer->getStoreId())) {
$mailchimpStoreId = $this->_helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE,
Expand Down
174 changes: 174 additions & 0 deletions Ui/Component/Listing/Column/Products.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?php
namespace Ebizmarts\MailChimp\Ui\Component\Listing\Column;

use Magento\Catalog\Model\ProductFactory;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use \Magento\Ui\Component\Listing\Columns\Column;

class Products extends Column
{
/**
* @var ProductFactory
*/
protected $_productFactory;
/**
* @var RequestInterface
*/
protected $_requestInterface;
/**
* @var \Ebizmarts\MailChimp\Helper\Data
*/
protected $_helper;
/**
* @var \Magento\Framework\View\Asset\Repository
*/
protected $_assetRepository;
/**
* @var \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory
*/
protected $_mailChimpErrorsFactory;

/**
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param ProductFactory $productFactory
* @param RequestInterface $requestInterface
* @param \Ebizmarts\MailChimp\Helper\Data $helper
* @param \Magento\Framework\View\Asset\Repository $assetRepository
* @param \Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $mailChimpErrorsFactory
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
ProductFactory $productFactory,
RequestInterface $requestInterface,
\Ebizmarts\MailChimp\Helper\Data $helper,
\Magento\Framework\View\Asset\Repository $assetRepository,
\Ebizmarts\MailChimp\Model\MailChimpErrorsFactory $mailChimpErrorsFactory,
array $components = [],
array $data = [])
{
$this->_productFactory = $productFactory;
$this->_requestInterface = $requestInterface;
$this->_helper = $helper;
$this->_assetRepository = $assetRepository;
$this->_mailChimpErrorsFactory = $mailChimpErrorsFactory;
parent::__construct($context, $uiComponentFactory, $components, $data);
}

public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
/**
* @var $product \Magento\Catalog\Model\Product
*/
$product = $this->_productFactory->create()->load($item['entity_id']);
$params = ['_secure' => $this->_requestInterface->isSecure()];
$alt = '';
if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE ||
$product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL ||
$product->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE ||
$product->getTypeId() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
$url = '';
$text = '';
if ($this->_helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_PATH_ACTIVE, $product->getStoreId())) {
$mailchimpStoreId = $this->_helper->getConfigValue(
\Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE,
$product->getStoreId()
);
$syncData = $this->_helper->getChimpSyncEcommerce(
$mailchimpStoreId,
$product->getId(),
\Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT
);
if (!$syncData || $syncData->getMailchimpStoreId() != $mailchimpStoreId ||
$syncData->getRelatedId() != $product->getId() ||
$syncData->getType() != \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT) {
$url = $this->_assetRepository->getUrlWithParams(
'Ebizmarts_MailChimp::images/no.png',
$params
);
$text = __('Syncing');
} else {
$sync = $syncData->getMailchimpSent();
switch ($sync) {
case \Ebizmarts\MailChimp\Helper\Data::SYNCED:
$url = $this->_assetRepository->getUrlWithParams(
'Ebizmarts_MailChimp::images/yes.png',
$params
);
$text = __('Synced');
$alt = $syncData->getMailchimpSyncDelta();
break;
case \Ebizmarts\MailChimp\Helper\Data::WAITINGSYNC:
$url = $this->_assetRepository->getUrlWithParams(
'Ebizmarts_MailChimp::images/waiting.png',
$params
);
$text = __('Waiting');
$alt = $syncData->getMailchimpSyncDelta();
break;
case \Ebizmarts\MailChimp\Helper\Data::SYNCERROR:
$url = $this->_assetRepository->getUrlWithParams(
'Ebizmarts_MailChimp::images/error.png',
$params
);
$text = __('Error');
$orderError = $this->_getError($product->getId(), $product->getStoreId());
if ($orderError) {
$alt = $orderError->getErrors();
}
break;
case \Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC:
$url = $this->_assetRepository->getUrlWithParams(
'Ebizmarts_MailChimp::images/resync.png',
$params
);
$text = __('Resyncing');
$alt = $syncData->getMailchimpSyncDelta();
break;
case \Ebizmarts\MailChimp\Helper\Data::NOTSYNCED:
$url = $this->_assetRepository->getUrlWithParams(
'Ebizmarts_MailChimp::images/never.png',
$params
);
$text = __('With error');
$alt = $syncData->getMailchimpSyncError();
break;
default:
$url = $this->_assetRepository->getUrlWithParams(
'Ebizmarts_MailChimp::images/error.png',
$params
);
$text = __('Error');
}
}
}
} else {
$url = $this->_assetRepository->getUrlWithParams(
'Ebizmarts_MailChimp::images/never.png',
$params
);
$text = __('Unsupported');
$alt = "Mailchimp does not support bundled or grouped products.";
}
$item['mailchimp_sync'] =
"<div style='width: 100%;margin: 0 auto;text-align: center'><div><img src='".$url."' style='border: none; width: 5rem; text-align: center; max-width: 100%' title='$alt' /></div><div>$text</div></div>";
}
}
return $dataSource;
}
private function _getError($productId, $storeId)
{
/**
* @var $error \Ebizmarts\MailChimp\Model\MailChimpErrors
*/
$error = $this->_mailChimpErrorsFactory->create();
return $error->getByStoreIdType($storeId, $productId, \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"description": "Connect MailChimp with Magento",
"type": "magento2-module",
"version": "102.3.45",
"version": "102.3.46",
"authors": [
{
"name": "Ebizmarts Corp",
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ebizmarts_MailChimp" setup_version="102.3.45">
<module name="Ebizmarts_MailChimp" setup_version="102.3.46">
<sequence>
<module name="Magento_Newsletter"/>
<module name="Magento_Sales"/>
Expand Down
15 changes: 15 additions & 0 deletions view/adminhtml/ui_component/product_listing.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="product_columns">
<column name="mailchimp_sync" class="\Ebizmarts\MailChimp\Ui\Component\Listing\Column\Products">
<settings>
<altField>mailchimp_sync</altField>
<hasPreview>0</hasPreview>
<addField>true</addField>
<label translate="true">Mailchimp</label>
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
<sortable>false</sortable>
</settings>
</column>
</columns>
</listing>

0 comments on commit 6909c5d

Please sign in to comment.