Skip to content

Commit

Permalink
Merge pull request #2212 from bakaphp/disable-workflow-import
Browse files Browse the repository at this point in the history
[Fix] Workflow Trigger Fix
  • Loading branch information
arfenis authored Oct 18, 2024
2 parents 44faac4 + 05985c5 commit bcbe1cf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ public function execute(): array
$jobUuid = Str::uuid()->toString();

ProductImporterJob::dispatch(
$jobUuid,
[$mappedProduct],
$integrationCompany->company->branch,
$this->receiver->user,
$integrationCompany->region,
$this->receiver->app
jobUuid: $jobUuid,
importer: [$mappedProduct],
branch: $integrationCompany->company->branch,
user: $this->receiver->user,
region: $integrationCompany->region,
app: $this->receiver->app,
runWorkflow: false
);

return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public function __construct(
public Companies $company,
public UserInterface $user,
public Regions $region,
public ?AppInterface $app = null
public ?AppInterface $app = null,
public bool $runWorkflow = true
) {
$this->app = $this->app ?? app(Apps::class);
}
Expand Down Expand Up @@ -81,7 +82,9 @@ public function execute(): ProductsModel
'is_published' => $this->importedProduct->isPublished,
'attributes' => $this->importedProduct->attributes,
]);
$this->product = (new CreateProductAction($productDto, $this->user))->execute();
$createAction = new CreateProductAction($productDto, $this->user);
$createAction->setRunWorkflow($this->runWorkflow);
$this->product = $createAction->execute();

if (isset($this->importedProduct->customFields) && ! empty($this->importedProduct->customFields)) {
$this->product->setAllCustomFields($this->importedProduct->customFields);
Expand Down
6 changes: 4 additions & 2 deletions src/Domains/Inventory/Importer/Jobs/ProductImporterJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public function __construct(
public UserInterface $user,
public Regions $region,
public AppInterface $app,
public ?FilesystemImports $filesystemImport = null
public ?FilesystemImports $filesystemImport = null,
public bool $runWorkflow = true
) {
$minuteDelay = (int)($app->get('delay_minute_job') ?? 0);
$queue = $this->onQueue('imports');
Expand Down Expand Up @@ -129,7 +130,8 @@ public function handle()
$company,
$this->user,
$this->region,
$this->app
$this->app,
$this->runWorkflow
))->execute();
if ($product->wasRecentlyCreated) {
$created++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,10 @@ public function execute(): Products

return $products;
}

public function setRunWorkflow(bool $runWorkflow): self
{
$this->runWorkflow = $runWorkflow;
return $this;
}
}

0 comments on commit bcbe1cf

Please sign in to comment.