├── modman ├── view ├── adminhtml │ ├── web │ │ ├── images │ │ │ ├── no.png │ │ │ ├── yes.png │ │ │ ├── error.png │ │ │ ├── never.png │ │ │ ├── freddie.png │ │ │ ├── resync.png │ │ │ └── waiting.png │ │ ├── fonts │ │ │ ├── mailchimp.eot │ │ │ ├── mailchimp.ttf │ │ │ └── mailchimp.woff │ │ ├── css │ │ │ └── styles.css │ │ └── js │ │ │ ├── mailchimpconfirmation.js │ │ │ └── apikey.js │ ├── templates │ │ ├── tab │ │ │ └── view.phtml │ │ └── system │ │ │ └── config │ │ │ ├── js.phtml │ │ │ ├── createwebhook.phtml │ │ │ ├── fixmailchimpjs.phtml │ │ │ ├── resyncproducts.phtml │ │ │ ├── resyncsubscriber.phtml │ │ │ ├── create_abandonedcart_automation.phtml │ │ │ ├── deletestore.phtml │ │ │ ├── reseterrors.phtml │ │ │ ├── reseterrorsnoretry.phtml │ │ │ ├── oauth_wizard.phtml │ │ │ └── resetstore.phtml │ ├── layout │ │ ├── default.xml │ │ ├── mailchimp_batch_index.xml │ │ ├── mailchimp_cron_index.xml │ │ ├── mailchimp_carts_index.xml │ │ ├── mailchimp_errors_index.xml │ │ ├── mailchimp_stores_grid.xml │ │ ├── mailchimp_stores_index.xml │ │ ├── mailchimp_stores_edit.xml │ │ └── customer_index_edit.xml │ ├── ui_component │ │ ├── customer_listing.xml │ │ ├── product_listing.xml │ │ └── sales_order_grid.xml │ └── requirejs-config.js └── frontend │ ├── templates │ ├── mailchimpjs.phtml │ ├── catcher.phtml │ ├── loadquote.phtml │ └── footer.phtml │ ├── requirejs-config.js │ └── layout │ ├── mailchimp_cart_loadquote.xml │ ├── newsletter_manage_index.xml │ ├── checkout_onepage_success.xml │ └── default.xml ├── Model ├── Config │ ├── Source │ │ ├── Timeout.php │ │ ├── CleanPeriod.php │ │ ├── CampaignAction.php │ │ ├── Months.php │ │ ├── WebhookDelete.php │ │ ├── Cmspage.php │ │ ├── MonkeyList.php │ │ ├── Interest.php │ │ └── ApiKey.php │ ├── ModuleVersion.php │ └── Backend │ │ ├── VarsMap.php │ │ └── MonkeyList.php ├── MailchimpNotification.php ├── ResourceModel │ ├── MailchimpNotification.php │ ├── MailchimpNotification │ │ └── Collection.php │ ├── MailChimpInterestGroup │ │ └── Collection.php │ ├── MailChimpStores.php │ ├── MailChimpSyncBatches.php │ ├── MailChimpWebhookRequest.php │ ├── MailChimpStores │ │ ├── Collection.php │ │ └── Grid │ │ │ └── Collection.php │ ├── MailChimpSyncBatches │ │ └── Collection.php │ ├── MailChimpSyncEcommerce │ │ └── Collection.php │ ├── MailChimpWebhookRequest │ │ └── Collection.php │ ├── Carts │ │ └── Collection.php │ ├── MailChimpInterestGroup.php │ ├── Schedule │ │ └── Collection.php │ └── MailChimpErrors.php ├── MailChimpStores.php ├── MailChimpSyncBatches.php ├── MailChimpWebhookRequest.php ├── Logger │ ├── Handler.php │ └── Logger.php ├── MailChimpInterestGroup.php ├── MailChimpErrors.php ├── Plugin │ ├── Coupon.php │ ├── Invoice.php │ ├── Ship.php │ ├── Creditmemo.php │ ├── Quote.php │ └── AccountManagement.php ├── MailChimpSyncEcommerceFactory.php └── MailChimpSyncEcommerce.php ├── etc ├── adminhtml │ ├── routes.xml │ ├── events.xml │ └── menu.xml ├── frontend │ ├── events.xml │ ├── routes.xml │ └── di.xml ├── cron_groups.xml ├── module.xml ├── config.xml ├── fieldset.xml ├── crontab.xml ├── events.xml └── acl.xml ├── Block ├── Loadquote.php ├── Catcher.php ├── Adminhtml │ ├── System │ │ └── Config │ │ │ ├── Date.php │ │ │ ├── Account.php │ │ │ ├── CreateAbandonedCart.php │ │ │ ├── FixMailchimpJS.php │ │ │ ├── ResyncProducts.php │ │ │ ├── ResyncSubscriber.php │ │ │ ├── OauthWizard.php │ │ │ ├── CreateWebhook.php │ │ │ ├── DeleteStore.php │ │ │ ├── ResetStore.php │ │ │ ├── ResetErrors.php │ │ │ ├── ResetErrorsNoRetry.php │ │ │ └── Form │ │ │ └── Field │ │ │ └── CustomerMap.php │ ├── Stores │ │ ├── Edit │ │ │ ├── Form.php │ │ │ └── Tabs.php │ │ └── Edit.php │ └── Customer │ │ └── Edit │ │ └── Tabs │ │ └── View │ │ └── Customer.php ├── Subscribe.php ├── Mailchimpjs.php └── Newsletter.php ├── registration.php ├── Setup ├── InstallData.php └── Uninstall.php ├── composer.json ├── CONTRIBUTING.md ├── Controller ├── Adminhtml │ ├── Stores │ │ ├── Index.php │ │ ├── Delete.php │ │ ├── Edit.php │ │ └── Get.php │ ├── Carts │ │ └── Index.php │ ├── Errors │ │ └── Index.php │ ├── Cron │ │ └── Index.php │ ├── Batch │ │ └── Index.php │ ├── Orders │ │ ├── Campaign.php │ │ └── Member.php │ ├── Stores.php │ ├── Ecommerce │ │ ├── SyncLog.php │ │ ├── ResyncProducts.php │ │ └── ResyncSubscribers.php │ └── Lists │ │ └── Get.php └── Campaign │ └── Check.php ├── Ui └── Component │ ├── Carts │ └── Grid │ │ └── Column │ │ ├── Customer.php │ │ └── Actions.php │ └── Stores │ └── Grid │ └── Column │ └── Actions.php ├── Observer ├── Sales │ └── Order │ │ ├── SubmitBefore.php │ │ ├── SaveAfter.php │ │ └── SubmitAfter.php ├── SalesRule │ └── Rule │ │ ├── DeleteAfter.php │ │ └── SaveAfter.php ├── Adminhtml │ └── Product │ │ ├── DeleteAfter.php │ │ └── SaveAfter.php ├── ConfigObserver.php └── Customer │ └── SaveBefore.php └── Cron ├── WebhookClean.php └── ErrorsClean.php /modman: -------------------------------------------------------------------------------- 1 | * app/code/Ebizmarts/MailChimp 2 | -------------------------------------------------------------------------------- /view/adminhtml/web/images/no.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/images/no.png -------------------------------------------------------------------------------- /view/adminhtml/web/images/yes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/images/yes.png -------------------------------------------------------------------------------- /view/adminhtml/web/images/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/images/error.png -------------------------------------------------------------------------------- /view/adminhtml/web/images/never.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/images/never.png -------------------------------------------------------------------------------- /view/adminhtml/web/fonts/mailchimp.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/fonts/mailchimp.eot -------------------------------------------------------------------------------- /view/adminhtml/web/fonts/mailchimp.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/fonts/mailchimp.ttf -------------------------------------------------------------------------------- /view/adminhtml/web/images/freddie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/images/freddie.png -------------------------------------------------------------------------------- /view/adminhtml/web/images/resync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/images/resync.png -------------------------------------------------------------------------------- /view/adminhtml/web/images/waiting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/images/waiting.png -------------------------------------------------------------------------------- /view/adminhtml/web/fonts/mailchimp.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mailchimp/mc-magento2/HEAD/view/adminhtml/web/fonts/mailchimp.woff -------------------------------------------------------------------------------- /view/frontend/templates/mailchimpjs.phtml: -------------------------------------------------------------------------------- 1 | getJsUrl(); 3 | ?> 4 | 5 | -------------------------------------------------------------------------------- /view/adminhtml/templates/tab/view.phtml: -------------------------------------------------------------------------------- 1 | 4 | getChildHtml(); ?> 5 | -------------------------------------------------------------------------------- /view/frontend/templates/catcher.phtml: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/js.phtml: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /Model/Config/Source/Timeout.php: -------------------------------------------------------------------------------- 1 | 10, 20=> 20, 30=>30]; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /view/adminhtml/layout/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Model/MailchimpNotification.php: -------------------------------------------------------------------------------- 1 | _init(\Ebizmarts\MailChimp\Model\ResourceModel\MailchimpNotification::class); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Model/Config/Source/CleanPeriod.php: -------------------------------------------------------------------------------- 1 | 'One day', 3=> 'Three days', 7=> 'One week']; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/createwebhook.phtml: -------------------------------------------------------------------------------- 1 |
2 | 3 | 6 |
7 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailchimpNotification.php: -------------------------------------------------------------------------------- 1 | _init('mailchimp_notification', 'id'); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/fixmailchimpjs.phtml: -------------------------------------------------------------------------------- 1 |
2 | 3 | 6 |
7 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/resyncproducts.phtml: -------------------------------------------------------------------------------- 1 |
2 | 3 | 6 |
7 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/resyncsubscriber.phtml: -------------------------------------------------------------------------------- 1 |
2 | 3 | 6 |
7 | -------------------------------------------------------------------------------- /view/frontend/templates/loadquote.phtml: -------------------------------------------------------------------------------- 1 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /etc/adminhtml/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /etc/frontend/events.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /view/adminhtml/layout/mailchimp_batch_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /view/adminhtml/layout/mailchimp_cron_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /view/adminhtml/layout/mailchimp_carts_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /view/adminhtml/layout/mailchimp_errors_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Block/Loadquote.php: -------------------------------------------------------------------------------- 1 | 'sent', 'label' => 'Sent'], 9 | ['value' => 'open', 'label' => 'Open'], 10 | ['value' => 'click', 'label' => 'Click'] 11 | ]; 12 | public function toOptionArray() 13 | { 14 | return $this->actions; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailchimpNotification/Collection.php: -------------------------------------------------------------------------------- 1 | _init( 10 | \Ebizmarts\MailChimp\Model\MailchimpNotification::class, 11 | \Ebizmarts\MailChimp\Model\ResourceModel\MailchimpNotification::class 12 | ); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /view/adminhtml/layout/mailchimp_stores_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /view/frontend/requirejs-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ebizmarts_MailChimp Magento JS component 3 | * 4 | * @category Ebizmarts 5 | * @package Ebizmarts_MailChimp 6 | * @author Ebizmarts Team 7 | * @copyright Ebizmarts (http://ebizmarts.com) 8 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 9 | */ 10 | 11 | var config = { 12 | "map": { 13 | "*": { 14 | campaigncatcher: 'Ebizmarts_MailChimp/js/campaigncatcher' 15 | } 16 | } 17 | }; -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | */ 11 | 12 | \Magento\Framework\Component\ComponentRegistrar::register( 13 | \Magento\Framework\Component\ComponentRegistrar::MODULE, 14 | 'Ebizmarts_MailChimp', 15 | __DIR__ 16 | ); 17 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/create_abandonedcart_automation.phtml: -------------------------------------------------------------------------------- 1 |
2 | 5 |
6 | -------------------------------------------------------------------------------- /etc/frontend/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/deletestore.phtml: -------------------------------------------------------------------------------- 1 | 3 |
4 | 5 | 8 |
9 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/reseterrors.phtml: -------------------------------------------------------------------------------- 1 | 3 |
4 | 5 | 8 |
9 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/reseterrorsnoretry.phtml: -------------------------------------------------------------------------------- 1 | 3 |
4 | 5 | 8 |
9 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/oauth_wizard.phtml: -------------------------------------------------------------------------------- 1 |
2 | 3 | 6 |
7 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpInterestGroup/Collection.php: -------------------------------------------------------------------------------- 1 | _init( 16 | \Ebizmarts\MailChimp\Model\MailChimpInterestGroup::class, 17 | \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpInterestGroup::class 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /etc/cron_groups.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 1 6 | 4 7 | 2 8 | 10 9 | 60 10 | 600 11 | 1 12 | 13 | -------------------------------------------------------------------------------- /view/adminhtml/ui_component/customer_listing.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ui/grid/cells/html 8 | false 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Model/Config/Source/Months.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 15/09/22 12:07 PM 11 | * @file: Months.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Model\Config\Source; 14 | 15 | class Months implements \Magento\Framework\Option\ArrayInterface 16 | { 17 | public function toOptionArray() 18 | { 19 | return ["0" => __("No"), "1"=> "1", "2" =>"2", "3" => "3", "4" => "4"]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /view/adminhtml/requirejs-config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ebizmarts_MailChimp Magento JS component 3 | * 4 | * @category Ebizmarts 5 | * @package Ebizmarts_MailChimp 6 | * @author Ebizmarts Team 7 | * @copyright Ebizmarts (http://ebizmarts.com) 8 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 9 | */ 10 | 11 | var config = { 12 | "map": { 13 | "*": { 14 | monkeyapikey: 'Ebizmarts_MailChimp/js/apikey', 15 | configmonkeyapikey: 'Ebizmarts_MailChimp/js/configapikey', 16 | mailchimpconfirmation: 'Ebizmarts_MailChimp/js/mailchimpconfirmation' 17 | } 18 | } 19 | }; -------------------------------------------------------------------------------- /Block/Catcher.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 4/25/17 3:35 PM 11 | * @file: Catcher.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Block; 14 | 15 | use Magento\Framework\View\Element\Template; 16 | 17 | class Catcher extends Template 18 | { 19 | /** 20 | * @var string $_template 21 | */ 22 | protected $_template = "catcher.phtml"; 23 | 24 | // write your methods here... 25 | } 26 | -------------------------------------------------------------------------------- /Model/MailChimpStores.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/21/16 4:55 PM 11 | * @file: MailChimpErrors.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model; 15 | 16 | class MailChimpStores extends \Magento\Framework\Model\AbstractModel 17 | { 18 | protected function _construct() 19 | { 20 | $this->_init(\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpStores::class); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Model/MailChimpSyncBatches.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/17/16 4:07 PM 11 | * @file: MailChimpSyncBatches.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Model; 14 | 15 | class MailChimpSyncBatches extends \Magento\Framework\Model\AbstractModel 16 | { 17 | protected function _construct() 18 | { 19 | $this->_init(\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncBatches::class); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Model/MailChimpWebhookRequest.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 5/26/17 11:32 AM 11 | * @file: MailChimpWebhookRequest.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model; 15 | 16 | class MailChimpWebhookRequest extends \Magento\Framework\Model\AbstractModel 17 | { 18 | protected function _construct() 19 | { 20 | $this->_init(\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpWebhookRequest::class); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /view/frontend/layout/mailchimp_cart_loadquote.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpStores.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 4/3/17 11:42 AM 11 | * @file: MailChimpStores.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model\ResourceModel; 15 | 16 | use Magento\Framework\DB\Select; 17 | use Magento\Framework\Model\ResourceModel\Db\AbstractDb; 18 | 19 | class MailChimpStores extends AbstractDb 20 | { 21 | protected function _construct() 22 | { 23 | $this->_init('mailchimp_stores', 'id'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpSyncBatches.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/17/16 2:27 PM 11 | * @file: MailChimpSyncBatches.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Model\ResourceModel; 14 | 15 | use Magento\Framework\DB\Select; 16 | use Magento\Framework\Model\ResourceModel\Db\AbstractDb; 17 | 18 | class MailChimpSyncBatches extends AbstractDb 19 | { 20 | protected function _construct() 21 | { 22 | $this->_init('mailchimp_sync_batches', 'id'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Model/Logger/Handler.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | */ 11 | 12 | namespace Ebizmarts\MailChimp\Model\Logger; 13 | 14 | use Monolog; 15 | 16 | class Handler extends \Magento\Framework\Logger\Handler\Base 17 | { 18 | /** 19 | * File name 20 | * @var string 21 | */ 22 | protected $fileName = '/var/log/MailChimp.log'; 23 | 24 | /** 25 | * Logging level 26 | * @var int 27 | */ 28 | protected $loggerType = Logger::INFO; 29 | } 30 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpWebhookRequest.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 5/26/17 11:33 AM 11 | * @file: MailChimpWebhookRequest.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Model\ResourceModel; 14 | 15 | use Magento\Framework\DB\Select; 16 | use Magento\Framework\Model\ResourceModel\Db\AbstractDb; 17 | 18 | class MailChimpWebhookRequest extends AbstractDb 19 | { 20 | protected function _construct() 21 | { 22 | $this->_init('mailchimp_webhook_request', 'id'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Model/Config/Source/WebhookDelete.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 5/31/17 11:26 AM 11 | * @file: WebhookDelete.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model\Config\Source; 15 | 16 | class WebhookDelete implements \Magento\Framework\Option\ArrayInterface 17 | { 18 | public function toOptionArray() 19 | { 20 | return [ 21 | ['value' => 0, 'label'=>__('Unsubscribe')], 22 | ['value' => 1, 'label'=>__('Delete subscriber')] 23 | ]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /view/adminhtml/ui_component/product_listing.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | mailchimp_sync 7 | 0 8 | true 9 | 10 | ui/grid/cells/html 11 | false 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpStores/Collection.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 3/27/17 1:22 PM 11 | * @file: Collection.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Model\ResourceModel\MailChimpStores; 14 | 15 | class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult 16 | { 17 | protected function _construct() 18 | { 19 | $this->_init( 20 | \Ebizmarts\MailChimp\Model\MailChimpStores::class, 21 | \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpStores::class 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Block/Adminhtml/System/Config/Date.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 9/30/16 2:38 PM 11 | * @file: Date.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config; 15 | 16 | class Date extends \Magento\Config\Block\System\Config\Form\Field 17 | { 18 | public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) 19 | { 20 | $element->setDateFormat(\Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT); 21 | $element->setTimeFormat(null); 22 | return parent::render($element); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /view/frontend/layout/newsletter_manage_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Setup/InstallData.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/7/16 1:30 PM 11 | * @file: InstallSchema.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Setup; 15 | 16 | use Magento\Eav\Setup\EavSetupFactory; 17 | 18 | use Magento\Framework\Setup\InstallDataInterface; 19 | use Magento\Framework\Setup\ModuleContextInterface; 20 | use Magento\Framework\Setup\ModuleDataSetupInterface; 21 | 22 | class InstallData implements InstallDataInterface 23 | { 24 | 25 | public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) 26 | { 27 | return; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpSyncBatches/Collection.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/21/16 4:16 PM 11 | * @file: Collection.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncBatches; 15 | 16 | class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection 17 | { 18 | protected function _construct() 19 | { 20 | $this->_init( 21 | \Ebizmarts\MailChimp\Model\MailChimpSyncBatches::class, 22 | \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncBatches::class 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpSyncEcommerce/Collection.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 12/1/16 2:36 PM 11 | * @file: Collection.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce; 14 | 15 | class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection 16 | { 17 | protected function _construct() 18 | { 19 | $this->_init( 20 | \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce::class, 21 | \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce::class 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpWebhookRequest/Collection.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 5/26/17 11:36 AM 11 | * @file: Collection.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Model\ResourceModel\MailChimpWebhookRequest; 14 | 15 | class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection 16 | { 17 | protected function _construct() 18 | { 19 | $this->_init( 20 | \Ebizmarts\MailChimp\Model\MailChimpWebhookRequest::class, 21 | \Ebizmarts\MailChimp\Model\ResourceModel\MailChimpWebhookRequest::class 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mailchimp/mc-magento2", 3 | "autoload": { 4 | "psr-4": {"Ebizmarts\\MailChimp\\":""}, 5 | "files": ["registration.php"] 6 | }, 7 | "description": "Connect MailChimp with Magento", 8 | "type": "magento2-module", 9 | "version": "102.3.76", 10 | "authors": [ 11 | { 12 | "name": "Ebizmarts Corp", 13 | "email": "mailchimp@ebizmarts-desk.zendesk.com", 14 | "homepage": "http://ebizmarts.com" 15 | } 16 | ], 17 | "license": [ 18 | "OSL-3.0", 19 | "AFL-3.0" 20 | ], 21 | "support": { 22 | "email": "mailchimp@ebizmarts-desk.zendesk.com", 23 | "wiki": "https://connect.mailchimp.com/integrations/magento", 24 | "forum": "http://ebizmarts.com/forums/view/6" 25 | }, 26 | "require" : { 27 | "magento/framework": "102.0.*", 28 | "ebizmarts/mailchimp-lib": ">=3.0.44", 29 | "ext-json": "*" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 7 8 | 9 | 10 | sent,open,click 11 | Yes 12 | 13 | 14 | f71334c7039eb7f6574676bd5f43b6bc 15 | https://logs-mc4mage.ebizmarts.com/batches 16 | https://users-mc4mage.ebizmarts.com 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ### Contribution requirements 2 | 3 | 1. Contributions must adhere to [Magento coding standards](http://devdocs.magento.com/guides/v2.0/coding-standards/bk-coding-standards.html). 4 | 2. Pull requests (PRs) must be accompanied by a meaningful description of their purpose. Comprehensive descriptions increase the chances that a pull request is merged quickly and without additional clarification requests. 5 | 3. Commits must be accompanied by meaningful commit messages. (include a **closes** in the commit that close the issue) 6 | 4. PRs that include bug fixing must be accompanied by the creation of an issue describing the bug following this [Issue reporting guidelines](https://github.com/mailchimp/mc-magento2/wiki/Issue-reporting-guidelines). 7 | 5. For large features or changes, please open an issue and discuss first. This may prevent duplicate or unnecessary effort, and it may gain you some additional contributors. 8 | -------------------------------------------------------------------------------- /view/frontend/layout/checkout_onepage_success.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /etc/frontend/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /view/adminhtml/layout/mailchimp_stores_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Ebizmarts_MailChimp::stores 8 | 9 | 10 | 11 | 12 | complex 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Model/MailChimpInterestGroup.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 11/20/17 3:43 PM 11 | * @file: MailChimpInterestGroup.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model; 15 | 16 | class MailChimpInterestGroup extends \Magento\Framework\Model\AbstractModel 17 | { 18 | protected function _construct() 19 | { 20 | parent::_construct(); 21 | $this->_init(\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpInterestGroup::class); 22 | } 23 | public function getBySubscriberIdStoreId($subscriberId, $storeId) 24 | { 25 | $this->getResource()->getBySubscriberIdStoreId($this, $subscriberId, $storeId); 26 | return $this; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Stores/Index.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 3/24/17 10:38 AM 11 | * @file: Index.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Controller\Adminhtml\Stores; 14 | 15 | use Ebizmarts\MailChimp\Controller\Adminhtml\Stores; 16 | 17 | class Index extends Stores 18 | { 19 | public function execute() 20 | { 21 | $this->_mhelper->loadStores(); 22 | $page = $this->_resultPageFactory->create(); 23 | $page->getConfig()->getTitle()->prepend(__('Mailchimp Stores')); 24 | return $page; 25 | } 26 | protected function _isAllowed() 27 | { 28 | return $this->_authorization->isAllowed('Ebizmarts_MailChimp::stores_grid'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /view/adminhtml/web/css/styles.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'mailchimp'; 3 | src: url('../fonts/mailchimp.eot?3g8ubh'); 4 | src: url('../fonts/mailchimp.eot?3g8ubh#iefix') format('embedded-opentype'), 5 | url('../fonts/mailchimp.ttf?3g8ubh') format('truetype'), 6 | url('../fonts/mailchimp.woff?3g8ubh') format('woff'), 7 | url('../fonts/mailchimp.svg?3g8ubh#mailchimp') format('svg'); 8 | font-weight: normal; 9 | font-style: normal;} 10 | .admin__menu .item-mailchimp-menu.parent.level-0 > a:before { 11 | font-family: 'mailchimp'; 12 | content: "\e991" 13 | } 14 | 15 | .admin__data-grid-wrap .data-grid .data-grid-draggable .data-row .data-grid-thumbnail-cell .admin__control-thumbnail > img:before { 16 | border:none; 17 | } 18 | 19 | .freddie { 20 | background-image:url('../images/freddie.png'); 21 | background-repeat:no-repeat; 22 | font-size:0px; 23 | display:block; 24 | background-size: 20px; 25 | background-position: right bottom; 26 | } 27 | -------------------------------------------------------------------------------- /Model/Config/Source/Cmspage.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 9/30/16 2:46 PM 11 | * @file: Cmspage.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model\Config\Source; 15 | 16 | class Cmspage 17 | { 18 | /** 19 | * @var \Magento\Cms\Model\Page 20 | */ 21 | private $_page; 22 | /** 23 | * @param \Magento\Cms\Model\Page $page 24 | */ 25 | public function __construct( 26 | \Magento\Cms\Model\Page $page 27 | ) { 28 | $this->_page = $page; 29 | } 30 | public function toOptionArray() 31 | { 32 | $pages = $this->_page->getCollection()->addOrder('title', 'asc'); 33 | return ['checkout/cart' => 'Shopping Cart (default page)'] + $pages->toOptionIdArray(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /etc/fieldset.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 |
28 |
-------------------------------------------------------------------------------- /view/frontend/templates/footer.phtml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 32 | -------------------------------------------------------------------------------- /Model/MailChimpErrors.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/21/16 4:55 PM 11 | * @file: MailChimpErrors.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model; 15 | 16 | class MailChimpErrors extends \Magento\Framework\Model\AbstractModel 17 | { 18 | protected function _construct() 19 | { 20 | $this->_init(\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpErrors::class); 21 | } 22 | public function getByStoreIdType($storeId, $id, $type) 23 | { 24 | $this->getResource()->getByStoreIdType($this, $storeId, $id, $type); 25 | return $this; 26 | } 27 | public function deleteByStorePeriod($storeId, $interval, $limit) 28 | { 29 | return $this->getResource()->deleteByStorePeriod($this, $storeId, $interval, $limit); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /view/adminhtml/ui_component/sales_order_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ui/grid/cells/html 8 | false 9 | 10 | 11 | 12 | 13 | 14 | id 15 | MailChimp 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Block/Subscribe.php: -------------------------------------------------------------------------------- 1 | context = $context; 32 | $this->helper = $helper; 33 | } 34 | 35 | public function getPopupUrl() 36 | { 37 | 38 | $storeId = $this->context->getStoreManager()->getStore()->getId(); 39 | return $this->helper->getConfigValue(MailchimpHelper::XML_POPUP_URL,$storeId); 40 | } 41 | } -------------------------------------------------------------------------------- /Block/Adminhtml/Stores/Edit/Form.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 4/10/17 4:04 PM 11 | * @file: Form.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit; 15 | 16 | use Magento\Backend\Block\Widget\Form\Generic; 17 | 18 | class Form extends Generic 19 | { 20 | protected function _prepareForm() 21 | { 22 | /** @var \Magento\Framework\Data\Form $form */ 23 | $form = $this->_formFactory->create( 24 | [ 25 | 'data' => [ 26 | 'id' => 'edit_form', 27 | 'action' => $this->getData('action'), 28 | 'method' => 'post' 29 | ] 30 | ] 31 | ); 32 | $form->setUseContainer(true); 33 | $this->setForm($form); 34 | 35 | return parent::_prepareForm(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Ui/Component/Carts/Grid/Column/Customer.php: -------------------------------------------------------------------------------- 1 | escaper = $escaper; 19 | parent::__construct($context, $uiComponentFactory, $components, $data); 20 | } 21 | public function prepareDataSource(array $dataSource) 22 | { 23 | if (isset($dataSource['data']['items'])) { 24 | foreach ($dataSource['data']['items'] as & $item) { 25 | $item[$this->getData('name')] = $item['customer_firstname'] . ' ' . $item['customer_lastname']; 26 | } 27 | } 28 | 29 | return $dataSource; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Model/Plugin/Coupon.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/23/17 1:32 PM 11 | * @file: Coupon.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model\Plugin; 15 | 16 | use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; 17 | 18 | class Coupon 19 | { 20 | /** 21 | * @var SyncHelper 22 | */ 23 | protected $syncHelper; 24 | 25 | /** 26 | * @param SyncHelper $syncHelper 27 | */ 28 | public function __construct( 29 | SyncHelper $syncHelper 30 | ) { 31 | $this->syncHelper = $syncHelper; 32 | } 33 | public function afterAfterDelete(\Magento\SalesRule\Model\Coupon $coupon) 34 | { 35 | $this->syncHelper->markEcommerceAsDeleted( 36 | $coupon->getCouponId(), 37 | \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_CODE, 38 | $coupon->getRuleId() 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Carts/Index.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 22 | 23 | parent::__construct($context); 24 | } 25 | public function execute() 26 | { 27 | $page = $this->resultPageFactory->create(); 28 | $page->getConfig()->getTitle()->prepend(__('Mailchimp Carts')); 29 | return $page; 30 | } 31 | protected function _isAllowed() 32 | { 33 | return $this->_authorization->isAllowed('Ebizmarts_MailChimp::carts_grid'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /view/adminhtml/templates/system/config/resetstore.phtml: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | escapeHtml('Reset errors')); ?> 25 | 26 | 27 |
28 | 29 | 32 |
33 | -------------------------------------------------------------------------------- /etc/adminhtml/events.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /view/adminhtml/layout/mailchimp_stores_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Block/Adminhtml/System/Config/Account.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | */ 11 | 12 | namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config; 13 | 14 | class Account extends \Magento\Config\Block\System\Config\Form\Field 15 | { 16 | protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) 17 | { 18 | $values = $element->getValues(); 19 | $html = '
'; 20 | $html .= '
    '; 21 | if ($values) { 22 | foreach ($values as $dat) { 23 | if ($dat['value']!=='') { 24 | $html .= "
  • {$dat['label']}: {$dat['value']}
  • "; 25 | } else { 26 | $html .= "
  • {$dat['label']}
  • "; 27 | } 28 | } 29 | } 30 | 31 | $html .= '
'; 32 | $html .= '
'; 33 | 34 | return $html; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Block/Adminhtml/System/Config/CreateAbandonedCart.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | */ 11 | 12 | namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config; 13 | 14 | class CreateAbandonedCart extends \Magento\Config\Block\System\Config\Form\Field 15 | { 16 | protected $_template = 'system/config/create_abandonedcart_automation.phtml'; 17 | 18 | private $_url = "https://admin.mailchimp.com/#/create-campaign/explore/abandonedCart"; 19 | 20 | protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) 21 | { 22 | $originalData = $element->getOriginalData(); 23 | 24 | $label = $originalData['button_label']; 25 | 26 | $this->addData([ 27 | 'button_label' => __($label), 28 | 'button_url' => $this->authorizeRequestUrl(), 29 | 'html_id' => $element->getHtmlId(), 30 | ]); 31 | return parent::_toHtml(); 32 | ; 33 | } 34 | public function authorizeRequestUrl() 35 | { 36 | return $this->_url; 37 | } 38 | } -------------------------------------------------------------------------------- /view/adminhtml/layout/customer_index_edit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 50 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Model/MailChimpSyncEcommerceFactory.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 2/28/17 7:24 PM 11 | * @file: MailChimpSyncEcommerceFactory.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model; 15 | 16 | class MailChimpSyncEcommerceFactory 17 | { 18 | 19 | protected $_objectManager; 20 | protected $_instanceName; 21 | 22 | /** 23 | * MailChimpSyncEcommerceFactory constructor. 24 | * @param \Magento\Framework\ObjectManagerInterface $objectManager 25 | * @param string $instanceName 26 | */ 27 | public function __construct( 28 | \Magento\Framework\ObjectManagerInterface $objectManager, 29 | $instanceName = \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce::class 30 | ) { 31 | 32 | $this->_objectManager = $objectManager; 33 | $this->_instanceName = $instanceName; 34 | } 35 | 36 | /** 37 | * @param array $data 38 | * @return \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce 39 | */ 40 | public function create(array $data = []) 41 | { 42 | return $this->_objectManager->create($this->_instanceName, $data); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /view/frontend/layout/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Ebizmarts_MailChimp::footer.phtml 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Model/ResourceModel/Carts/Collection.php: -------------------------------------------------------------------------------- 1 | getSelect() 27 | ->where( 28 | "type = 'QUO'" 29 | ); 30 | $this->getSelect()->join(['alias' => $this->getTable('quote')], 'main_table.related_id = alias.entity_id', 31 | ['customer_id', 'customer_email','customer_firstname','customer_lastname','items_count','items_qty','created_at','updated_at','grand_total']); 32 | return $this; 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Errors/Index.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/28/16 4:58 PM 11 | * @file: Index.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Controller\Adminhtml\Errors; 14 | 15 | class Index extends \Magento\Backend\App\Action 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | protected $resultPageFactory; 21 | 22 | /** 23 | * Index constructor. 24 | * @param \Magento\Backend\App\Action\Context $context 25 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory 26 | */ 27 | public function __construct( 28 | \Magento\Backend\App\Action\Context $context, 29 | \Magento\Framework\View\Result\PageFactory $resultPageFactory 30 | ) { 31 | 32 | $this->resultPageFactory = $resultPageFactory; 33 | return parent::__construct($context); 34 | } 35 | public function execute() 36 | { 37 | $page = $this->resultPageFactory->create(); 38 | $page->getConfig()->getTitle()->prepend(__('Mailchimp Errors')); 39 | return $page; 40 | } 41 | protected function _isAllowed() 42 | { 43 | return $this->_authorization->isAllowed('Ebizmarts_MailChimp::error_grid'); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Cron/Index.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/28/16 4:58 PM 11 | * @file: Index.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Controller\Adminhtml\Cron; 14 | 15 | class Index extends \Magento\Backend\App\Action 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | protected $resultPageFactory; 21 | 22 | /** 23 | * Index constructor. 24 | * @param \Magento\Backend\App\Action\Context $context 25 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory 26 | */ 27 | public function __construct( 28 | \Magento\Backend\App\Action\Context $context, 29 | \Magento\Framework\View\Result\PageFactory $resultPageFactory 30 | ) { 31 | 32 | $this->resultPageFactory = $resultPageFactory; 33 | return parent::__construct($context); 34 | } 35 | public function execute() 36 | { 37 | $page = $this->resultPageFactory->create(); 38 | $page->getConfig()->getTitle()->prepend(__('Mailchimp Cron')); 39 | return $page; 40 | } 41 | protected function _isAllowed() 42 | { 43 | return $this->_authorization->isAllowed('Ebizmarts_MailChimp::cron_grid'); 44 | } 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /Controller/Adminhtml/Batch/Index.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/28/16 4:58 PM 11 | * @file: Index.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Controller\Adminhtml\Batch; 14 | 15 | class Index extends \Magento\Backend\App\Action 16 | { 17 | /** 18 | * @var \Magento\Framework\View\Result\PageFactory 19 | */ 20 | protected $resultPageFactory; 21 | 22 | /** 23 | * Index constructor. 24 | * @param \Magento\Backend\App\Action\Context $context 25 | * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory 26 | */ 27 | public function __construct( 28 | \Magento\Backend\App\Action\Context $context, 29 | \Magento\Framework\View\Result\PageFactory $resultPageFactory 30 | ) { 31 | 32 | $this->resultPageFactory = $resultPageFactory; 33 | return parent::__construct($context); 34 | } 35 | public function execute() 36 | { 37 | $page = $this->resultPageFactory->create(); 38 | $page->getConfig()->getTitle()->prepend(__('Mailchimp Batches')); 39 | return $page; 40 | } 41 | protected function _isAllowed() 42 | { 43 | return $this->_authorization->isAllowed('Ebizmarts_MailChimp::batch_grid'); 44 | } 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpInterestGroup.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 11/20/17 3:51 PM 11 | * @file: MailChimpInterestGroup.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model\ResourceModel; 15 | 16 | use Magento\Framework\DB\Select; 17 | use Magento\Framework\Model\ResourceModel\Db\AbstractDb; 18 | 19 | class MailChimpInterestGroup extends AbstractDb 20 | { 21 | protected function _construct() 22 | { 23 | $this->_init('mailchimp_interest_group', 'id'); 24 | } 25 | public function getBySubscriberIdStoreId( 26 | \Ebizmarts\MailChimp\Model\MailChimpInterestGroup $mailChimpInterestGroup, 27 | $subscriberId, 28 | $storeId 29 | ) { 30 | $connection = $this->getConnection(); 31 | $bind = ['subscriber_id'=>$subscriberId, 'store_id' => $storeId]; 32 | $select = $connection->select()->from( 33 | $this->getTable('mailchimp_interest_group') 34 | )->where( 35 | 'subscriber_id = :subscriber_id AND store_id = :store_id' 36 | ); 37 | $data = $connection->fetchRow($select, $bind); 38 | if ($data) { 39 | $mailChimpInterestGroup->setData($data); 40 | } 41 | return $mailChimpInterestGroup; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Block/Adminhtml/System/Config/FixMailchimpJS.php: -------------------------------------------------------------------------------- 1 | _helper = $helper; 30 | parent::__construct($context, $data); 31 | } 32 | 33 | protected function _construct() 34 | { 35 | parent::_construct(); 36 | $this->setTemplate('system/config/fixmailchimpjs.phtml'); 37 | } 38 | 39 | protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) 40 | { 41 | $originalData = $element->getOriginalData(); 42 | $this->addData( 43 | [ 44 | 'button_label' => __($originalData['button_label']), 45 | 'html_id' => $element->getHtmlId(), 46 | ] 47 | ); 48 | return $this->_toHtml(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Block/Adminhtml/System/Config/ResyncProducts.php: -------------------------------------------------------------------------------- 1 | _helper = $helper; 30 | parent::__construct($context, $data); 31 | } 32 | 33 | protected function _construct() 34 | { 35 | parent::_construct(); 36 | $this->setTemplate('system/config/resyncproducts.phtml'); 37 | } 38 | 39 | protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) 40 | { 41 | $originalData = $element->getOriginalData(); 42 | $this->addData( 43 | [ 44 | 'button_label' => __($originalData['button_label']), 45 | 'html_id' => $element->getHtmlId(), 46 | ] 47 | ); 48 | return $this->_toHtml(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Observer/Sales/Order/SubmitBefore.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 3/14/17 11:26 PM 11 | * @file: SaveBefore.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Observer\Sales\Order; 14 | 15 | use Magento\Framework\Event\Observer; 16 | 17 | class SubmitBefore implements \Magento\Framework\Event\ObserverInterface 18 | { 19 | private $attributes = [ 20 | 'mailchimp_abandonedcart_flag', 21 | 'mailchimp_campaign_id', 22 | 'mailchimp_landing_page' 23 | ]; 24 | public function execute(\Magento\Framework\Event\Observer $observer) 25 | { 26 | /* @var \Magento\Sales\Model\Order $order */ 27 | $order = $observer->getEvent()->getData('order'); 28 | /* @var \Magento\Quote\Model\Quote $quote */ 29 | $quote = $observer->getEvent()->getData('quote'); 30 | $flag = 0; 31 | 32 | foreach ($this->attributes as $attribute) { 33 | if ($quote->hasData($attribute)) { 34 | $order->setData($attribute, $quote->getData($attribute)); 35 | if ($quote->getData($attribute)) { 36 | $flag = 1; 37 | } 38 | } 39 | } 40 | $order->setData('mailchimp_flag', $flag); 41 | return $this; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Block/Adminhtml/System/Config/ResyncSubscriber.php: -------------------------------------------------------------------------------- 1 | _helper = $helper; 30 | parent::__construct($context, $data); 31 | } 32 | 33 | protected function _construct() 34 | { 35 | parent::_construct(); 36 | $this->setTemplate('system/config/resyncsubscriber.phtml'); 37 | } 38 | 39 | protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) 40 | { 41 | $originalData = $element->getOriginalData(); 42 | $this->addData( 43 | [ 44 | 'button_label' => __($originalData['button_label']), 45 | 'html_id' => $element->getHtmlId(), 46 | ] 47 | ); 48 | return $this->_toHtml(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Observer/SalesRule/Rule/DeleteAfter.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/19/17 5:26 PM 11 | * @file: DeleteAfter.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Observer\SalesRule\Rule; 14 | 15 | use Magento\Framework\Event\Observer; 16 | use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; 17 | 18 | class DeleteAfter implements \Magento\Framework\Event\ObserverInterface 19 | { 20 | /** 21 | * @var \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce 22 | */ 23 | protected $_ecommerce; 24 | /** 25 | * @var SyncHelper 26 | */ 27 | private $syncHelper; 28 | 29 | /** 30 | * @param \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $ecommerce 31 | * @param SyncHelper $syncHelper 32 | */ 33 | public function __construct( 34 | \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $ecommerce, 35 | SyncHelper $syncHelper 36 | ) { 37 | $this->_ecommerce = $ecommerce; 38 | $this->syncHelper = $syncHelper; 39 | } 40 | 41 | public function execute(\Magento\Framework\Event\Observer $observer) 42 | { 43 | $rule = $observer->getEvent()->getRule(); 44 | $ruleId = $rule->getRuleId(); 45 | $this->syncHelper->markEcommerceAsDeleted($ruleId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Model/ResourceModel/Schedule/Collection.php: -------------------------------------------------------------------------------- 1 | getSelect() 32 | ->where( 33 | "job_code IN ( 34 | 'ebizmarts_webhooks', 35 | 'ebizmarts_ecommerce', 36 | 'ebizmarts_clean_webhooks', 37 | 'ebizmarts_clean_batches', 38 | 'ebizmarts_clean_errors' 39 | )" 40 | ); 41 | return $this; 42 | 43 | }//end _initSelect() 44 | 45 | 46 | }//end class 47 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpStores/Grid/Collection.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | */ 11 | 12 | namespace Ebizmarts\MailChimp\Model\Logger; 13 | 14 | class Logger extends \Monolog\Logger 15 | { 16 | 17 | public function mailchimpLog($message, $file) 18 | { 19 | if ($file) { 20 | $fileName = BP. DIRECTORY_SEPARATOR .'var'. DIRECTORY_SEPARATOR.'log'. 21 | DIRECTORY_SEPARATOR.$file.'_Request.log'; 22 | $this->pushHandler(new \Monolog\Handler\StreamHandler($fileName)); 23 | } 24 | 25 | try { 26 | if ($message===null) { 27 | $message = "NULL"; 28 | } 29 | if (is_array($message)) { 30 | $message = json_encode($message, JSON_PRETTY_PRINT); 31 | } 32 | if (is_object($message)) { 33 | $message = json_encode($message, JSON_PRETTY_PRINT); 34 | } 35 | if (!empty(json_last_error())) { 36 | $message = (string)json_last_error(); 37 | } 38 | $message = (string)$message; 39 | } catch (\Exception $e) { 40 | $message = "INVALID MESSAGE"; 41 | } 42 | $message .= "\r\n"; 43 | $this->info($message); 44 | if ($file) { 45 | $this->popHandler(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Ui/Component/Carts/Grid/Column/Actions.php: -------------------------------------------------------------------------------- 1 | urlBuilder = $urlBuilder; 19 | parent::__construct($context, $uiComponentFactory, $components, $data); 20 | } 21 | public function prepareDataSource(array $dataSource) 22 | { 23 | if (isset($dataSource['data']['items'])) { 24 | foreach ($dataSource['data']['items'] as &$item) { 25 | $customerId = $item['customer_id']; 26 | if ($customerId) { 27 | $item[$this->getData('name')] = [ 28 | 'viewcustomer' => [ 29 | 'href' => $this->urlBuilder->getUrl( 30 | 'customer/index/edit', 31 | ['id' => $customerId] 32 | ), 33 | 'label' => 'View Customer', 34 | 'target' => '_blank' 35 | ] 36 | ]; 37 | } 38 | } 39 | } 40 | return $dataSource; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Cron/WebhookClean.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 22/11/18 10:02 AM 11 | * @file: WebhookClean.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Cron; 14 | 15 | class WebhookClean 16 | { 17 | /** 18 | * @var \Ebizmarts\MailChimp\Helper\Data 19 | */ 20 | protected $helper; 21 | /** 22 | * @var \Ebizmarts\MailChimp\Model\MailChimpWebhookRequest 23 | */ 24 | protected $webhooks; 25 | 26 | /** 27 | * WebhookClean constructor. 28 | * @param \Ebizmarts\MailChimp\Helper\Data $helper 29 | * @param \Ebizmarts\MailChimp\Model\MailChimpWebhookRequest $webhookRequest 30 | */ 31 | public function __construct( 32 | \Ebizmarts\MailChimp\Helper\Data $helper, 33 | \Ebizmarts\MailChimp\Model\MailChimpWebhookRequest $webhookRequest 34 | ) { 35 | $this->helper = $helper; 36 | $this->webhooks = $webhookRequest; 37 | } 38 | public function execute() 39 | { 40 | try { 41 | $connection = $this->webhooks->getResource()->getConnection(); 42 | $tableName = $this->webhooks->getResource()->getMainTable(); 43 | $quoteInto = $connection->quoteInto('processed = ? and date_add(fired_at, interval 1 month) < now()', 1); 44 | $connection->delete($tableName, $quoteInto); 45 | } catch (\Exception $e) { 46 | $this->helper->log($e->getMessage()); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Block/Adminhtml/System/Config/OauthWizard.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | */ 11 | 12 | namespace Ebizmarts\MailChimp\Block\Adminhtml\System\Config; 13 | 14 | class OauthWizard extends \Magento\Config\Block\System\Config\Form\Field 15 | { 16 | protected $_template = 'system/config/oauth_wizard.phtml'; 17 | 18 | private $_authorizeUri = "https://login.mailchimp.com/oauth2/authorize"; 19 | private $_accessTokenUri = "https://login.mailchimp.com/oauth2/token"; 20 | private $_redirectUri = "https://ebizmarts.com/magento/mc-magento2/oauth2/complete.php"; 21 | private $_clientId = 390007044048; 22 | 23 | protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element) 24 | { 25 | $originalData = $element->getOriginalData(); 26 | 27 | $label = $originalData['button_label']; 28 | 29 | $this->addData([ 30 | 'button_label' => __($label), 31 | 'button_url' => $this->authorizeRequestUrl(), 32 | 'html_id' => $element->getHtmlId(), 33 | ]); 34 | return parent::_toHtml(); 35 | ; 36 | } 37 | public function authorizeRequestUrl() 38 | { 39 | 40 | $url = $this->_authorizeUri; 41 | $redirectUri = urlencode($this->_redirectUri); 42 | 43 | return "{$url}?redirect_uri={$redirectUri}&response_type=code&client_id={$this->_clientId}"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Setup/Uninstall.php: -------------------------------------------------------------------------------- 1 | [ 23 | 'mailchimp_abandonedcart_flag', 24 | 'mailchimp_campaign_id', 25 | 'mailchimp_landing_page', 26 | 'mailchimp_flag' 27 | ], 28 | 'quote' => [ 29 | 'mailchimp_abandonedcart_flag', 30 | 'mailchimp_campaign_id', 31 | 'mailchimp_landing_page' 32 | ], 33 | 'sales_order_grid' => [ 34 | 'mailchimp_flag' 35 | ] 36 | ]; 37 | $installer = $setup; 38 | $installer->startSetup(); 39 | $connection = $installer->getConnection(); 40 | foreach ($tables as $table) { 41 | $connection->dropTable($setup->getTable($table)); 42 | } 43 | foreach($tablesFields as $table => $columnArray) { 44 | foreach($columnArray as $column) { 45 | $connection->dropColumn( $setup->getTable($table), $column); 46 | } 47 | } 48 | 49 | $installer->endSetup(); 50 | } 51 | } -------------------------------------------------------------------------------- /Controller/Adminhtml/Stores/Delete.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 4/17/17 12:03 PM 11 | * @file: Delete.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Controller\Adminhtml\Stores; 15 | 16 | class Delete extends \Ebizmarts\MailChimp\Controller\Adminhtml\Stores 17 | { 18 | public function execute() 19 | { 20 | $resultRedirect = $this->resultRedirectFactory->create(); 21 | $storeId = (int) $this->getRequest()->getParam('id'); 22 | if ($storeId) { 23 | $storeModel = $this->_mailchimpStoresFactory->create(); 24 | $storeModel->getResource()->load($storeModel, $storeId); 25 | try { 26 | $api = $this->_mhelper->getApiByApiKey($storeModel->getApikey(), true); 27 | $api->ecommerce->stores->delete($storeModel->getStoreid()); 28 | $this->messageManager->addSuccess(__('You deleted the store.')); 29 | return $resultRedirect->setPath('mailchimp/stores'); 30 | } catch (\Mailchimp_Error | \Mailchimp_HttpError $e) { 31 | $this->messageManager->addError(__('Store could not be deleted.'.$e->getMessage())); 32 | $this->_mhelper->log($e->getFriendlyMessage()); 33 | return $resultRedirect->setPath('mailchimp/stores/edit', ['id'=>$storeId]); 34 | } 35 | } 36 | } 37 | protected function _isAllowed() 38 | { 39 | return $this->_authorization->isAllowed('Ebizmarts_MailChimp::stores_edit'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Model/ResourceModel/MailChimpErrors.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/17/16 1:57 PM 11 | * @file: MailChimpError.php 12 | */ 13 | namespace Ebizmarts\MailChimp\Model\ResourceModel; 14 | 15 | use Magento\Framework\DB\Select; 16 | use Magento\Framework\Model\ResourceModel\Db\AbstractDb; 17 | 18 | class MailChimpErrors extends AbstractDb 19 | { 20 | protected function _construct() 21 | { 22 | $this->_init('mailchimp_errors', 'id'); 23 | } 24 | public function getByStoreIdType(\Ebizmarts\MailChimp\Model\MailChimpErrors $errors, $storeId, $id, $type) 25 | { 26 | $connection = $this->getConnection(); 27 | $bind = ['store_id' => $storeId, 'regtype' => $type, 'original_id' => $id]; 28 | $select = $connection->select()->from( 29 | $this->getTable('mailchimp_errors') 30 | )->where( 31 | 'store_id = :store_id AND regtype = :regtype AND original_id = :original_id' 32 | ); 33 | $data = $connection->fetchRow($select, $bind); 34 | if ($data) { 35 | $errors->setData($data); 36 | } 37 | return $errors; 38 | } 39 | public function deleteByStorePeriod(\Ebizmarts\MailChimp\Model\MailChimpErrors $errors, $storeId, $interval, $limit) 40 | { 41 | $connection = $this->getConnection(); 42 | $table = $this->getTable('mailchimp_errors'); 43 | $ret = $connection->query("DELETE FROM $table WHERE date_add(added_at, interval $interval month) < now() AND store_id = $storeId LIMIT $limit"); 44 | return $ret; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Observer/Adminhtml/Product/DeleteAfter.php: -------------------------------------------------------------------------------- 1 | helper = $helper; 39 | $this->syncHelper = $syncHelper; 40 | $this->configurable = $configurable; 41 | } 42 | function execute(Observer $observer) 43 | { 44 | $product = $observer->getProduct(); 45 | $mailchimpStore = $this->helper->getConfigValue( 46 | \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, 47 | $product->getStoreId() 48 | ); 49 | $this->_updateProduct($product->getId()); 50 | } 51 | protected function _updateProduct($entityId) 52 | { 53 | $this->syncHelper->markEcommerceAsDeleted($entityId, \Ebizmarts\MailChimp\Helper\Data::IS_PRODUCT); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Observer/SalesRule/Rule/SaveAfter.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/19/17 4:14 PM 11 | * @file: Rule.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Observer\SalesRule\Rule; 15 | 16 | use Magento\Framework\Event\Observer; 17 | use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; 18 | 19 | class SaveAfter implements \Magento\Framework\Event\ObserverInterface 20 | { 21 | /** 22 | * @var \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce 23 | */ 24 | protected $_ecommerce; 25 | /** 26 | * @var SyncHelper 27 | */ 28 | protected $syncHelper; 29 | protected $_date; 30 | 31 | /** 32 | * @param \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $ecommerce 33 | * @param SyncHelper $syncHelper 34 | * @param \Magento\Framework\Stdlib\DateTime\DateTime $date 35 | */ 36 | public function __construct( 37 | \Ebizmarts\MailChimp\Model\MailChimpSyncEcommerce $ecommerce, 38 | SyncHelper $syncHelper, 39 | \Magento\Framework\Stdlib\DateTime\DateTime $date 40 | ) { 41 | 42 | $this->_ecommerce = $ecommerce; 43 | $this->syncHelper = $syncHelper; 44 | $this->_date = $date; 45 | } 46 | 47 | public function execute(\Magento\Framework\Event\Observer $observer) 48 | { 49 | /** 50 | * @var $rule \Magento\SalesRule\Model\Rule 51 | */ 52 | $rule = $observer->getEvent()->getRule(); 53 | $ruleId = $rule->getRuleId(); 54 | $this->syncHelper->markRegisterAsModified($ruleId, \Ebizmarts\MailChimp\Helper\Data::IS_PROMO_RULE); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /etc/crontab.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 18 | */5 * * * * 19 | 20 | 21 | */5 * * * * 22 | 23 | 24 | 0 * * * * 25 | 26 | 27 | 0 * * * * 28 | 29 | 30 | 0 * * * * 31 | 32 | 33 | 0 */12 * * * 34 | 35 | 36 | 0 */1 * * * 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Model/Plugin/Invoice.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * 11 | */ 12 | namespace Ebizmarts\MailChimp\Model\Plugin; 13 | 14 | use Magento\Sales\Api\Data\InvoiceInterface; 15 | use Magento\Sales\Model\Order\Invoice as SalesInvoice; 16 | use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; 17 | 18 | class Invoice 19 | { 20 | /** 21 | * @var \Ebizmarts\MailChimp\Helper\Data 22 | */ 23 | private $_helper; 24 | /** 25 | * @var SyncHelper 26 | */ 27 | private $syncHelper; 28 | 29 | /** 30 | * @param \Ebizmarts\MailChimp\Helper\Data $helper 31 | * @param SyncHelper $syncHelper 32 | */ 33 | public function __construct( 34 | \Ebizmarts\MailChimp\Helper\Data $helper, 35 | SyncHelper $syncHelper 36 | ) { 37 | $this->_helper = $helper; 38 | $this->syncHelper = $syncHelper; 39 | } 40 | public function afterSave( 41 | SalesInvoice $subject, 42 | InvoiceInterface $invoice 43 | ) { 44 | $mailchimpStoreId = $this->_helper->getConfigValue( 45 | \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, 46 | $invoice->getStoreId() 47 | ); 48 | $this->syncHelper->saveEcommerceData( 49 | $mailchimpStoreId, 50 | $invoice->getOrderId(), 51 | \Ebizmarts\MailChimp\Helper\Data::IS_ORDER, 52 | null, 53 | null, 54 | 1, 55 | null, 56 | null, 57 | \Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC 58 | ); 59 | return $invoice; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Model/Plugin/Ship.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * 11 | */ 12 | namespace Ebizmarts\MailChimp\Model\Plugin; 13 | 14 | use Magento\Sales\Api\Data\ShipmentInterface; 15 | use Magento\Sales\Model\Order\Shipment as SalesShipment; 16 | use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; 17 | 18 | class Ship 19 | { 20 | /** 21 | * @var \Ebizmarts\MailChimp\Helper\Data 22 | */ 23 | private $_helper; 24 | /** 25 | * @var SyncHelper 26 | */ 27 | private $syncHelper; 28 | 29 | /** 30 | * @param \Ebizmarts\MailChimp\Helper\Data $helper 31 | * @param SyncHelper $syncHelper 32 | */ 33 | public function __construct( 34 | \Ebizmarts\MailChimp\Helper\Data $helper, 35 | SyncHelper $syncHelper 36 | ) { 37 | $this->_helper = $helper; 38 | $this->syncHelper = $syncHelper; 39 | } 40 | public function afterSave( 41 | SalesShipment $subject, 42 | ShipmentInterface $shipment 43 | ) { 44 | $mailchimpStoreId = $this->_helper->getConfigValue( 45 | \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, 46 | $shipment->getStoreId() 47 | ); 48 | $this->syncHelper->saveEcommerceData( 49 | $mailchimpStoreId, 50 | $shipment->getOrderId(), 51 | \Ebizmarts\MailChimp\Helper\Data::IS_ORDER, 52 | null, 53 | null, 54 | 1, 55 | null, 56 | null, 57 | \Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC 58 | ); 59 | return $shipment; 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /Observer/Sales/Order/SaveAfter.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 2/15/17 3:38 PM 11 | * @file: SaveAfter.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Observer\Sales\Order; 15 | 16 | use Magento\Framework\Event\Observer; 17 | use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; 18 | 19 | class SaveAfter implements \Magento\Framework\Event\ObserverInterface 20 | { 21 | /** 22 | * @var \Ebizmarts\MailChimp\Helper\Data 23 | */ 24 | protected $_helper; 25 | /** 26 | * @var SyncHelper 27 | */ 28 | private $syncHelper; 29 | 30 | /** 31 | * @param \Ebizmarts\MailChimp\Helper\Data $helper 32 | * @param SyncHelper $syncHelper 33 | */ 34 | public function __construct( 35 | \Ebizmarts\MailChimp\Helper\Data $helper, 36 | SyncHelper $syncHelper 37 | ) { 38 | 39 | $this->_helper = $helper; 40 | $this->syncHelper = $syncHelper; 41 | } 42 | 43 | public function execute(\Magento\Framework\Event\Observer $observer) 44 | { 45 | $order = $observer->getEvent()->getOrder(); 46 | $mailchimpStoreId = $this->_helper->getConfigValue( 47 | \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, 48 | $order->getStoreId() 49 | ); 50 | $this->syncHelper->saveEcommerceData( 51 | $mailchimpStoreId, 52 | $order->getId(), 53 | \Ebizmarts\MailChimp\Helper\Data::IS_ORDER, 54 | null, 55 | null, 56 | 1, 57 | null, 58 | null, 59 | \Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC 60 | ); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/mailchimpconfirmation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ebizmarts_MailChimp Magento JS component 3 | * 4 | * @category Ebizmarts 5 | * @package Ebizmarts_MailChimp 6 | * @author Ebizmarts Team 7 | * @copyright Ebizmarts (http://ebizmarts.com) 8 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 9 | */ 10 | define( 11 | [ 12 | 'jquery', 13 | 'Magento_Ui/js/modal/confirm', 14 | 'Magento_Ui/js/modal/alert' 15 | ], function ($ , confirmation, alert) { 16 | 'use strict'; 17 | 18 | window.mailchimpdeleteconfirmation = function (ajaxurl) { 19 | var message = 'Are you sure you want to do this?'; 20 | confirmation( { 21 | content: message, 22 | actions: { 23 | confirm: function () { 24 | $.ajax({ 25 | url: ajaxurl, 26 | data: {form_key: window.FORM_KEY}, 27 | type: 'POST', 28 | success: function (retdata) { 29 | if (retdata.valid == 0) { 30 | alert({ 31 | content: 'Error: ' + data.message 32 | }); 33 | } 34 | else if (retdata.valid == 1) { 35 | alert({ 36 | content: 'Operation OK' 37 | }); 38 | } 39 | } 40 | }).done(function (a) { 41 | console.log(a); 42 | }); 43 | } 44 | } 45 | }); 46 | return false; 47 | } 48 | } 49 | ); 50 | -------------------------------------------------------------------------------- /Block/Adminhtml/Stores/Edit/Tabs.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 4/12/17 11:01 AM 11 | * @file: Tabs.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit; 15 | 16 | use Magento\Backend\Block\Widget\Tabs as WidgetTabs; 17 | 18 | class Tabs extends WidgetTabs 19 | { 20 | /** 21 | * Class constructor 22 | * 23 | * @return void 24 | */ 25 | protected function _construct() 26 | { 27 | parent::_construct(); 28 | $this->setId('stores_edit_tabs'); 29 | $this->setDestElementId('edit_form'); 30 | $this->setTitle(__('Mailchimp Store Information')); 31 | } 32 | 33 | /** 34 | * @return $this 35 | */ 36 | protected function _beforeToHtml() 37 | { 38 | $this->addTab( 39 | 'stores_info', 40 | [ 41 | 'label' => __('General'), 42 | 'title' => __('General'), 43 | 'content' => $this->getLayout()->createBlock( 44 | \Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit\Tab\Info::class 45 | )->toHtml(), 46 | 'active' => true 47 | ] 48 | ); 49 | $this->addTab( 50 | 'stores_address', 51 | [ 52 | 'label' => __('Address'), 53 | 'title' => __('Address'), 54 | 'content' => $this->getLayout()->createBlock( 55 | \Ebizmarts\MailChimp\Block\Adminhtml\Stores\Edit\Tab\Address::class 56 | )->toHtml(), 57 | 'active' => false 58 | ] 59 | ); 60 | 61 | return parent::_beforeToHtml(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /etc/events.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Model/Plugin/Creditmemo.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * 11 | */ 12 | namespace Ebizmarts\MailChimp\Model\Plugin; 13 | 14 | use Magento\Sales\Api\Data\CreditmemoInterface; 15 | use Magento\Sales\Api\CreditmemoRepositoryInterface as SalesCreditmemoRepositoryInterface; 16 | use Ebizmarts\MailChimp\Helper\Sync as SyncHelper; 17 | 18 | class Creditmemo 19 | { 20 | /** 21 | * @var \Ebizmarts\MailChimp\Helper\Data 22 | */ 23 | private $_helper; 24 | /** 25 | * @var SyncHelper 26 | */ 27 | private $syncHelper; 28 | 29 | /** 30 | * @param \Ebizmarts\MailChimp\Helper\Data $helper 31 | * @param SyncHelper $syncHelper 32 | */ 33 | public function __construct( 34 | \Ebizmarts\MailChimp\Helper\Data $helper, 35 | SyncHelper $syncHelper 36 | ) { 37 | $this->_helper = $helper; 38 | $this->syncHelper = $syncHelper; 39 | } 40 | public function afterSave( 41 | SalesCreditmemoRepositoryInterface $subject, 42 | CreditmemoInterface $creditmemo 43 | ) { 44 | $mailchimpStoreId = $this->_helper->getConfigValue( 45 | \Ebizmarts\MailChimp\Helper\Data::XML_MAILCHIMP_STORE, 46 | $creditmemo->getStoreId() 47 | ); 48 | $this->syncHelper->saveEcommerceData( 49 | $mailchimpStoreId, 50 | $creditmemo->getOrderId(), 51 | \Ebizmarts\MailChimp\Helper\Data::IS_ORDER, 52 | null, 53 | null, 54 | 1, 55 | null, 56 | null, 57 | \Ebizmarts\MailChimp\Helper\Data::NEEDTORESYNC 58 | ); 59 | 60 | return $creditmemo; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /etc/acl.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Model/MailChimpSyncEcommerce.php: -------------------------------------------------------------------------------- 1 | 8 | * @copyright Ebizmarts (http://ebizmarts.com) 9 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 10 | * @date: 10/21/16 4:55 PM 11 | * @file: MailChimpSyncEcommerce.php 12 | */ 13 | 14 | namespace Ebizmarts\MailChimp\Model; 15 | 16 | class MailChimpSyncEcommerce extends \Magento\Framework\Model\AbstractModel 17 | { 18 | protected function _construct() 19 | { 20 | parent::_construct(); 21 | $this->_init(\Ebizmarts\MailChimp\Model\ResourceModel\MailChimpSyncEcommerce::class); 22 | } 23 | 24 | public function getByStoreIdType($storeId, $id, $type) 25 | { 26 | $this->getResource()->getByStoreIdType($this, $storeId, $id, $type); 27 | return $this; 28 | } 29 | public function markAllAsDeleted($id, $type, $relatedDeletedId) 30 | { 31 | $this->getResource()->markAllAsDeleted($this, $id, $type, $relatedDeletedId); 32 | return $this; 33 | } 34 | public function markEcommorceAsNotDeleted($id, $type) 35 | { 36 | $this->getResource()->markEcommorceAsNotDeleted($this, $id, $type); 37 | return $this; 38 | } 39 | public function markAllAsModified($id, $type) 40 | { 41 | $this->getResource()->markAllAsModified($this, $id, $type); 42 | return $this; 43 | } 44 | public function deleteAllByIdType($id, $type, $mailchimpStoreId) 45 | { 46 | $this->getResource()->deleteAllByIdType($this, $id, $type, $mailchimpStoreId); 47 | return $this; 48 | } 49 | public function deleteAllByBatchid($batchId) 50 | { 51 | $this->getResource()->deleteAllByBatchid($this, $batchId); 52 | } 53 | public function markAllAsModifiedByIds($mailchimpStoreId, $ids, $type) 54 | { 55 | $this->getResource()->markAllAsModifiedByIds($this, $mailchimpStoreId, $ids, $type); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Cron/ErrorsClean.php: -------------------------------------------------------------------------------- 1 | 9 | * @copyright Ebizmarts (http://ebizmarts.com) 10 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 11 | * @date: 15/09/22 10:02 AM 12 | * @file: ErrorsClean.php 13 | */ 14 | namespace Ebizmarts\MailChimp\Cron; 15 | 16 | class ErrorsClean 17 | { 18 | /** 19 | * @var \Ebizmarts\MailChimp\Helper\Data 20 | */ 21 | protected $helper; 22 | /** 23 | * @var \Ebizmarts\MailChimp\Model\MailChimpErrors 24 | */ 25 | protected $chimpErrors; 26 | /** 27 | * @var \Magento\Store\Model\StoreManager 28 | */ 29 | protected $storeManager; 30 | const LIMIT = 1000; 31 | 32 | /** 33 | * @param \Ebizmarts\MailChimp\Helper\Data $helper 34 | * @param \Ebizmarts\MailChimp\Model\MailChimpErrors $chimpErrors 35 | * @param \Magento\Store\Model\StoreManager $storeManager 36 | */ 37 | public function __construct( 38 | \Ebizmarts\MailChimp\Helper\Data $helper, 39 | \Ebizmarts\MailChimp\Model\MailChimpErrors $chimpErrors, 40 | \Magento\Store\Model\StoreManager $storeManager 41 | ) 42 | { 43 | $this->helper = $helper; 44 | $this->chimpErrors = $chimpErrors; 45 | $this->storeManager = $storeManager; 46 | } 47 | public function execute() 48 | { 49 | foreach ($this->storeManager->getStores() as $storeId => $val) 50 | { 51 | $period = $this->helper->getConfigValue(\Ebizmarts\MailChimp\Helper\Data::XML_CLEAN_ERROR_MONTHS, $storeId); 52 | if ($period > 0) { 53 | try { 54 | $this->helper->log("Cleaning errors for store [$storeId] older than $period months"); 55 | $this->chimpErrors->deleteByStorePeriod($storeId,$period,self::LIMIT); 56 | } catch (\Exception $e) { 57 | $this->helper->log($e->getMessage()); 58 | } 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Controller/Adminhtml/Orders/Campaign.php: -------------------------------------------------------------------------------- 1 | helper = $helper; 40 | $this->orderRepository = $orderRepository; 41 | $this->urlBuilder = $urlBuilder; 42 | } 43 | public function execute() 44 | { 45 | $param = $this->getRequest()->getParams(); 46 | $orderId = $this->getRequest()->getParam('orderId'); 47 | $order = $this->orderRepository->get($orderId); 48 | $api = $this->helper->getApi($order->getStoreId()); 49 | try { 50 | $campaign = $api->campaigns->get($order->getMailchimpCampaignId()); 51 | $webId = $campaign['web_id']; 52 | $url = $this->urlBuilder->getUrl('https://admin.mailchimp.com/reports/summary') . "?id=$webId"; 53 | $this->_redirect($url); 54 | } catch(\Exception $e) { 55 | $this->messageManager->addErrorMessage($e->getMessage()); 56 | $this->_redirect($this->urlBuilder->getUrl('sales/order')); 57 | } 58 | } 59 | protected function _isAllowed() 60 | { 61 | return $this->_authorization->isAllowed('Ebizmarts_MailChimp::mailchimp_access'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/apikey.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ebizmarts_MailChimp Magento JS component 3 | * 4 | * @category Ebizmarts 5 | * @package Ebizmarts_MailChimp 6 | * @author Ebizmarts Team 7 | * @copyright Ebizmarts (http://ebizmarts.com) 8 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 9 | */ 10 | define( 11 | [ 12 | 'jquery', 13 | 'Magento_Ui/js/modal/alert' 14 | ], 15 | function ($,alert) { 16 | "use strict"; 17 | 18 | $.widget('mage.monkeyapikey', { 19 | "options": { 20 | "apikeyUrl": "" 21 | }, 22 | 23 | _init: function () { 24 | var apiUrl = this.options.apikeyUrl; 25 | $('#stores_apikey').change(function () { 26 | // remove all items in list combo 27 | $('#stores_list_id').empty(); 28 | // get the selected apikey 29 | var apiKey = $('#stores_apikey').find(':selected').val(); 30 | // get the list for this apikey via ajax 31 | //var apiUrl = this.options.apikeyUrl; 32 | $.ajax({ 33 | url: apiUrl, 34 | data: {'form_key': window.FORM_KEY, 'apikey': apiKey, 'encrypt': 1}, 35 | type: 'POST', 36 | dataType: 'json', 37 | showLoader: true 38 | }).done(function (data) { 39 | if (data.valid==1) { 40 | $.each(data.lists, function (i, item) { 41 | $('#stores_list_id').append($('