diff --git a/Checkout/Api/Bold/Customers.php b/Checkout/Api/Bold/Customers.php
deleted file mode 100644
index 3f8cb16..0000000
--- a/Checkout/Api/Bold/Customers.php
+++ /dev/null
@@ -1,53 +0,0 @@
-items = $customers->items;
- return json_decode(
- Bold_Checkout_PlatformClient::call(
- Zend_Http_Client::POST,
- self::CUSTOMER_SAVE_URL,
- $websiteId,
- json_encode($body)
- )
- );
- }
-
- /**
- * Send delete customer request to bold.
- *
- * @param array $customerIds
- * @param int $websiteId
- * @return string
- * @throws Mage_Core_Exception
- */
- public static function deleted(array $customerIds, $websiteId)
- {
- return json_decode(
- Bold_Checkout_PlatformClient::call(
- Zend_Http_Client::POST,
- self::CUSTOMER_DELETE_URL,
- $websiteId,
- json_encode(['ids' => $customerIds])
- )
- );
- }
-}
diff --git a/Checkout/Model/Import/Entity/Customer.php b/Checkout/Model/Import/Entity/Customer.php
deleted file mode 100644
index 19311bc..0000000
--- a/Checkout/Model/Import/Entity/Customer.php
+++ /dev/null
@@ -1,186 +0,0 @@
-getBehavior() === Mage_ImportExport_Model_Import::BEHAVIOR_DELETE) {
- $this->syncDeletedCustomers();
- }
- parent::_importData();
- if ($this->getBehavior() !== Mage_ImportExport_Model_Import::BEHAVIOR_DELETE) {
- $this->syncImportedCustomers();
- }
- return true;
- }
-
- /**
- * Retrieve imported customers.
- *
- * @return void
- */
- private function syncImportedCustomers()
- {
- $websiteIds = [];
- /** @var Mage_Customer_Model_Config_Share $configShare */
- $configShare = Mage::getSingleton('customer/config_share');
- foreach (Mage::app()->getWebsites() as $website) {
- $websiteIds[] = $website->getId();
- }
- while ($bunch = $this->_dataSourceModel->getNextBunch()) {
- $emails = $this->getEmails($bunch);
- if (!$emails) {
- continue;
- }
- if ($configShare->isWebsiteScope()) {
- $this->syncImportedCustomersPerWebsite($emails);
- continue;
- }
- foreach ($websiteIds as $websiteId) {
- $queryParameters = [
- 'searchCriteria' => [
- 'filterGroups' => [
- [
- 'filters' => [
- [
- 'field' => 'email',
- 'conditionType' => 'in',
- 'value' => $emails,
- ],
- ],
- ],
- ],
- 'pageSize' => count($emails),
- 'currentPage' => 1,
- ],
- ];
- Bold_Checkout_Api_Bold_Customers::update($queryParameters, $websiteId);
- }
- }
- }
-
- /**
- * Retrieve imported customers.
- *
- * @return void
- * @throws Mage_Core_Exception
- */
- private function syncDeletedCustomers()
- {
- /** @var Mage_Customer_Model_Config_Share $configShare */
- $configShare = Mage::getSingleton('customer/config_share');
- $websiteIds = [];
- foreach (Mage::app()->getWebsites() as $website) {
- $websiteIds[] = $website->getId();
- }
- while ($bunch = $this->_dataSourceModel->getNextBunch()) {
- $emails = $this->getEmails($bunch);
- if (!$emails) {
- continue;
- }
- /** @var Mage_Customer_Model_Resource_Customer_Collection $collection */
- $collection = Mage::getModel('customer/customer')->getCollection();
- $collection->addFieldToFilter('email', $emails);
- $collection->addAttributeToSelect('website_id');
- if ($configShare->isWebsiteScope()) {
- $this->syncDeletedCustomersPerWebsite($collection);
- continue;
- }
- $customerIds[] = $collection->getAllIds();
- foreach ($websiteIds as $websiteId) {
- Bold_Checkout_Api_Bold_Customers::deleted($customerIds, $websiteId);
- }
- }
- }
-
- /**
- * Get imported customer's emails.
- *
- * @param array $bunch
- * @return array
- */
- private function getEmails(array $bunch)
- {
- $emails = [];
- foreach ($bunch as $rowNum => $rowData) {
- if (!$this->validateRow($rowData, $rowNum)) {
- continue;
- }
- if (self::SCOPE_DEFAULT == $this->getRowScope($rowData)) {
- $emails[] = strtolower($rowData[self::COL_EMAIL]);
- }
- }
- return $emails;
- }
-
- /**
- * Sync deleted customers with Bold.
- *
- * @param Mage_Customer_Model_Resource_Customer_Collection $collection
- * @return void
- * @throws Mage_Core_Exception
- */
- private function syncDeletedCustomersPerWebsite(Mage_Customer_Model_Resource_Customer_Collection $collection)
- {
- $ids = [];
- foreach ($collection->getItems() as $customer) {
- $ids[$customer->getWebsiteId()][] = $customer->getId();
- }
- foreach ($ids as $websiteId => $customerIds) {
- Bold_Checkout_Api_Bold_Customers::deleted($customerIds, $websiteId);
- }
- }
-
- /**
- * Sync imported customers with Bold.
- *
- * @param array $emails
- * @return void
- * @throws Mage_Core_Exception
- */
- private function syncImportedCustomersPerWebsite(array $emails)
- {
- /** @var Mage_Customer_Model_Resource_Customer_Collection $collection */
- $collection = Mage::getModel('customer/customer')->getCollection();
- $collection->addFieldToFilter('email', $emails);
- $collection->addAttributeToSelect('website_id');
- $ids = [];
- foreach ($collection->getItems() as $customer) {
- $ids[$customer->getWebsiteId()][] = $customer->getId();
- }
- foreach ($ids as $websiteId => $customerIds) {
- $queryParameters = [
- 'searchCriteria' => [
- 'filterGroups' => [
- [
- 'filters' => [
- [
- 'field' => 'entity_id',
- 'conditionType' => 'in',
- 'value' => $customerIds,
- ],
- [
- 'field' => 'website_id',
- 'conditionType' => 'eq',
- 'value' => $websiteId,
- ],
- ],
- ],
- ],
- 'pageSize' => count($customerIds),
- 'currentPage' => 1,
- ],
- ];
- Bold_Checkout_Api_Bold_Customers::update($queryParameters, $websiteId);
- }
- }
-}
diff --git a/Checkout/Observer/CustomerObserver.php b/Checkout/Observer/CustomerObserver.php
deleted file mode 100644
index 8c97779..0000000
--- a/Checkout/Observer/CustomerObserver.php
+++ /dev/null
@@ -1,174 +0,0 @@
-getCustomer();
- $websiteIds = $this->getWebsiteIds($customer);
- foreach ($websiteIds as $websiteId) {
- $this->syncCustomerSave($customer->getId(), $websiteId);
- }
- }
-
- /**
- * Set customer sync time to null in order to sync customer with bold via cron after customer has been deleted.
- *
- * @param Varien_Event_Observer $event
- * @return void
- * @throws Exception
- */
- public function customerDeleted(Varien_Event_Observer $event)
- {
- /** @var Mage_Customer_Model_Customer $customer */
- $customer = $event->getDataObject();
- $websiteIds = $this->getWebsiteIds($customer);
- foreach ($websiteIds as $websiteId) {
- $this->syncCustomerDelete($customer->getId(), $websiteId);
- }
- }
-
- /**
- * Set customer sync time to null in order to sync customer with bold via cron when customer address has been saved.
- *
- * @param Varien_Event_Observer $event
- * @return void
- * @throws Exception
- */
- public function customerAddressSaved(Varien_Event_Observer $event)
- {
- $customerId = $event->getDataObject()->getCustomerId();
- /** @var Mage_Customer_Model_Customer $customer */
- $customer = Mage::getModel('customer/customer')->load($customerId);
- if (!$customer->getId()) {
- return;
- }
- $websiteIds = $this->getWebsiteIds($customer);
- foreach ($websiteIds as $websiteId) {
- $this->syncCustomerSave($customer->getId(), $websiteId);
- }
- }
-
- /**
- * Set customer sync time to null in order to sync one with bold via cron when customer address has been deleted.
- *
- * @param Varien_Event_Observer $event
- * @return void
- * @throws Exception
- */
- public function customerAddressDeleted(Varien_Event_Observer $event)
- {
- $config = Mage::getSingleton(Bold_Checkout_Model_Config::RESOURCE);
- $websiteId = Mage::app()->getWebsite()->getId();
- if (!$config->isCheckoutEnabled($websiteId)) {
- return;
- }
- $customerId = $event->getDataObject()->getCustomerId();
- /** @var Mage_Customer_Model_Customer $customer */
- $customer = Mage::getModel('customer/customer');
- $customer = $customer->load($customerId);
- if (!$customer->getId()) {
- return;
- }
- $websiteIds = $this->getWebsiteIds($customer);
- foreach ($websiteIds as $websiteId) {
- $this->syncCustomerSave($customerId, $websiteId);
- }
- }
-
- /**
- * Get customer websites.
- *
- * @param Mage_Customer_Model_Customer $customer
- * @return array
- */
- private function getWebsiteIds(Mage_Customer_Model_Customer $customer)
- {
- $websitesIds = [];
- if ($customer->getSharingConfig()->isWebsiteScope()) {
- return [$customer->getWebsiteId()];
- }
- foreach (Mage::app()->getWebsites() as $website) {
- $websitesIds[] = $website->getId();
- }
- return $websitesIds;
- }
-
- /**
- * Sync customer with Bold after save.
- *
- * @param int $customerId
- * @param int $websiteId
- * @return void
- * @throws Mage_Core_Exception
- */
- private function syncCustomerSave($customerId, $websiteId)
- {
- /** @var Bold_Checkout_Model_Config $config */
- $config = Mage::getSingleton(Bold_Checkout_Model_Config::RESOURCE);
- if (!$config->isCheckoutEnabled($websiteId)) {
- return;
- }
- $queryParameters = [
- 'searchCriteria' => [
- 'filterGroups' => [
- [
- 'filters' => [
- [
- 'field' => 'entity_id',
- 'conditionType' => 'eq',
- 'value' => $customerId,
- ],
- [
- 'field' => 'website_id',
- 'conditionType' => 'eq',
- 'value' => $websiteId,
- ],
- ],
- ],
- ],
- 'pageSize' => 1,
- 'currentPage' => 1,
- ],
- ];
- $result = Bold_Checkout_Api_Bold_Customers::update($queryParameters, $websiteId);
- /** @var Mage_Adminhtml_Model_Session $session */
- $session = Mage::getSingleton('adminhtml/session');
- isset($result->errors)
- ? $session->addError(Mage::helper('core')->__('Cannot synchronize customer with Bold'))
- : $session->addNotice(Mage::helper('core')->__('Customer successfully synchronized with Bold'));
- }
-
- /**
- * Sync customer with Bold after delete.
- *
- * @param int $customerId
- * @param int $websiteId
- * @return void
- * @throws Mage_Core_Exception
- */
- private function syncCustomerDelete($customerId, $websiteId)
- {
- /** @var Bold_Checkout_Model_Config $config */
- $config = Mage::getSingleton(Bold_Checkout_Model_Config::RESOURCE);
- if (!$config->isCheckoutEnabled($websiteId)) {
- return;
- }
- $result = Bold_Checkout_Api_Bold_Customers::deleted([(int)$customerId], $websiteId);
- /** @var Mage_Adminhtml_Model_Session $session */
- $session = Mage::getSingleton('adminhtml/session');
- isset($result->errors)
- ? $session->addError(Mage::helper('core')->__('Cannot sync customer with Bold'))
- : $session->addNotice(Mage::helper('core')->__('Customer successfully synced with Bold'));
- }
-}
diff --git a/Checkout/etc/config.xml b/Checkout/etc/config.xml
index e555ef2..71ea362 100644
--- a/Checkout/etc/config.xml
+++ b/Checkout/etc/config.xml
@@ -44,11 +44,6 @@
-
-
- Bold_Checkout_Model_Import_Entity_Customer
-
-
@@ -58,22 +53,6 @@
-
-
-
- Bold_Checkout_Observer_CustomerObserver
- customerSaved
-
-
-
-
-
-
- Bold_Checkout_Observer_CustomerObserver
- customerDeleted
-
-
-
@@ -134,22 +113,6 @@
-
-
-
- Bold_Checkout_Observer_CustomerObserver
- customerAddressSaved
-
-
-
-
-
-
- Bold_Checkout_Observer_CustomerObserver
- customerAddressDeleted
-
-
-