This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -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);
}
}