diff --git a/Model/ResourceModel/Objects.php b/Model/ResourceModel/Objects.php index be12af1d..660167e2 100644 --- a/Model/ResourceModel/Objects.php +++ b/Model/ResourceModel/Objects.php @@ -26,6 +26,11 @@ class Objects extends AbstractDb */ private $selectEntityIds; + /** + * @var \Magento\Framework\DB\Select + */ + private $selectEntityIdsByType; + /** * @var \Magento\Framework\DB\Select */ @@ -94,6 +99,14 @@ protected function _construct() ->where('website_id IN (:entity_website_id, :base_website_id)') ->order(new \Zend_Db_Expr('FIELD(website_id, :base_website_id, :entity_website_id)')); + $this->selectEntityIdsByType = $this->getConnection()->select() + ->from($this->getMainTable(), ['entity_id']) + ->where('magento_type = :magento_type') + ->where('salesforce_type = :salesforce_type') + ->where('object_id = :object_id') + ->where('website_id IN (:entity_website_id, :base_website_id)') + ->order(new \Zend_Db_Expr('FIELD(website_id, :base_website_id, :entity_website_id)')); + $this->selectStatus = $this->getConnection()->select() ->from($this->getMainTable(), ['status']) ->where('magento_type = :magento_type') @@ -317,4 +330,23 @@ public function unsetPendingStatus($entityId, $magentoType, $websiteId, $salesfo $where ); } + + /** + * @param string $objectId + * @param string $magentoType + * @param string $salesforceType + * @param int $websiteId + * + * @return array + */ + public function loadEntityIdsByType($objectId, $magentoType, $salesforceType, $websiteId) + { + return $this->getConnection()->fetchCol($this->selectEntityIdsByType, [ + 'magento_type' => $magentoType, + 'salesforce_type' => $salesforceType, + 'object_id' => $objectId, + 'entity_website_id' => $websiteId, + 'base_website_id' => $this->baseWebsiteId($websiteId), + ]); + } } diff --git a/Plugin/FixMissedWebsites.php b/Plugin/FixMissedWebsites.php new file mode 100644 index 00000000..dc0d3686 --- /dev/null +++ b/Plugin/FixMissedWebsites.php @@ -0,0 +1,64 @@ +storeManager = $storeManager; + } + + /** + * @param $website + * @return int + */ + public function getDefaultStoreId($website) + { + + $defaultGroupId = $website->getDefaultGroupId(); + /** @var GroupInterface $defaultGroup */ + $defaultGroup = $this->storeManager->getGroup($defaultGroupId); + return $defaultGroup->getDefaultStoreId(); + } + + /** + * @param AbstractModel $entity + * @param $result + * @param $entity + */ + public function afterGetEntityWebsiteIds( + DivideEntityByWebsiteOrg $subject, + $result, + $entity + ) { + + if (in_array(0, $result)) { + $result = array_filter($result); + if (empty($result)) { + $defaultWebsite = $this->storeManager->getWebsite(true); + $result[] = $defaultWebsite->getId(); + $entity->setWebsiteId($defaultWebsite->getId()); + $entity->setStoreId($this->getDefaultStoreId($defaultWebsite)); + } + } + + return $result; + } +} diff --git a/Plugin/Synchronize/Queue/Website/FixMissedWebsites.php b/Plugin/Synchronize/Queue/Website/FixMissedWebsites.php new file mode 100644 index 00000000..b4abded5 --- /dev/null +++ b/Plugin/Synchronize/Queue/Website/FixMissedWebsites.php @@ -0,0 +1,77 @@ +storeManager = $storeManager; + } + + /** + * @param $website + * @return int + */ + public function getDefaultStoreId($website) + { + + $defaultGroupId = $website->getDefaultGroupId(); + /** @var GroupInterface $defaultGroup */ + $defaultGroup = $this->storeManager->getGroup($defaultGroupId); + return $defaultGroup->getDefaultStoreId(); + } + + /** + * @param CreateInterface $subject + * @param $result + * @param int[] $entityIds + * @param array $additional + * @param callable $create + * @param int $websiteId + */ + public function afterProcess( + CreateInterface $subject, + $result, + array $entityIds, + array $additional, + callable $create, + $websiteId + ) { + + foreach ($result as $k => $item) { + if (empty($item->getEntityId())) { + $defaultWebsite = $this->storeManager->getWebsite(true); + + $baseEntityIds = $item->getData('_base_entity_id'); + $baseEntityId = reset($baseEntityIds); + $result[] = $create( + 'website', + $defaultWebsite->getId(), + $baseEntityId, + ['website' => $defaultWebsite->getId()] + ); + + unset($result[$k]); + } + } + + return $result; + } +} diff --git a/Plugin/Synchronize/Unit/Mapping/CheckOwnerField.php b/Plugin/Synchronize/Unit/Mapping/CheckOwnerField.php index 7db06169..7e04e2da 100644 --- a/Plugin/Synchronize/Unit/Mapping/CheckOwnerField.php +++ b/Plugin/Synchronize/Unit/Mapping/CheckOwnerField.php @@ -12,7 +12,7 @@ use TNW\Salesforce\Model\ResourceModel\Mapper\Collection; use TNW\Salesforce\Synchronize\Unit\Mapping; -class CheckOwnerField +class CheckOwnerField extends Mapping { const OWNER_ID_FIELD = 'OwnerId'; @@ -51,7 +51,10 @@ public function __construct( */ public function checkOwner($value, $entity) { + $value = $this->correctSalesforceId($value); $actualOwners = $this->salesforceOwners->toOptionArray(); + $actualOwners = $this->correctSalesforceIdKey($actualOwners); + if (!isset($actualOwners[$value])) { $this->logger->messageDebug('The owner %s is not valid anymore, the default owner %s used instead', $value, $this->customerConfig->defaultOwner($entity->getData('config_website'))); $value = $this->customerConfig->defaultOwner($entity->getData('config_website')); @@ -60,6 +63,21 @@ public function checkOwner($value, $entity) return $value; } + /** + * @param $actualOwners + * @return array + */ + public function correctSalesforceIdKey($actualOwners) + { + $result= []; + foreach ($actualOwners as $salesforceId => $value) { + $salesforceId = $this->correctSalesforceId($salesforceId); + $result[$salesforceId] = $value; + } + + return $result; + } + /** * @param Mapping $subject * @param callable $proceed diff --git a/Synchronize/Group.php b/Synchronize/Group.php index c7357992..db30e62d 100644 --- a/Synchronize/Group.php +++ b/Synchronize/Group.php @@ -123,8 +123,9 @@ protected function createUnits(array $queues) { /** @var Units $units */ $units = $this->unitsFactory->create(); - foreach ($this->units as $instanceName) { + foreach ($this->units as $key => $instanceName) { $units->add($this->objectManager->create($instanceName, [ + 'name' => $key, 'group' => $this, 'queues' => $queues, 'units' => $units diff --git a/Synchronize/Queue.php b/Synchronize/Queue.php index 751da5af..15bbf2a8 100644 --- a/Synchronize/Queue.php +++ b/Synchronize/Queue.php @@ -145,7 +145,6 @@ public function synchronize($collection, $websiteId, $syncJobs = []) $lastPageNumber = (int)$groupCollection->getLastPageNumber(); for ($i = 1; $i <= $lastPageNumber; $i++) { $groupCollection->clear(); - $groupCollection->setCurPage($i); $group->messageDebug( 'Start job "%s", phase "%s" for website %s', @@ -213,6 +212,9 @@ public function sortGroup($syncJobs = null) $description[] = sprintf('%s <- %s;', $group->code(), $dependent); + if ($group->code() == $dependent) { + continue; + } if (isset($sortGroups[$dependent])) { continue; } diff --git a/Synchronize/Queue/Add.php b/Synchronize/Queue/Add.php index 7112d4fb..17bc3b01 100644 --- a/Synchronize/Queue/Add.php +++ b/Synchronize/Queue/Add.php @@ -197,7 +197,7 @@ public function addToQueueByWebsite(array $entityIds, $website = null, $syncType if ($syncType === Config::DIRECT_SYNC_TYPE_REALTIME) { // Sync realtime type - $this->publisher->publish(self::TOPIC_NAME, (string) $websiteId); + $this->publisher->publish(self::TOPIC_NAME, (string)$websiteId); return; } @@ -272,39 +272,39 @@ public function generateQueueObjects( continue; } - /** - * This unit already processed higher in recursion stack - */ + // merge already created records if (isset($queuesUnique[$key])) { $current = $unit->baseByUnique($queuesUnique[$key], $current); - $parents = $children = []; + } - /** - * add if items were added partially (regular/guest customers for example) - */ - foreach ([$current] as $relation) { - foreach ($relation as $relationItem) { - $queuesUnique[$key][$relationItem->getId()] = $relationItem; - } - } - } else { - $currentEntityIds = []; - $currentByEntityLoad = []; - foreach ([$current] as $relation) { - foreach ($relation as $relationItem) { - $queuesUnique[$key][$relationItem->getId()] = $relationItem; + $currentEntityIds = []; + $currentByEntityLoad = []; + foreach ([$current] as $relation) { + foreach ($relation as $relationItem) { + if (empty($queuesUnique[$key][$relationItem->getId()])) { $currentEntityIds[$relationItem->getEntityLoad()][] = $relationItem->getEntityId(); $currentByEntityLoad[$relationItem->getEntityLoad()][] = $relationItem; + $queuesUnique[$key][$relationItem->getId()] = $relationItem; } } + } - foreach ($currentByEntityLoad as $baseEntityLoad => $itemByEntityLoad) { - /** @var Queue */ - $currentItem = reset($itemByEntityLoad); - $baseEntityLoadAdditional = $currentItem->getEntityLoadAdditional(); - - $parentsTmp = $this->generateQueueObjects( - $unit->parents(), + foreach ($currentByEntityLoad as $baseEntityLoad => $itemByEntityLoad) { + /** @var Queue */ + $currentItem = reset($itemByEntityLoad); + $baseEntityLoadAdditional = $currentItem->getEntityLoadAdditional(); + + $closure = function ($unitsList, &$result) use ( + $unit, + $baseEntityLoad, + $currentEntityIds, + $baseEntityLoadAdditional, + $websiteId, + &$dependencies, + &$queuesUnique + ) { + $tmp = $this->generateQueueObjects( + $unitsList, $baseEntityLoad, $currentEntityIds[$baseEntityLoad], $baseEntityLoadAdditional, @@ -314,38 +314,19 @@ public function generateQueueObjects( $unit->code() ); - foreach ($parentsTmp as $item) { - $parents[] = $item; + if (!empty($tmp)) { + $tmp = array_values($tmp); + array_push($result, ...$tmp); } + }; - $childrenTmp = $this->generateQueueObjects( - $unit->children(), - $baseEntityLoad, - $currentEntityIds[$baseEntityLoad], - $baseEntityLoadAdditional, - $websiteId, - $dependencies, - $queuesUnique, - $unit->code() - ); + $closure($unit->parents(), $parents); + $closure($unit->children(), $children); - foreach ($childrenTmp as $item) { - $children[] = $item; - } - } - - /** - * add parent dependency only, child has own relations - * and will be created as parent dependency deeper in recursion generateQueueObjects - */ - foreach ($unit->parents() as $parent) { - $newDependencies = $this->buildDependency($current, $parent->getQueues(), $unit->code()); - if (!empty($newDependencies)) { - array_push($dependencies, ...$newDependencies); - } - } } + $dependencies = $this->addDependencies($unit, $current, $dependencies); + $unit->addQueues($current); foreach ([$current, $parents, $children] as $relation) { @@ -358,6 +339,27 @@ public function generateQueueObjects( return $queues; } + /** + * @param $unit + * @param $current + * @param $dependencies + * @return mixed + */ + public function addDependencies($unit, $current, $dependencies) + { + /** + * add parent dependency only, child has own relations + * and will be created as parent dependency deeper in recursion generateQueueObjects + */ + foreach ($unit->parents() as $parent) { + $newDependencies = $this->buildDependency($current, $parent->getQueues(), $unit->code()); + if (!empty($newDependencies)) { + array_push($dependencies, ...$newDependencies); + } + } + return $dependencies; + } + /** * @param $queues * @return array diff --git a/Synchronize/Queue/DependenciesQueue.php b/Synchronize/Queue/DependenciesQueue.php index ca3264ab..507e7950 100644 --- a/Synchronize/Queue/DependenciesQueue.php +++ b/Synchronize/Queue/DependenciesQueue.php @@ -104,4 +104,37 @@ public function getResolvesCodes(string $entityType) return $resolves; } + + /** + * @param $descendantStr + * @return array + */ + public function parseDependencyString($descendantStr) + { + $descendantsTmp = explode('&', $descendantStr); + $descendants = []; + foreach ($descendantsTmp as $descendantTmp) { + try { + list($key, $value) = explode('=', $descendantTmp); + $descendants[$key] = $value; + } catch (\Exception $e) { + continue; + } + } + + return $descendants; + } + + + /** + * @param $descendantStr + * @return array + */ + public function parseDependencyStringWithReplace($descendantStr) + { + $descendants = $this->parseDependencyString($descendantStr); + $descendants = str_replace('_', '.', array_keys($descendants)); + + return $descendants; + } } diff --git a/Synchronize/Queue/Website/CreateByBase.php b/Synchronize/Queue/Website/CreateByBase.php new file mode 100644 index 00000000..f636d490 --- /dev/null +++ b/Synchronize/Queue/Website/CreateByBase.php @@ -0,0 +1,24 @@ +resourceCustomer = $resourceCustomer; } @@ -50,7 +52,7 @@ public function process(array $entityIds, array $additional, callable $create, $ 'website', $entity['website_id'], $entity['base_entity_id'], - ['website' => $entity['email']] + ['website' => $entity['website_id']] ); } diff --git a/Synchronize/Queue/Website/CreateByWebsite.php b/Synchronize/Queue/Website/CreateByWebsite.php index caa9864b..fa2cd27d 100644 --- a/Synchronize/Queue/Website/CreateByWebsite.php +++ b/Synchronize/Queue/Website/CreateByWebsite.php @@ -1,24 +1,28 @@ resourceWebsite = $resourceWebsite; } @@ -41,7 +45,7 @@ public function createBy() * @param callable $create * @param int $websiteId * @return mixed - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function process(array $entityIds, array $additional, callable $create, $websiteId) { @@ -63,7 +67,7 @@ public function process(array $entityIds, array $additional, callable $create, $ * * @param int[] $entityIds * @return array - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function entities(array $entityIds) { diff --git a/Synchronize/Transport/Soap/Calls/Upsert/Storage.php b/Synchronize/Transport/Soap/Calls/Upsert/Storage.php index 3eddff61..efd41fa8 100644 --- a/Synchronize/Transport/Soap/Calls/Upsert/Storage.php +++ b/Synchronize/Transport/Soap/Calls/Upsert/Storage.php @@ -43,4 +43,12 @@ public function searchResult($entity) return $this->results[$hash]; } + + /** + * Reset Storage + */ + public function resetStorage() + { + $this->results = []; + } } diff --git a/Synchronize/Unit/Context.php b/Synchronize/Unit/Context.php new file mode 100644 index 00000000..517370db --- /dev/null +++ b/Synchronize/Unit/Context.php @@ -0,0 +1,141 @@ +identification = $identification; + $this->salesforceIdStorage = $salesforceIdStorage; + $this->magentoType = $magentoType; + $this->objectType = $objectType; + $this->salesforceType = $salesforceType; + $this->fieldSalesforceId = $fieldSalesforceId; + } + + /** + * @return IdentificationInterface + */ + public function getIdentification() + { + return $this->identification; + } + + /** + * @return SalesforceIdStorage + */ + public function getSalesforceIdStorage() + { + return $this->salesforceIdStorage; + } + + /** + * @return HashInterface + */ + public function getHash() + { + return $this->hash; + } + + /** + * @return string + */ + public function getMagentoType() + { + return $this->magentoType; + } + + /** + * @return string|null + */ + public function getObjectType() + { + return $this->objectType; + } + + /** + * @return string + */ + public function getSalesforceType() + { + return $this->salesforceType; + } + + /** + * @return string + */ + public function getFieldSalesforceId() + { + return $this->fieldSalesforceId; + } + + public function process() + { + + } +} diff --git a/Synchronize/Unit/Customer/Account/Lookup/ByName.php b/Synchronize/Unit/Customer/Account/Lookup/ByName.php index 29ca26ac..d9de7930 100644 --- a/Synchronize/Unit/Customer/Account/Lookup/ByName.php +++ b/Synchronize/Unit/Customer/Account/Lookup/ByName.php @@ -19,10 +19,8 @@ class ByName extends Synchronize\Unit\LookupAbstract /** * ByName constructor. * @param string $name - * @param string $load * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param Synchronize\Unit\IdentificationInterface $identification * @param Synchronize\Transport\Calls\Query\InputFactory $inputFactory * @param Synchronize\Transport\Calls\Query\OutputFactory $outputFactory * @param Synchronize\Transport\Calls\QueryInterface $process @@ -31,10 +29,8 @@ class ByName extends Synchronize\Unit\LookupAbstract */ public function __construct( $name, - $load, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Synchronize\Transport\Calls\Query\InputFactory $inputFactory, Synchronize\Transport\Calls\Query\OutputFactory $outputFactory, Synchronize\Transport\Calls\QueryInterface $process, @@ -43,10 +39,8 @@ public function __construct( ) { parent::__construct( $name, - $load, $units, $group, - $identification, $inputFactory, $outputFactory, $process, diff --git a/Synchronize/Unit/Customer/Account/Mapping.php b/Synchronize/Unit/Customer/Account/Mapping.php index 58354fbe..350082b0 100644 --- a/Synchronize/Unit/Customer/Account/Mapping.php +++ b/Synchronize/Unit/Customer/Account/Mapping.php @@ -24,36 +24,24 @@ class Mapping extends Synchronize\Unit\Mapping * Mapping constructor. * * @param string $name - * @param string $load - * @param string $lookup - * @param string $objectType * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param Synchronize\Unit\IdentificationInterface $identification * @param Model\ResourceModel\Mapper\CollectionFactory $mapperCollectionFactory * @param Config $customerConfig * @param array $dependents */ public function __construct( $name, - $load, - $lookup, - $objectType, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Model\ResourceModel\Mapper\CollectionFactory $mapperCollectionFactory, Config $customerConfig, array $dependents = [] ) { parent::__construct( $name, - $load, - $lookup, - $objectType, $units, $group, - $identification, $mapperCollectionFactory, $dependents ); diff --git a/Synchronize/Unit/Customer/Account/Upsert/Input.php b/Synchronize/Unit/Customer/Account/Upsert/Input.php index 7d53ed84..ef908b53 100644 --- a/Synchronize/Unit/Customer/Account/Upsert/Input.php +++ b/Synchronize/Unit/Customer/Account/Upsert/Input.php @@ -17,12 +17,8 @@ class Input extends Synchronize\Unit\Upsert\Input /** * Input constructor. * @param string $name - * @param string $load - * @param string $mapping - * @param string $salesforceType * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param Synchronize\Unit\IdentificationInterface $identification * @param Synchronize\Transport\Calls\Upsert\Transport\InputFactory $inputFactory * @param Synchronize\Transport\Calls\Upsert\InputInterface $process * @param Model\Customer\Config $customerConfig @@ -31,12 +27,8 @@ class Input extends Synchronize\Unit\Upsert\Input */ public function __construct( $name, - $load, - $mapping, - $salesforceType, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Synchronize\Transport\Calls\Upsert\Transport\InputFactory $inputFactory, Synchronize\Transport\Calls\Upsert\InputInterface $process, Model\Customer\Config $customerConfig, @@ -45,12 +37,8 @@ public function __construct( ) { parent::__construct( $name, - $load, - $mapping, - $salesforceType, $units, $group, - $identification, $inputFactory, $process, $factory, diff --git a/Synchronize/Unit/Customer/Contact/Lookup.php b/Synchronize/Unit/Customer/Contact/Lookup.php index 2ecc96bd..cc426115 100644 --- a/Synchronize/Unit/Customer/Contact/Lookup.php +++ b/Synchronize/Unit/Customer/Contact/Lookup.php @@ -20,10 +20,8 @@ class Lookup extends Synchronize\Unit\LookupAbstract * Lookup constructor. * * @param string $name - * @param string $load * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param Synchronize\Unit\IdentificationInterface $identification * @param Synchronize\Transport\Calls\Query\InputFactory $inputFactory * @param Synchronize\Transport\Calls\Query\OutputFactory $outputFactory * @param Synchronize\Transport\Calls\QueryInterface $process @@ -32,10 +30,8 @@ class Lookup extends Synchronize\Unit\LookupAbstract */ public function __construct( $name, - $load, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Synchronize\Transport\Calls\Query\InputFactory $inputFactory, Synchronize\Transport\Calls\Query\OutputFactory $outputFactory, Synchronize\Transport\Calls\QueryInterface $process, @@ -44,10 +40,8 @@ public function __construct( ) { parent::__construct( $name, - $load, $units, $group, - $identification, $inputFactory, $outputFactory, $process, diff --git a/Synchronize/Unit/Customer/Contact/Mapping.php b/Synchronize/Unit/Customer/Contact/Mapping.php index 71cbaf4a..990d86ab 100644 --- a/Synchronize/Unit/Customer/Contact/Mapping.php +++ b/Synchronize/Unit/Customer/Contact/Mapping.php @@ -23,36 +23,24 @@ class Mapping extends Synchronize\Unit\Mapping * Mapping constructor. * * @param string $name - * @param string $load - * @param string $lookup - * @param string $objectType * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param Synchronize\Unit\IdentificationInterface $identification * @param Model\ResourceModel\Mapper\CollectionFactory $mapperCollectionFactory * @param Config $customerConfig * @param array $dependents */ public function __construct( $name, - $load, - $lookup, - $objectType, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Model\ResourceModel\Mapper\CollectionFactory $mapperCollectionFactory, Config $customerConfig, array $dependents = [] ) { parent::__construct( $name, - $load, - $lookup, - $objectType, $units, $group, - $identification, $mapperCollectionFactory, $dependents ); diff --git a/Synchronize/Unit/Delete/Input.php b/Synchronize/Unit/Delete/Input.php index cbf80c3f..9929f4b3 100644 --- a/Synchronize/Unit/Delete/Input.php +++ b/Synchronize/Unit/Delete/Input.php @@ -9,7 +9,6 @@ use TNW\Salesforce\Synchronize\Group; use TNW\Salesforce\Synchronize\Transport\Calls\Delete\InputInterface as DeleteInterface; use TNW\Salesforce\Synchronize\Transport\Calls\Delete\Transport\InputFactory; -use TNW\Salesforce\Synchronize\Unit\IdentificationInterface; use TNW\Salesforce\Synchronize\Unit\Load; use TNW\Salesforce\Synchronize\Unit\UnitInterface; use TNW\Salesforce\Synchronize\Units; @@ -19,56 +18,35 @@ */ class Input extends Synchronize\Unit\UnitAbstract { - /** - * @var string - */ - protected $load; - /** @var InputFactory */ protected $inputFactory; - /** - * @var string - */ - private $salesforceType; - /** * @var DeleteInterface */ protected $process; - /** @var IdentificationInterface */ - protected $identification; - /** * Delete constructor. * @param $name - * @param $load * @param array $dependents * @param Units $units * @param Group $group * @param InputFactory $inputFactory * @param DeleteInterface $process - * @param IdentificationInterface $identification */ public function __construct( $name, - $load, - $salesforceType, array $dependents, Units $units, Group $group, InputFactory $inputFactory, - DeleteInterface $process, - IdentificationInterface $identification + DeleteInterface $process ) { - parent::__construct($name, $units, $group, array_merge($dependents, [$load])); - $this->load = $load; + parent::__construct($name, $units, $group, array_merge($dependents, ['load'])); $this->inputFactory = $inputFactory; $this->process = $process; - $this->identification = $identification; - $this->salesforceType = $salesforceType; } /** @@ -108,7 +86,7 @@ public function process() */ public function createTransport() { - return $this->inputFactory->create(['type' => $this->salesforceType()]); + return $this->inputFactory->create(['type' => $this->units()->get('context')->getSalesforceType()]); } /** @@ -142,7 +120,7 @@ protected function entities() */ public function load() { - return $this->unit($this->load); + return $this->unit('load'); } /** @@ -167,14 +145,4 @@ protected function filter($entity) { return !$this->unit('mapping')->skipped($entity); } - - /** - * Salesforce Type - * - * @return string - */ - public function salesforceType() - { - return $this->salesforceType; - } } diff --git a/Synchronize/Unit/Delete/Output.php b/Synchronize/Unit/Delete/Output.php index c802ba9b..61e2d2a9 100644 --- a/Synchronize/Unit/Delete/Output.php +++ b/Synchronize/Unit/Delete/Output.php @@ -19,69 +19,30 @@ class Output extends Synchronize\Unit\UnitAbstract implements Synchronize\Unit\F */ protected $outputFactory; - /** - * @var Synchronize\Unit\IdentificationInterface - */ - protected $identification; - /** * @var Synchronize\Transport\Calls\Delete\OutputInterface */ protected $process; - /** - * @var string - */ - protected $load; - - /** - * @var - */ - protected $fieldSalesforceId; - - /** - * @var string - */ - private $salesforceType; - - /** - * @var string - */ - private $deleteInput; - /** * Output constructor. * @param string $name - * @param string $load - * @param string $deleteInput - * @param string $fieldSalesforceId * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param Synchronize\Unit\IdentificationInterface $identification * @param Synchronize\Transport\Calls\Delete\Transport\OutputFactory $outputFactory * @param Synchronize\Transport\Calls\Delete\OutputInterface $process * @param array $dependents */ public function __construct( $name, - $load, - $salesforceType, - $deleteInput, - $fieldSalesforceId, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Synchronize\Transport\Calls\Delete\Transport\OutputFactory $outputFactory, Synchronize\Transport\Calls\Delete\OutputInterface $process, array $dependents = [] ) { parent::__construct($name, $units, $group, $dependents); - $this->load = $load; - $this->salesforceType = $salesforceType; - $this->deleteInput = $deleteInput; - $this->fieldSalesforceId = $fieldSalesforceId; - $this->identification = $identification; $this->outputFactory = $outputFactory; $this->process = $process; } @@ -91,7 +52,7 @@ public function __construct( */ public function description() { - return __('Delete entity: %s', $this->salesforceType); + return __('Delete entity: %s', $this->units()->get('context')->getSalesforceType()); } /** @@ -101,7 +62,7 @@ public function description() */ public function deleteInput() { - return $this->unit($this->deleteInput); + return $this->unit('deleteInput'); } /** @@ -111,7 +72,7 @@ public function deleteInput() */ public function fieldSalesforceId() { - return $this->fieldSalesforceId; + return $this->units()->get('context')->getFieldSalesforceId(); } /** @@ -129,7 +90,7 @@ public function process() $this->group()->messageDebug(implode("\n", array_map(function ($entity) use ($output) { return __( "Entity %1 response data:\n%2", - $this->identification->printEntity($entity), + $this->units()->get('context')->getIdentification()->printEntity($entity), print_r($output->offsetGet($entity), true) ); }, $this->entities()))); @@ -144,7 +105,7 @@ public function process() */ public function createTransport() { - $output = $this->outputFactory->create(['type' => $this->salesforceType()]); + $output = $this->outputFactory->create(['type' => $this->units()->get('context')->getSalesforceType()]); $output->setUnit($this); foreach ($this->entities() as $entity) { @@ -174,7 +135,7 @@ public function entities() */ public function load() { - return $this->unit($this->load); + return $this->unit('load'); } /** @@ -193,7 +154,7 @@ public function processOutput(Synchronize\Transport\Calls\Delete\Transport\Outpu ) { $this->group()->messageError( 'Delete object. Entity: %s. Message: "%s".', - $this->identification->printEntity($entity), + $this->units()->get('context')->getIdentification()->printEntity($entity), $output[$entity]['message'] ); } @@ -214,7 +175,7 @@ public function prepare($entity) return; } - $entity->setData($this->fieldSalesforceId, $this->cache->get('%s/salesforce', $entity)); + $entity->setData($this->fieldSalesforceId(), $this->cache->get('%s/salesforce', $entity)); } /** @@ -241,16 +202,6 @@ public function skipped($entity) return empty($this->cache[$entity]['success']); } - /** - * Salesforce Type - * - * @return string - */ - public function salesforceType() - { - return $this->salesforceType; - } - /** * @inheridoc */ diff --git a/Synchronize/Unit/Delete/Status.php b/Synchronize/Unit/Delete/Status.php index 6311bd65..49c3ff15 100644 --- a/Synchronize/Unit/Delete/Status.php +++ b/Synchronize/Unit/Delete/Status.php @@ -13,15 +13,6 @@ */ class Status extends Synchronize\Unit\UnitAbstract { - /** - * @var string - */ - private $load; - - /** - * @var string - */ - private $deleteOutput; /** * @var SalesforceIdStorage|null @@ -31,8 +22,6 @@ class Status extends Synchronize\Unit\UnitAbstract /** * Status constructor. * @param string $name - * @param string $load - * @param string $deleteOutput * @param Synchronize\Units $units * @param Synchronize\Group $group * @param SalesforceIdStorage $salesforceIdStorage @@ -40,17 +29,13 @@ class Status extends Synchronize\Unit\UnitAbstract */ public function __construct( $name, - $load, - $deleteOutput, Synchronize\Units $units, Synchronize\Group $group, SalesforceIdStorage $salesforceIdStorage = null, array $dependents = [] ) { - parent::__construct($name, $units, $group, array_merge($dependents, [$load, $deleteOutput])); - $this->load = $load; - $this->deleteOutput = $deleteOutput; + parent::__construct($name, $units, $group, array_merge($dependents, ['load', 'deleteOutput'])); $this->salesforceIdStorage = $salesforceIdStorage; } @@ -88,7 +73,7 @@ public function process() */ public function deleteOutput() { - return $this->unit($this->deleteOutput); + return $this->unit('deleteOutput'); } /** @@ -109,7 +94,7 @@ protected function entities() */ public function load() { - return $this->unit($this->load); + return $this->unit('load'); } /** diff --git a/Synchronize/Unit/Load.php b/Synchronize/Unit/Load.php index d73dddeb..66690103 100644 --- a/Synchronize/Unit/Load.php +++ b/Synchronize/Unit/Load.php @@ -3,7 +3,6 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Model\AbstractModel; -use TNW\Salesforce\Model\Entity\SalesforceIdStorage; use TNW\Salesforce\Model\Queue; use TNW\Salesforce\Model\ResourceModel\Objects; use TNW\Salesforce\Synchronize; @@ -13,11 +12,6 @@ */ class Load extends Synchronize\Unit\UnitAbstract { - /** - * @var string - */ - private $magentoType; - /** * @var Queue[] */ @@ -28,21 +22,11 @@ class Load extends Synchronize\Unit\UnitAbstract */ private $loaders; - /** - * @var IdentificationInterface - */ - protected $identification; - /** * @var HashInterface */ private $hash; - /** - * @var SalesforceIdStorage - */ - private $entityObject; - /** * @var EntityLoaderAbstract[] */ @@ -61,60 +45,41 @@ class Load extends Synchronize\Unit\UnitAbstract /** * Load constructor. * @param string $name - * @param string $magentoType * @param Queue[] $queues * @param LoadLoaderInterface[] $loaders * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param Synchronize\Unit\IdentificationInterface $identification * @param Synchronize\Unit\HashInterface $hash * @param Objects $objects - * @param SalesforceIdStorage|null $entityObject * @param EntityLoaderAbstract[] $entityLoaders * @param array $entityTypeMapping */ public function __construct( $name, - $magentoType, array $queues, array $loaders, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Synchronize\Unit\HashInterface $hash, Objects $objects, - SalesforceIdStorage $entityObject = null, array $entityLoaders = [], array $entityTypeMapping = [] ) { parent::__construct($name, $units, $group); - $this->magentoType = $magentoType; $this->queues = $queues; $this->loaders = $loaders; - $this->identification = $identification; $this->hash = $hash; $this->objects = $objects; - $this->entityObject = $entityObject; $this->entityLoaders = $entityLoaders; $this->entityTypeMapping = $entityTypeMapping; } - /** - * Identification - * - * @return IdentificationInterface - */ - public function identification() - { - return $this->identification; - } - /** * Description */ public function description() { - return __('Loading Magento %1 ...', $this->magentoType); + return __('Loading Magento %1 ...', $this->units()->get('context')->getMagentoType()); } /** @@ -149,7 +114,7 @@ public function process() foreach ($this->entityLoaders as $entityType => $entityLoader) { $subEntity = $entityLoader->get($entity); if (!empty($subEntity)) { - if (!$subEntity->getData($subEntity->getIdFieldName())) { + if (!empty($entityLoader->getSalesforceIdStorage()) && !$subEntity->getData($subEntity->getIdFieldName())) { $salesforceIds = $this->objects->loadObjectIds( $queue->getEntityId(), $queue->getEntityType(), @@ -176,8 +141,9 @@ public function process() } } - if (null !== $this->entityObject && null !== $entity->getId()) { - $this->entityObject->load($entity, $entity->getData('config_website')); + if (null !== $this->units()->get('context')->getSalesforceIdStorage() && null !== $entity->getId()) { + $this->units()->get('context')->getSalesforceIdStorage() + ->load($entity, $entity->getData('config_website')); } $hash = $this->hash->calculateEntity($entity); @@ -188,9 +154,16 @@ public function process() $index[$hash] = $this->cache['entities'][$entity] = $entity; $this->cache['websiteIds'][$entity] = $this->websiteId($entity); - $message[] = __('Entity %1 loaded', $this->identification->printEntity($entity)); + $message[] = __( + 'Entity %1 loaded', + $this->units()->get('context')->getIdentification()->printEntity($entity) + ); } catch (\Exception $e) { - $this->group()->messageError('Magento entity loading error, queueId: %s. Error: %s', $queue->getId(), $e->getMessage()); + $this->group()->messageError( + 'Magento entity loading error, queueId: %s. Error: %s', + $queue->getId(), + $e->getMessage() + ); } } diff --git a/Synchronize/Unit/LookupAbstract.php b/Synchronize/Unit/LookupAbstract.php index fbfa85fc..f9c88835 100644 --- a/Synchronize/Unit/LookupAbstract.php +++ b/Synchronize/Unit/LookupAbstract.php @@ -13,11 +13,6 @@ */ abstract class LookupAbstract extends Synchronize\Unit\UnitAbstract { - /** - * @var string - */ - protected $load; - protected $skipMappingFields = false; /** @@ -45,18 +40,11 @@ abstract class LookupAbstract extends Synchronize\Unit\UnitAbstract */ protected $process; - /** - * @var IdentificationInterface - */ - protected $identification; - /** * LookupAbstract constructor. * @param string $name - * @param string $load * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param IdentificationInterface $identification * @param Synchronize\Transport\Calls\Query\InputFactory $inputFactory * @param Synchronize\Transport\Calls\Query\OutputFactory $outputFactory * @param Synchronize\Transport\Calls\QueryInterface $process @@ -65,23 +53,19 @@ abstract class LookupAbstract extends Synchronize\Unit\UnitAbstract */ public function __construct( $name, - $load, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Synchronize\Transport\Calls\Query\InputFactory $inputFactory, Synchronize\Transport\Calls\Query\OutputFactory $outputFactory, Synchronize\Transport\Calls\QueryInterface $process, array $dependents = [], $skipMappingFields = false ) { - parent::__construct($name, $units, $group, array_merge($dependents, [$load])); + parent::__construct($name, $units, $group, array_merge($dependents, ['load'])); - $this->load = $load; $this->inputFactory = $inputFactory; $this->outputFactory = $outputFactory; $this->process = $process; - $this->identification = $identification; $this->skipMappingFields = $skipMappingFields; } @@ -240,7 +224,7 @@ public function processOutput() $this->cache[$entity]['record'] = $this->prepareRecord($record); $message[] = __( "Found %1 entity and the following data:\n%2", - $this->identification->printEntity($entity), + $this->units()->get('context')->getIdentification()->printEntity($entity), print_r($record, true) ); } @@ -287,7 +271,7 @@ public function prepareRecord(array $record) */ public function load() { - return $this->unit($this->load); + return $this->unit('load'); } /** diff --git a/Synchronize/Unit/Mapping.php b/Synchronize/Unit/Mapping.php index 9d948733..5ae0026f 100644 --- a/Synchronize/Unit/Mapping.php +++ b/Synchronize/Unit/Mapping.php @@ -19,32 +19,11 @@ class Mapping extends Synchronize\Unit\UnitAbstract { const PARENT_ENTITY = '__parent_entity'; - /** - * @deprecated - * @var string - */ - private $load; - - /** - * @var string - */ - private $lookup; - - /** - * @var string - */ - private $objectType; - /** * @var CollectionFactory */ private $mapperCollectionFactory; - /** - * @var IdentificationInterface - */ - protected $identification; - /** * ['insert/update']['entity_type']['website_id'] => Model\ResourceModel\Mapper\Collection * @var [] @@ -55,32 +34,20 @@ class Mapping extends Synchronize\Unit\UnitAbstract * Mapping constructor. * * @param string $name - * @param string $load - * @param string $lookup - * @param string $objectType * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param IdentificationInterface $identification * @param CollectionFactory $mapperCollectionFactory * @param array $dependents */ public function __construct( $name, - $load, - $lookup, - $objectType, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, CollectionFactory $mapperCollectionFactory, array $dependents = [] ) { - parent::__construct($name, $units, $group, array_merge($dependents, [$load, $lookup])); - $this->load = $load; - $this->objectType = $objectType; - $this->identification = $identification; + parent::__construct($name, $units, $group, array_merge($dependents, ['load', 'lookup'])); $this->mapperCollectionFactory = $mapperCollectionFactory; - $this->lookup = $lookup; } /** @@ -88,11 +55,11 @@ public function __construct( */ public function description() { - if (empty($this->objectType)) { + if (empty($this->units()->get('context')->getObjectType())) { return __('System mapping'); } - return __('Mapping for %1', $this->objectType); + return __('Mapping for %1', $this->units()->get('context')->getObjectType()); } /** @@ -102,7 +69,7 @@ public function description() */ public function lookup() { - return $this->unit($this->lookup); + return $this->unit('lookup'); } /** @@ -112,17 +79,7 @@ public function lookup() */ public function load() { - return $this->unit($this->load); - } - - /** - * Object Type - * - * @return string - */ - public function objectType() - { - return $this->objectType; + return $this->unit('load'); } /** @@ -140,7 +97,7 @@ public function process() $count = 0; $message[] = __( "Entity %1 mapping:\n%2", - $this->identification->printEntity($entity), + $this->units()->get('context')->getIdentification()->printEntity($entity), implode("\n", $mappers->walk(function (Model\Mapper $mapper) use (&$count) { $count++; @@ -160,7 +117,7 @@ public function process() $this->cache[$entity] = $this->generateObject($entity, $mappers); $message[] = __( "Entity %1 mapping result:\n%2", - $this->identification->printEntity($entity), + $this->units()->get('context')->getIdentification()->printEntity($entity), print_r($this->cache[$entity], true) ); } @@ -231,7 +188,7 @@ public function value($entity, $mapper) $this->group()->messageDebug( 'Object type "%s" not found. Entity: %s.', $mapper->getMagentoEntityType(), - $this->identification->printEntity($entity) + $this->units()->get('context')->getIdentification()->printEntity($entity) ); break; @@ -278,17 +235,18 @@ public function getUpdateInsertFlag($entity) */ public function mappers($entity) { + $objectType = $this->units()->get('context')->getObjectType(); $upsertInsertFlag = $this->getUpdateInsertFlag($entity); $websiteId = (int)$this->load()->get('websiteIds/%s', $entity); - if (empty($this->collectionCache[$upsertInsertFlag][$this->objectType][$websiteId])) { + if (empty($this->collectionCache[$upsertInsertFlag][$objectType][$websiteId])) { - $this->collectionCache[$upsertInsertFlag][$this->objectType][$websiteId] = $this->mapperCollectionFactory->create() - ->addObjectToFilter($this->objectType) + $this->collectionCache[$upsertInsertFlag][$objectType][$websiteId] = $this->mapperCollectionFactory->create() + ->addObjectToFilter($objectType) ->applyUniquenessByWebsite($websiteId) ->setOrder('is_default', Collection::SORT_ORDER_DESC); } - return $this->collectionCache[$upsertInsertFlag][$this->objectType][$websiteId]; + return $this->collectionCache[$upsertInsertFlag][$objectType][$websiteId]; } /** diff --git a/Synchronize/Unit/ProcessingAbstract.php b/Synchronize/Unit/ProcessingAbstract.php index 5a8b0bfe..cdd01ed3 100644 --- a/Synchronize/Unit/ProcessingAbstract.php +++ b/Synchronize/Unit/ProcessingAbstract.php @@ -9,53 +9,21 @@ */ abstract class ProcessingAbstract extends Synchronize\Unit\UnitAbstract { - /** - * @var string - */ - private $load; - - /** - * @var Synchronize\Unit\IdentificationInterface - */ - protected $identification; - /** * ProcessingAbstract constructor. * @param string $name - * @param string $load * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param IdentificationInterface $identification * @param array $dependents */ public function __construct( $name, - $load, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, array $dependents = [] ) { - parent::__construct($name, $units, $group, array_merge($dependents, [$load])); - $this->load = $load; - $this->identification = $identification; - } - - /** - * @return IdentificationInterface - */ - public function getIdentification() - { - return $this->identification; - } - - /** - * @param IdentificationInterface $identification - */ - public function setIdentification(IdentificationInterface $identification) - { - $this->identification = $identification; + parent::__construct($name, $units, $group, array_merge($dependents, ['load'])); } /** @@ -73,7 +41,7 @@ public function description() */ public function load() { - return $this->unit($this->load); + return $this->unit('load'); } /** @@ -114,20 +82,27 @@ public function process() switch (true) { case $processing instanceof \Magento\Framework\Phrase: $this->cache[$entity] = false; - $this->cache['message'][$entity] = - __('Entity %1 skipped because %2', $this->identification->printEntity($entity), $processing); + $this->cache['message'][$entity] = __( + 'Entity %1 skipped because %2', + $this->units()->get('context')->getIdentification()->printEntity($entity), + $processing + ); break; case !$processing: $this->cache[$entity] = false; - $this->cache['message'][$entity] - = __('Entity %1 skipped', $this->identification->printEntity($entity)); + $this->cache['message'][$entity] = __( + 'Entity %1 skipped', + $this->units()->get('context')->getIdentification()->printEntity($entity) + ); break; default: $this->cache[$entity] = true; - $this->cache['message'][$entity] - = __('Entity %1 processed', $this->identification->printEntity($entity)); + $this->cache['message'][$entity] = __( + 'Entity %1 processed', + $this->units()->get('context')->getIdentification()->printEntity($entity) + ); break; } } catch (\Exception $e) { diff --git a/Synchronize/Unit/ProcessingUpsertInput.php b/Synchronize/Unit/ProcessingUpsertInput.php index 3bebc995..3d7a73fb 100644 --- a/Synchronize/Unit/ProcessingUpsertInput.php +++ b/Synchronize/Unit/ProcessingUpsertInput.php @@ -5,12 +5,39 @@ use Magento\Framework\Model\AbstractModel; use Magento\Framework\Phrase; use TNW\Salesforce\Model\Queue; +use TNW\Salesforce\Synchronize\Group; +use TNW\Salesforce\Synchronize\Transport\Soap\Calls\Upsert\Storage; +use TNW\Salesforce\Synchronize\Units; /** * Processing Upsert Input */ class ProcessingUpsertInput extends ProcessingAbstract { + /** + * @var Storage + */ + private $storage; + + /** + * @param string $name + * @param Units $units + * @param Group $group + * @param Storage $storage + * @param array $dependents + */ + public function __construct( + $name, + Units $units, + Group $group, + Storage $storage, + array $dependents = [] + ) + { + parent::__construct($name, $units, $group, $dependents); + $this->storage = $storage; + } + /** * @inheritdoc */ @@ -44,6 +71,15 @@ public function isEntityEmpty($entity) return false; } + /** + * @inheridoc + */ + public function process() + { + $this->storage->resetStorage(); + parent::process(); + } + /** * Analize * diff --git a/Synchronize/Unit/Save.php b/Synchronize/Unit/Save.php index acd5864e..83c33fd4 100644 --- a/Synchronize/Unit/Save.php +++ b/Synchronize/Unit/Save.php @@ -8,7 +8,6 @@ use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Model\AbstractModel; use OutOfBoundsException; -use TNW\Salesforce\Model\Entity\SalesforceIdStorage; use TNW\Salesforce\Synchronize; /** @@ -16,53 +15,30 @@ */ class Save extends Synchronize\Unit\UnitAbstract { - /** - * @var string - */ - protected $load; - - /** - * @var string - */ - protected $fieldModifier; /** - * @var IdentificationInterface + * @var string|null */ - protected $identification; - - /** - * @var SalesforceIdStorage - */ - protected $entityObject; + protected $fieldModifier = null; /** * Save constructor. * * @param string $name - * @param string $load - * @param string $fieldModifier * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param IdentificationInterface $identification - * @param SalesforceIdStorage $entityObject + * @param string $fieldModifier * @param array $dependents */ public function __construct( $name, - $load, - $fieldModifier, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, - SalesforceIdStorage $entityObject, + $fieldModifier = null, array $dependents = [] ) { - parent::__construct($name, $units, $group, array_merge($dependents, [$load, $fieldModifier])); - $this->load = $load; - $this->fieldModifier = $fieldModifier; - $this->identification = $identification; - $this->entityObject = $entityObject; + $this->fieldModifier = $fieldModifier ?: 'upsertOutput'; + parent::__construct($name, $units, $group, array_merge($dependents, ['load', $fieldModifier])); } /** @@ -99,26 +75,28 @@ public function processEntities($entities) foreach ($attributeNames as $attributeName) { foreach ($entities as $entity) { try { - $salesforceId = $this->entityObject->valueByAttribute($entity, $attributeName); + $salesforceId = $this->units()->get('context')->getSalesforceIdStorage() + ->valueByAttribute($entity, $attributeName); if (!$salesforceId) { continue; } // Save Salesforce Id - $this->entityObject->saveByAttribute($entity, $attributeName, $entity->getData('config_website')); + $this->units()->get('context')->getSalesforceIdStorage() + ->saveByAttribute($entity, $attributeName, $entity->getData('config_website')); $this->load()->get('%s/queue', $entity)->setAdditionalByCode($attributeName, $salesforceId); $message[] = __( "Updating %1 attribute:\n\t\"%2\": %3", - $this->identification->printEntity($entity), + $this->units()->get('context')->getIdentification()->printEntity($entity), $attributeName, $salesforceId ); // Save Salesforce Id from duplicates foreach ((array)$this->load()->get('duplicates/%s', $entity) as $duplicate) { - $this->entityObject->saveValueByAttribute( + $this->units()->get('context')->getSalesforceIdStorage()->saveValueByAttribute( $duplicate, $salesforceId, $attributeName, @@ -129,7 +107,7 @@ public function processEntities($entities) $message[] = __( "Updating %1 attribute:\n\t\"%2\": %3", - $this->identification->printEntity($duplicate), + $this->units()->get('context')->getIdentification()->printEntity($duplicate), $attributeName, $salesforceId ); @@ -155,7 +133,7 @@ public function processEntities($entities) */ public function load() { - return $this->unit($this->load); + return $this->unit('load'); } /** @@ -194,7 +172,8 @@ public function filter($entity) $result = false; foreach ($attributeName as $attribute) { - $result = $result || $this->entityObject->valueByAttribute($entity, $attribute); + $result = $result + || $this->units()->get('context')->getSalesforceIdStorage()->valueByAttribute($entity, $attribute); } return $this->fieldModifier()->get('%s/success', $entity) && $result; @@ -226,7 +205,8 @@ public function skipped($entity) $result = false; foreach ($attributeName as $attribute) { - $result = $result || $this->entityObject->valueByAttribute($entity, $attribute); + $result = $result + || $this->units()->get('context')->getSalesforceIdStorage()->valueByAttribute($entity, $attribute); } return $this->fieldModifier()->get('%s/skipped', $entity) && $result; diff --git a/Synchronize/Unit/Status.php b/Synchronize/Unit/Status.php index f7381b5a..d98f02c0 100644 --- a/Synchronize/Unit/Status.php +++ b/Synchronize/Unit/Status.php @@ -5,7 +5,6 @@ use Magento\Framework\Exception\LocalizedException; use OutOfBoundsException; use TNW\Salesforce\Model\Config; -use TNW\Salesforce\Model\Entity\SalesforceIdStorage; use TNW\Salesforce\Model\Queue; use TNW\Salesforce\Synchronize; @@ -15,48 +14,27 @@ class Status extends Synchronize\Unit\UnitAbstract { /** - * @var string + * @var Config */ - private $load; - - /** - * @var string - */ - private $upsertOutput; - - /** - * @var SalesforceIdStorage|null - */ - private $salesforceIdStorage; - - /** @var Config */ protected $config; /** * Status constructor. * @param string $name - * @param string $load - * @param string $upsertOutput * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param SalesforceIdStorage $salesforceIdStorage + * @param Config $config * @param array $dependents */ public function __construct( $name, - $load, - $upsertOutput, Synchronize\Units $units, Synchronize\Group $group, Config $config, - SalesforceIdStorage $salesforceIdStorage = null, array $dependents = [] ) { - parent::__construct($name, $units, $group, array_merge($dependents, [$load, $upsertOutput])); - $this->load = $load; - $this->upsertOutput = $upsertOutput; + parent::__construct($name, $units, $group, array_merge($dependents, ['load', 'upsertOutput'])); $this->config = $config; - $this->salesforceIdStorage = $salesforceIdStorage; } /** @@ -64,7 +42,9 @@ public function __construct( */ public function getConfig() { - return !empty($this->salesforceIdStorage) ? $this->salesforceIdStorage->getConfig() : $this->config; + return !empty($this->units()->get('context')->getSalesforceIdStorage()) + ? $this->units()->get('context')->getSalesforceIdStorage()->getConfig() + : $this->config; } /** @@ -150,14 +130,16 @@ public function process() */ public function saveStatus($entity) { - if (null !== $this->salesforceIdStorage) { + if (null !== $this->units()->get('context')->getSalesforceIdStorage()) { switch ($this->cache[$entity]['status']) { case Queue::STATUS_COMPLETE: - $this->salesforceIdStorage->saveStatus($entity, 1, $entity->getData('config_website')); + $this->units()->get('context')->getSalesforceIdStorage() + ->saveStatus($entity, 1, $entity->getData('config_website')); break; case Queue::STATUS_ERROR: - $this->salesforceIdStorage->saveStatus($entity, 0, $entity->getData('config_website')); + $this->units()->get('context')->getSalesforceIdStorage() + ->saveStatus($entity, 0, $entity->getData('config_website')); break; } } @@ -186,7 +168,7 @@ public function updateQueue() */ public function load() { - return $this->unit($this->load); + return $this->unit('load'); } /** @@ -196,7 +178,7 @@ public function load() */ public function upsertOutput() { - return $this->unit($this->upsertOutput); + return $this->unit('upsertOutput'); } /** diff --git a/Synchronize/Unit/UnitAbstract.php b/Synchronize/Unit/UnitAbstract.php index 17ea45f7..84af9d7d 100644 --- a/Synchronize/Unit/UnitAbstract.php +++ b/Synchronize/Unit/UnitAbstract.php @@ -192,7 +192,7 @@ public function status($status) } /** - * @return int + * @return void */ public function forceStatus($status) { @@ -201,7 +201,7 @@ public function forceStatus($status) } /** - * @return int + * @return void */ public function restoreStatus() { @@ -224,6 +224,6 @@ public function isComplete() */ public function correctSalesforceId($id) { - return substr($id, 0, self::MIN_LEN_SF_ID); + return is_string($id) ? substr($id, 0, self::MIN_LEN_SF_ID) : $id; } } diff --git a/Synchronize/Unit/Upsert/Input.php b/Synchronize/Unit/Upsert/Input.php index fcf8cb4f..3b7ad05f 100644 --- a/Synchronize/Unit/Upsert/Input.php +++ b/Synchronize/Unit/Upsert/Input.php @@ -17,11 +17,6 @@ */ class Input extends Synchronize\Unit\UnitAbstract { - /** - * @var Synchronize\Unit\IdentificationInterface - */ - protected $identification; - /** * @var Synchronize\Transport\Calls\Upsert\InputInterface */ @@ -32,21 +27,6 @@ class Input extends Synchronize\Unit\UnitAbstract */ protected $factory; - /** - * @var string - */ - private $load; - - /** - * @var string - */ - private $mapping; - - /** - * @var string - */ - private $salesforceType; - /** * @var array */ @@ -63,12 +43,8 @@ class Input extends Synchronize\Unit\UnitAbstract /** * Input constructor. * @param string $name - * @param string $load - * @param string $mapping - * @param string $salesforceType * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param Synchronize\Unit\IdentificationInterface $identification * @param Synchronize\Transport\Calls\Upsert\Transport\InputFactory $inputFactory * @param Synchronize\Transport\Calls\Upsert\InputInterface $process * @param ClientFactory $factory @@ -77,23 +53,15 @@ class Input extends Synchronize\Unit\UnitAbstract public function __construct( $name, - $load, - $mapping, - $salesforceType, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Synchronize\Transport\Calls\Upsert\Transport\InputFactory $inputFactory, Synchronize\Transport\Calls\Upsert\InputInterface $process, ClientFactory $factory, TimezoneInterface $localeDate ) { - parent::__construct($name, $units, $group, [$load, $mapping]); + parent::__construct($name, $units, $group, ['load', 'mapping']); $this->process = $process; - $this->load = $load; - $this->mapping = $mapping; - $this->salesforceType = $salesforceType; - $this->identification = $identification; $this->inputFactory = $inputFactory; $this->factory = $factory; @@ -113,7 +81,7 @@ public function getProcess() */ public function description() { - return __('Upserting "%1" entity', $this->salesforceType); + return __('Upserting "%1" entity', $this->units()->get('context')->getSalesforceType()); } /** @@ -121,17 +89,7 @@ public function description() */ public function load() { - return $this->unit($this->load); - } - - /** - * Salesforce Type - * - * @return string - */ - public function salesforceType() - { - return $this->salesforceType; + return $this->unit('load'); } /** @@ -152,7 +110,7 @@ public function process() $this->group()->messageDebug(implode("\n", array_map(function ($entity) use ($input) { return __( "Entity %1 request data:\n%2", - $this->identification->printEntity($entity), + $this->units()->get('context')->getIdentification()->printEntity($entity), print_r($input->offsetGet($entity), true) ); }, $this->entities()))); @@ -167,7 +125,7 @@ public function process() */ public function createTransport() { - return $this->inputFactory->create(['type' => $this->salesforceType()]); + return $this->inputFactory->create(['type' => $this->units()->get('context')->getSalesforceType()]); } /** @@ -179,7 +137,7 @@ public function createTransport() public function processInput(Synchronize\Transport\Calls\Upsert\Transport\Input $input) { foreach ($this->entities() as $entity) { - $input->offsetSet($entity, $this->prepareObject($entity, $this->unit($this->mapping)->get('%s', $entity))); + $input->offsetSet($entity, $this->prepareObject($entity, $this->unit('mapping')->get('%s', $entity))); } } @@ -205,7 +163,7 @@ public function entities() */ public function filter($entity) { - return !$this->unit($this->mapping)->skipped($entity); + return !$this->unit('mapping')->skipped($entity); } /** @@ -217,13 +175,14 @@ public function filter($entity) */ public function findFieldProperty($fieldName) { - if (empty($this->objectDescription[$this->salesforceType])) { + $salesforceType = $this->units()->get('context')->getSalesforceType(); + if (empty($this->objectDescription[$salesforceType])) { //TODO: Cache Field - $resultObjects = $this->factory->client()->describeSObjects([$this->salesforceType]); - $this->objectDescription[$this->salesforceType] = $resultObjects[0]; + $resultObjects = $this->factory->client()->describeSObjects([$salesforceType]); + $this->objectDescription[$salesforceType] = $resultObjects[0]; } - return $this->objectDescription[$this->salesforceType]->getField($fieldName); + return $this->objectDescription[$salesforceType]->getField($fieldName); } /** @@ -305,6 +264,8 @@ public function prepareObject($entity, array $object) ); unset($object[$fieldName]); } + } elseif (in_array($fieldProperty->getSoapType(), ['xsd:double'])) { + $object[$fieldName] = (float)$object[$fieldName]; } elseif (is_string($object[$fieldName])) { $object[$fieldName] = trim($object[$fieldName]); @@ -334,7 +295,7 @@ public function needUpdate($entity) return true; } - $mappedObject = $this->unit($this->mapping)->get('%s', $entity); + $mappedObject = $this->unit('mapping')->get('%s', $entity); $mappedObject = (object)$this->prepareObject($entity, (array)$mappedObject); $lookupObject = $lookup->get('%s/record', $entity); @@ -344,12 +305,26 @@ public function needUpdate($entity) } foreach ($mappedObject as $compareField => $compareValue) { - if (in_array($compareField, $this->unit($this->mapping)->getCompareIgnoreFields())) { + if (in_array($compareField, $this->unit('mapping')->getCompareIgnoreFields())) { continue; } - if (empty($lookupObject[$compareField]) || $compareValue != $lookupObject[$compareField]) { - $this->group()->messageDebug('Entity %1 has changed field: %2 = %3', $this->identification->printEntity($entity), $compareField, $compareValue); + if ($compareValue instanceof \DateTime && !empty($lookupObject[$compareField]) && $lookupObject[$compareField] instanceof \DateTime) { + $fieldProperty = $this->findFieldProperty($compareField); + if (strcasecmp($fieldProperty->getType(), 'date') === 0) { + $compareValue + ->setTimezone($lookupObject[$compareField]->getTimezone()) + ->setTime(0, 0); + } + } + + if ((empty($lookupObject[$compareField]) && !empty($compareValue)) || (!empty($lookupObject[$compareField]) && $compareValue != $lookupObject[$compareField])) { + $this->group()->messageDebug( + 'Entity %1 has changed field: %2 = %3', + $this->units()->get('context')->getIdentification()->printEntity($entity), + $compareField, + $compareValue + ); return true; } } @@ -363,10 +338,15 @@ public function needUpdate($entity) $this->cache[$entity]['updated'] = true; $this->cache[$entity]['salesforce'] = $lookupObject['Id']; - $this->cache[$entity]['message'] - = __('Synchronization of the %1 was skipped, data is Salesforce matches the data in Magento.', $this->identification->printEntity($entity)); - - $this->group()->messageDebug('Synchronization of the %1 was skipped, data is Salesforce matches the data in Magento.', $this->identification->printEntity($entity)); + $this->cache[$entity]['message'] = __( + 'Synchronization of the %1 was skipped, data is Salesforce matches the data in Magento.', + $this->units()->get('context')->getIdentification()->printEntity($entity) + ); + + $this->group()->messageDebug( + 'Synchronization of the %1 was skipped, data is Salesforce matches the data in Magento.', + $this->units()->get('context')->getIdentification()->printEntity($entity) + ); return false; } diff --git a/Synchronize/Unit/Upsert/Output.php b/Synchronize/Unit/Upsert/Output.php index 9b8ab373..36ba6f77 100644 --- a/Synchronize/Unit/Upsert/Output.php +++ b/Synchronize/Unit/Upsert/Output.php @@ -18,36 +18,11 @@ class Output extends Synchronize\Unit\UnitAbstract implements Synchronize\Unit\F */ private $outputFactory; - /** - * @var Synchronize\Unit\IdentificationInterface - */ - protected $identification; - /** * @var Synchronize\Transport\Calls\Upsert\OutputInterface */ private $process; - /** - * @var string - */ - private $load; - - /** - * @var string - */ - private $upsertInput; - - /** - * @var string - */ - private $salesforceType; - - /** - * @var - */ - private $fieldSalesforceId; - /** * @var array */ @@ -57,13 +32,8 @@ class Output extends Synchronize\Unit\UnitAbstract implements Synchronize\Unit\F * Upsert constructor. * * @param string $name - * @param string $load - * @param string $upsertInput - * @param string $salesforceType - * @param string $fieldSalesforceId * @param Synchronize\Units $units * @param Synchronize\Group $group - * @param Synchronize\Unit\IdentificationInterface $identification * @param Synchronize\Transport\Calls\Upsert\Transport\OutputFactory $outputFactory * @param Synchronize\Transport\Calls\Upsert\OutputInterface $process * @param array $dependents @@ -71,28 +41,18 @@ class Output extends Synchronize\Unit\UnitAbstract implements Synchronize\Unit\F */ public function __construct( $name, - $load, - $upsertInput, - $salesforceType, - $fieldSalesforceId, Synchronize\Units $units, Synchronize\Group $group, - Synchronize\Unit\IdentificationInterface $identification, Synchronize\Transport\Calls\Upsert\Transport\OutputFactory $outputFactory, Synchronize\Transport\Calls\Upsert\OutputInterface $process, array $dependents = [], array $additionalSalesforceId = [] ) { - parent::__construct($name, $units, $group, array_merge($dependents, [$load, $upsertInput])); + parent::__construct($name, $units, $group, array_merge($dependents, ['load', 'upsertInput'])); - $this->load = $load; - $this->salesforceType = $salesforceType; - $this->fieldSalesforceId = $fieldSalesforceId; $this->additionalSalesforceId = $additionalSalesforceId; - $this->identification = $identification; $this->outputFactory = $outputFactory; $this->process = $process; - $this->upsertInput = $upsertInput; } /** @@ -100,7 +60,7 @@ public function __construct( */ public function description() { - return __('Upserting "%1" entity', $this->salesforceType); + return __('Upserting "%1" entity', $this->units()->get('context')->getSalesforceType()); } /** @@ -108,7 +68,7 @@ public function description() */ public function load() { - return $this->unit($this->load); + return $this->unit('load'); } /** @@ -118,17 +78,7 @@ public function load() */ public function upsertInput() { - return $this->unit($this->upsertInput); - } - - /** - * Salesforce Type - * - * @return string - */ - public function salesforceType() - { - return $this->salesforceType; + return $this->unit('upsertInput'); } /** @@ -138,7 +88,7 @@ public function salesforceType() */ public function fieldSalesforceId() { - return $this->fieldSalesforceId; + return $this->units()->get('context')->getFieldSalesforceId(); } /** @@ -164,7 +114,7 @@ public function process() $this->group()->messageDebug(implode("\n", array_map(function ($entity) use ($output) { return __( "Entity %1 response data:\n%2", - $this->identification->printEntity($entity), + $this->units()->get('context')->getIdentification()->printEntity($entity), print_r($output->offsetGet($entity), true) ); }, $this->entities()))); @@ -179,7 +129,7 @@ public function process() */ public function createTransport() { - $output = $this->outputFactory->create(['type' => $this->salesforceType()]); + $output = $this->outputFactory->create(['type' => $this->units()->get('context')->getSalesforceType()]); $output->setUnit($this); foreach ($this->entities() as $entity) { @@ -233,8 +183,8 @@ public function processOutput(Synchronize\Transport\Calls\Upsert\Transport\Outpu ) { $this->group()->messageError( 'Upsert object "%s". Entity: %s. Message: "%s".', - $this->salesforceType, - $this->identification->printEntity($entity), + $this->units()->get('context')->getSalesforceType(), + $this->units()->get('context')->getIdentification()->printEntity($entity), $output[$entity]['message'] ); } @@ -255,7 +205,7 @@ public function prepare($entity) return; } - $entity->setData($this->fieldSalesforceId, $this->cache->get('%s/salesforce', $entity)); + $entity->setData($this->fieldSalesforceId(), $this->cache->get('%s/salesforce', $entity)); } /** diff --git a/Synchronize/Units.php b/Synchronize/Units.php index b4ae5c1d..39dec2fe 100644 --- a/Synchronize/Units.php +++ b/Synchronize/Units.php @@ -11,12 +11,15 @@ class Units implements \IteratorAggregate /** * Add * - * @param Unit\UnitInterface $unit + * @param Unit\UnitInterface|null $unit * @return $this */ public function add(Unit\UnitInterface $unit) { - $this->units[$unit->name()] = $unit; + if ($unit) { + $this->units[$unit->name()] = $unit; + } + return $this; } @@ -48,7 +51,7 @@ public function sort() $addUnit = function (array &$sortUnits, Unit\UnitInterface $unit) use (&$addUnit) { foreach ($unit->dependents() as $dependent) { if (empty($this->units[$dependent])) { - throw new \RuntimeException(sprintf('Not fount unit "%s"', $dependent)); + throw new \RuntimeException(sprintf('Not found unit "%s"', $dependent)); } if (isset($sortUnits[$dependent])) { diff --git a/composer.json b/composer.json index 03b2c0f1..4a959e22 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "gpl-3.0" ], "type": "magento2-module", - "version": "2.7.16", + "version": "2.8.1", "autoload": { "files": [ "registration.php" diff --git a/etc/db_schema.xml b/etc/db_schema.xml index 4c8be1db..9b52ae03 100644 --- a/etc/db_schema.xml +++ b/etc/db_schema.xml @@ -170,8 +170,6 @@ - - diff --git a/etc/di.xml b/etc/di.xml index 1f39fbdf..785c6ae4 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -56,11 +56,7 @@ - customerLoad - customer TNW\Salesforce\Synchronize\Unit\Customer\Hash - TNW\Salesforce\Synchronize\Unit\Customer\Identification - TNW\Salesforce\Model\Entity\Object\Customer TNW\Salesforce\Synchronize\Unit\Customer\Mapping\Loader\Website @@ -70,46 +66,31 @@ - - - customerBusinessAccountProcessingUpsertInput - customerLoad - TNW\Salesforce\Synchronize\Unit\Customer\Identification - - - - customerBusinessAccountLookupByContact - customerLoad - TNW\Salesforce\Synchronize\Unit\Customer\Identification - customerBusinessAccountProcessingUpsertInput + processingUpsertInput - customerBusinessAccountLookupByName - customerLoad - TNW\Salesforce\Synchronize\Unit\Customer\Identification - customerBusinessAccountProcessingUpsertInput + processingUpsertInput - lookup - customerBusinessAccountLookupByContact - customerBusinessAccountLookupByName + lookupByContact + lookupByName - - + + @@ -123,95 +104,41 @@ - mapping - customerLoad - lookup - Account - TNW\Salesforce\Synchronize\Unit\Customer\Identification - - customerBusinessAccountProcessingUpsertInput - - - - - - - upsertInput - customerLoad - mapping - Account - TNW\Salesforce\Synchronize\Unit\Customer\Identification - - - - - - customerBusinessAccountProcessingUpsertOutput - customerLoad - TNW\Salesforce\Synchronize\Unit\Customer\Identification - - - - - - upsertOutput - customerLoad - upsertInput - Account - sforce_account_id - TNW\Salesforce\Synchronize\Unit\Customer\Identification - customerBusinessAccountProcessingUpsertOutput + processingUpsertInput - - - save - customerLoad - upsertOutput - TNW\Salesforce\Synchronize\Unit\Customer\Identification - TNW\Salesforce\Model\Entity\Object\Customer - - - - - - customerBusinessAccountStatus - customerLoad - upsertOutput - TNW\Salesforce\Model\Entity\Object\Customer - - - - + customerBusinessAccount + TNW\Unit\Customer\BusinessAccount\Context TNW\Unit\Customer\BusinessAccount\Load - TNW\Unit\Customer\BusinessAccount\ProcessingUpsertInput - TNW\Unit\Customer\BusinessAccount\Lookup\ByContact TNW\Unit\Customer\BusinessAccount\Lookup\ByName TNW\Unit\Customer\BusinessAccount\Lookup TNW\Unit\Customer\BusinessAccount\Mapping - TNW\Unit\Customer\BusinessAccount\UpsertInput - TNW\Unit\Customer\BusinessAccount\ProcessingUpsertOutput - TNW\Unit\Customer\BusinessAccount\UpsertOutput - TNW\Customer\BusinessAccount\Save - TNW\Unit\Customer\BusinessAccount\Status + TNW\Salesforce\Synchronize\Unit\Customer\Account\Upsert\Input - + - customerLoad + TNW\Salesforce\Synchronize\Unit\Customer\Identification + TNW\Salesforce\Model\Entity\Object\Customer customer + Account + Account + sforce_account_id + + + + + TNW\Salesforce\Synchronize\Unit\Customer\Hash - TNW\Salesforce\Synchronize\Unit\Customer\Identification - TNW\Salesforce\Model\Entity\Object\Customer TNW\Salesforce\Synchronize\Unit\Customer\Mapping\Loader\Website TNW\Salesforce\Synchronize\Unit\Customer\Mapping\Loader\Customer @@ -222,216 +149,74 @@ - - - customerContactProcessingUpsertInput - customerLoad - TNW\Salesforce\Synchronize\Unit\Customer\Identification - - - - - - lookup - customerLoad - TNW\Salesforce\Synchronize\Unit\Customer\Identification - - - - - - - mapping - customerLoad - lookup - Contact - TNW\Salesforce\Synchronize\Unit\Customer\Identification - customerContactProcessingUpsertInput + processingUpsertInput - + - upsertInput - customerLoad - mapping - Contact - TNW\Salesforce\Synchronize\Unit\Customer\Identification - - - - - - customerContactProcessingUpsertOutput - customerLoad - TNW\Salesforce\Synchronize\Unit\Customer\Identification - - - - - - upsertOutput - customerLoad - upsertInput - Contact - sforce_id - TNW\Salesforce\Synchronize\Unit\Customer\Identification - - customerContactProcessingUpsertOutput + customerContact + + TNW\Unit\Customer\Contact\Context + TNW\Unit\Customer\Contact\Load + TNW\Salesforce\Synchronize\Unit\Customer\Contact\Lookup + TNW\Unit\Customer\Contact\Mapping - + - save - customerLoad - upsertOutput TNW\Salesforce\Synchronize\Unit\Customer\Identification - TNW\Salesforce\Model\Entity\Object\Customer - - - - - - customerContactStatus - customerLoad - upsertOutput TNW\Salesforce\Model\Entity\Object\Customer - - - - - - customerContact - - TNW\Unit\Customer\Contact\Load - TNW\Unit\Customer\Contact\ProcessingUpsertInput - TNW\Unit\Customer\Contact\Lookup - TNW\Unit\Customer\Contact\Mapping - TNW\Unit\Customer\Contact\UpsertInput - TNW\Unit\Customer\Contact\ProcessingUpsertOutput - TNW\Unit\Customer\Contact\UpsertOutput - TNW\Customer\Contact\Save - TNW\Unit\Customer\Contact\Status - + customer + Contact + Contact + sforce_id - websiteLoad - website TNW\Salesforce\Synchronize\Unit\Website\Hash - TNW\Salesforce\Model\Entity\Object\Website - TNW\Salesforce\Synchronize\Unit\Website\Identification TNW\Salesforce\Synchronize\Unit\Website\Loader\ByWebsite - - - websiteWebsiteProcessingUpsertInput - websiteLoad - TNW\Salesforce\Synchronize\Unit\Website\Identification - - - - - - lookup - websiteLoad - TNW\Salesforce\Synchronize\Unit\Website\Identification - - - - - - - mapping - websiteLoad - lookup - Website - TNW\Salesforce\Synchronize\Unit\Website\Identification - websiteWebsiteProcessingUpsertInput + processingUpsertInput - - - upsertInput - websiteLoad - mapping - tnw_mage_basic__Magento_Website__c - TNW\Salesforce\Synchronize\Unit\Website\Identification - - - - + - websiteWebsiteProcessingUpsertOutput - websiteLoad - TNW\Salesforce\Synchronize\Unit\Website\Identification - - - - - - upsertOutput - websiteLoad - upsertInput - tnw_mage_basic__Magento_Website__c - salesforce_id - TNW\Salesforce\Synchronize\Unit\Website\Identification - - websiteWebsiteProcessingUpsertOutput + websiteWebsite + + TNW\Unit\Website\Website\Context + TNW\Unit\Website\Website\Load + TNW\Salesforce\Synchronize\Unit\Website\Website\Lookup + TNW\Salesforce\Synchronize\Unit\Website\Website\Mapping - + - save - websiteLoad - upsertOutput - TNW\Salesforce\Model\Entity\Object\Website TNW\Salesforce\Synchronize\Unit\Website\Identification - - - - - - websiteWebsiteStatus - websiteLoad - upsertOutput TNW\Salesforce\Model\Entity\Object\Website - - - - - - websiteWebsite - - TNW\Unit\Website\Website\Load - TNW\Unit\Website\Website\ProcessingUpsertInput - TNW\Unit\Website\Website\Lookup - TNW\Salesforce\Synchronize\Unit\Website\Website\Mapping - TNW\Unit\Website\Website\UpsertInput - TNW\Unit\Website\Website\ProcessingUpsertOutput - TNW\Unit\Website\Website\UpsertOutput - TNW\Unit\Website\Website\Save - TNW\Unit\Website\Website\Status - + website + Website + tnw_mage_basic__Magento_Website__c + salesforce_id @@ -667,4 +452,46 @@ + + + + + + + + + + + + + TNW\Salesforce\Synchronize\Unit\Context + TNW\Salesforce\Synchronize\Unit\Load + TNW\Salesforce\Synchronize\Unit\ProcessingUpsertInput + TNW\Salesforce\Synchronize\Unit\LookupAbstract + TNW\Salesforce\Synchronize\Unit\Mapping + TNW\Salesforce\Synchronize\Unit\Upsert\Input + TNW\Salesforce\Synchronize\Unit\ProcessingUpsertOutput + TNW\Salesforce\Synchronize\Unit\Upsert\Output + TNW\Salesforce\Synchronize\Unit\Save + TNW\Salesforce\Synchronize\Unit\Status + + + + + + + TNW\Salesforce\Synchronize\Unit\Identification + + + + + + + processingUpsertOutput + + + + diff --git a/view/adminhtml/requirejs-config.js b/view/adminhtml/requirejs-config.js index c0d1ed9d..4276e4c2 100644 --- a/view/adminhtml/requirejs-config.js +++ b/view/adminhtml/requirejs-config.js @@ -1,7 +1,7 @@ var config = { map: { '*': { - testConnection: 'TNW_Salesforce/js/connection', + testTnwSalesforceConnection: 'TNW_Salesforce/js/connection', fileBrowse: 'TNW_Salesforce/js/browse' } }