Skip to content

Commit

Permalink
fix: Fixed Services for preparing export entities
Browse files Browse the repository at this point in the history
  • Loading branch information
hmennen90 committed Nov 25, 2024
1 parent bea0ecd commit 93252fd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function getLanguages(): Languages

public function callStoredProcedure(int $id, string $type): void
{
$this->connection->executeQuery('CALL makairaChange('.$id.','.$type.')');
$this->connection->executeQuery('CALL makairaChange('.$id.',"'.$type.'")');
}

public function exportIsDoneForType(string $type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function prepareExport(): void
/** @var \CategoryReadService $categoryReadService */
$categoryReadService = \StaticGXCoreLoader::getService('CategoryRead');
/** @var \CategoryListItemCollection $categories */
$categories = $categoryReadService->getCategoryList(new \LanguageCode($language->code()));
$categories = $categoryReadService->getCategoryList(new \LanguageCode(new \StringType($language->code())));
/** @var CategoryListItem $category */
foreach($categories as $category) {
$this->callStoredProcedure($category->getCategoryId(), 'category');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\FetchMode;
use Exception;
use Gambio\Admin\Modules\Language\Model\Language;
use GXModules\MakairaIO\MakairaConnect\App\Documents\MakairaEntity;
use GXModules\MakairaIO\MakairaConnect\App\GambioConnectService;
use GXModules\MakairaIO\MakairaConnect\App\Mapper\MakairaDataMapper;
Expand All @@ -17,14 +18,14 @@ class GambioConnectManufacturerService extends GambioConnectService implements G

public function prepareExport(): void
{
$languages = $this->getLanguages();
/** @var \ManufacturerReadService $readService */
$readService = \StaticGXCoreLoader::getService('ManufacturerRead');

foreach ($languages as $language) {
$manufacturers = $this->getQuery($language->id());
$manufacturers = $readService->getAll();

foreach ($manufacturers as $manufacturer) {
$this->callStoredProcedure($manufacturer['manufacturers_id'], 'manufacturer');
}
/** @var \ManufacturerInterface $manufacturer */
foreach($manufacturers as $manufacturer) {
$this->callStoredProcedure($manufacturer->getId(), 'manufacturer');
}
}

Expand Down Expand Up @@ -73,7 +74,7 @@ public function pushRevision(array $manufacturer): MakairaEntity
return MakairaDataMapper::mapManufacturer($manufacturer);
}

public function getQuery(string $language, array $makairaChanges = []): array
public function getQuery(Language $language, array $makairaChanges = []): array
{
$query = $this->connection->createQueryBuilder()
->select('*')
Expand All @@ -85,7 +86,7 @@ public function getQuery(string $language, array $makairaChanges = []): array
'manufacturers.manufacturers_id = manufacturers_info.manufacturers_id'
)
->where('manufacturers_info.languages_id = :languageId')
->setParameter('languageId', $language);
->setParameter('languageId', $language->id());

if (! empty($makairaChanges)) {
$ids = array_map(fn ($change) => $change['gambio_id'], $makairaChanges);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ public function prepareExport(): void
{
$languages = $this->getLanguages();

/** @var \ProductReadService $productReadService */
$productReadService = \StaticGXCoreLoader::getService('ProductRead');


foreach ($languages as $language) {
$products = $this->getQuery($language->id());
$products = $productReadService->getProductList(new \LanguageCode(new \StringType($language->code())));

/** @var \ProductListItem $product */
foreach ($products as $product) {
$this->connection->executeQuery('CALL makairaChange('.$product['products_id'].', "product")');
$this->connection->executeQuery('CALL makairaChange('.$product->getProductId().', "product")');
}
}
}
Expand Down

0 comments on commit 93252fd

Please sign in to comment.