PHP code example of integration-helper / integration-version-magento-client

1. Go to this page and download the library: Download integration-helper/integration-version-magento-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

integration-helper / integration-version-magento-client example snippets


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
    {
    }
}


 
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)
                );
            }
        }
       
    
 }