<?php
namespace Jabber\GenericBundle\EventListener;
use Pimcore\Event\Model\DataObjectEvent;
use Pimcore\Event\Model\ElementEventInterface;
use Pimcore\Model\DataObject\Product;
class CopyProofing {
public function onPreUpdateAndSave (ElementEventInterface $e) {
if (!$e->hasArgument('isAutoSave')) {
if ($e instanceof DataObjectEvent) {
// do something with the object
$dataObject = $e->getObject();
if ($dataObject instanceof Product) {
if ($dataObject->getProductLevel() == "PARENT" || $dataObject->getProductLevel() == "STYLE" || ($dataObject->getProductLevel() != "CHILD" && $dataObject->getParent()->getType() != "variant")) {
if (method_exists($dataObject, "getDescription") && !empty($dataObject->getDescription())) {
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
$redis->sAdd('dev_pimcore_copy_proofing', $dataObject->getId());
}
}
}
}
}
}
}