integration-helper / integration-version-magento-client
N/A
Installs: 23
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: *
- 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\IntegrationVersion\Repository\IntegrationVersionRepositoryInterface; public function __construct( protected IntegrationVersionRepositoryInterface $integrationVersionRepository, protected IntegrationVersionManager $integrationVersionManager ){} public function importsRun() { foreach ($this->integrationVersionRepository->getItems() as $item) { $source = $item->getSource(); $latestOutputData = $this->integrationVersionManager->getLatestHashData($source); if($latestOutputData->isError()) { $this->integrationVersionManager->saveLatestHash($source, $latestOutputData); continue; } $identities = []; foreach ( $this->integrationVersionManager ->getIdentities( $source, $item->getHash(), $item->getHashDateTime()) as $items) { $identities[] = //.... get identities } //Get Yours Api request from Mapped $source-$request if($identities) { $request->importByIdentities($identities); //Request by Api and get Items by ids } } }
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="tokenApiMethod" xsi:type="const">\IntegrationHelper\IntegrationVersionMagentoClient\Api\ConstraintsInterface::BASE_TOKEN_METHOD</argument> <argument name="identitiesApiMethod" xsi:type="const">\IntegrationHelper\IntegrationVersionMagentoClient\Api\ConstraintsInterface::BASE_GET_IDENTITIES_METHOD</argument> <argument name="latestHashApiMethod" xsi:type="const">\IntegrationHelper\IntegrationVersionMagentoClient\Api\ConstraintsInterface::BASE_GET_LATEST_HASH_METHOD</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) ); } } }