integration-helper / integration-version-magento-client
N/A
Installs: 49
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:magento2-module
Requires
- php: ~8.1.0||~8.2.0
- integration-helper/integration-version-magento: ~1.0.10
- magento/framework: 103.0.*
- magento/module-backend: 102.0.*
- magento/module-config: 101.2.*
- magento/module-store: 101.1.*
README
Usage
Default:
Add Configuration in System Admin Config (Api Url, Api Key, Api Secret Key or Token)
use IntegrationHelper\IntegrationVersionMagentoClient\Import\AbstractImportClient; class ImportProcess extends AbstractImportClient { public function import() { foreach ($this->itemsData() as $itemsData) { //... prepare $itemsData to import //..save $itemsData } } public function getSourceCode(): string { return self::SOURCE_CODE; } public function callbackAfterClearOldData(): void { // TODO: Implement callbackAfterClearOldData() method. } public function callbackBeforeSaveLatestHash(): void { } public function callbackAfterReturnData(): void { // TODO: Implement callbackAfterReturnData() method. } public function callbackBeforeGetItem(): void { // TODO: Implement callbackBeforeGetItem() method. } public function callbackBeforeStart(): void { } }
Custom:
Add Configuration in System Admin Config (Api Url, Api Key, Api Secret Key or Token)
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <virtualType name="Vendor\ApiAppIntegrationVersion\ApiRequest\EngineApiRequest" type="IntegrationHelper\IntegrationVersionMagentoClient\ApiRequest\BaseApiRequest"> <arguments> <argument name="configProvider" xsi:type="object">Vendor\ApiAppIntegrationVersion\Model\ConfigProvider</argument> <argument name="getCachedToken" xsi:type="object">IntegrationHelper\IntegrationVersionMagentoClient\ApiRequest\GetCachedToken</argument> <argument name="type" xsi:type="string">engine_api_request</argument> <argument name="name" xsi:type="string">Engine Api Request</argument> </arguments> </virtualType> <virtualType name="Vendor\ApiAppIntegrationVersion\Service\EngineIntegrationVersionManager" type="IntegrationHelper\IntegrationVersionMagentoClient\Service\IntegrationVersionManager" > <arguments> <argument name="apiRequest" xsi:type="object">Vendor\ApiAppIntegrationVersion\ApiRequest\EngineApiRequest</argument> </arguments> </virtualType> <type name="Vendor\ApiAppIntegrationVersion\Service\RunImports"> <arguments> <argument name="integrationVersionManager" xsi:type="object">Vendor\ApiAppIntegrationVersion\Service\EngineIntegrationVersionManager</argument> </arguments> </type> </config>
Get Deleted Identities
public function __construct( protected IntegrationVersionManager $integrationVersionManager ){} public function deleteOldData() { $tableName = $integrationVersion->getTableName(); $connection = $this->resourceConnection->getConnection(); $page = 1; while(true) { $query = $connection->select()->from($tableName, $integrationVersion->getIdentityColumn()) ->limitPage($page++, 10000); $identities = $connection->fetchCol($query); if(!$identities) break; $deletedIdentities = $this->integrationVersionManager ->getDeletedIdentities(self::SOURCE_CODE, $identities); if($deletedIdentities) { $connection->deleteFromSelect( $connection->select()->from($tableName)->where($integrationVersion->getIdentityColumn() . ' IN (?)', $deletedIdentities) ); } } }