<?php
namespace Import1CBundle\EventListener;
use Import1CBundle\Event\ArticleUpdateEvent;
use Import1CBundle\Helper\v3\ConnectionHelper;
use WebBundle\Helper\App;
class ArticleUpdateListener
{
public function onArticleUpdate(ArticleUpdateEvent $event)
{
$items = $event->getTovar();
$code = $items['CODE'] ?? null;
if(!$code){
return;
}
$updateService = App::getContainer()->get('bi.v4.service.update');
$updateService->saveHash($code, $event->getTovar());
$queueService = App::getContainer()->get('bi.v4.service.queue');
$queueService->toQueueArticleUpdateDescription($items, $event->getId(), $event->getI());
$queueService->toQueueArticleUpdatePrice($items, $event->getId(), $event->getI());
$items = $this->items($code);
$queueService->toQueueArticleUpdateDiscount($items, $event->getId(), $event->getI());
}
private function items($code): ?array
{
$sql = sprintf(
'SELECT * FROM VOLUMEPRC WHERE CODE=\'%s\';',
$code,
);
return ConnectionHelper::getInstance('oneC')->executeColumnsRows($sql);
}
}