init
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Catalog\Model\MixStepPricing;
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
|
||||
class DeleteService
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SpreadsheetReader $reader,
|
||||
private readonly BatchValidator $validator,
|
||||
private readonly AttributeWriter $attributeWriter
|
||||
) {
|
||||
}
|
||||
|
||||
public function validate(string $path): array
|
||||
{
|
||||
return $this->validator->validateDelete($this->reader->readDelete($path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function run(string $path): array
|
||||
{
|
||||
$result = $this->validate($path);
|
||||
if (!$result['valid']) {
|
||||
throw new LocalizedException(__('Validation failed. No prices were deleted.'));
|
||||
}
|
||||
if ($result['groups'] === []) {
|
||||
throw new LocalizedException(__('There are no existing configurable products to delete.'));
|
||||
}
|
||||
|
||||
return $this->attributeWriter->write($result['groups'], true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user