Skip to content

Commit 39eb471

Browse files
author
Myron
committed
generalize and update code
1 parent b76dafa commit 39eb471

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

Controller/Adminhtml/Product/MassEnrich.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Magento\Backend\Model\View\Result\Redirect;
88
use Magento\Catalog\Api\ProductRepositoryInterface;
99
use Magento\Backend\App\Action;
10+
use Magento\Catalog\Model\Product;
1011
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
1112
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1213
use Magento\Framework\Controller\ResultFactory;
@@ -41,7 +42,7 @@ public function execute(): Redirect
4142

4243
$productEnriched = 0;
4344
if($this->config->isEnabled()) {
44-
/** @var \Magento\Catalog\Model\Product $product */
45+
/** @var Product $product */
4546
foreach ($collection->getItems() as $product) {
4647
//@TODO: we hit rate limit, change to batching the request
4748
$this->publisher->execute($product->getId(), $this->overwrite);

Model/Config.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22
declare(strict_types=1);
3+
34
namespace MageOS\CatalogDataAI\Model;
45

56
use Magento\Framework\App\Config\ScopeConfigInterface;
6-
USE Magento\Catalog\Model\Product;
7+
use Magento\Catalog\Model\Product;
78

89
class Config
910
{
@@ -19,8 +20,7 @@ class Config
1920

2021
public function __construct(
2122
private readonly ScopeConfigInterface $scopeConfig
22-
) {
23-
}
23+
) {}
2424

2525
public function isEnabled(): bool
2626
{

Model/Product/Enricher.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
class Enricher
1414
{
1515
private Client $client;
16-
public function __construct
17-
(
16+
public function __construct(
1817
private readonly Factory $clientFactory,
1918
private readonly Config $config
2019
) {

Model/Product/Publisher.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ class Publisher
1616
public function __construct(
1717
private readonly PublisherInterface $publisher,
1818
private readonly RequestFactory $requestFactory,
19-
) {
20-
}
19+
) {}
2120

2221
/**
2322
* @param int|string $productId

Observer/Product/SaveBefore.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ public function execute(Observer $observer): void
2424
if($this->config->canEnrich($product) && !$this->config->isAsync()) {
2525
$this->enricher->execute($product);
2626
}
27-
2827
}
2928
}

0 commit comments

Comments
 (0)