Symfony 3.4.2 Akeneo – Can’t get the original attribute data in the event

I’m using to check if some attributes were changed. The problem is that repository always returns new data instead of old data from database. Does anyone got any ideas how to fix it? Or maybe it is another way to check if attribute value is changed?

 * @param GenericEvent $event
public function onPreSave(GenericEvent $event)
     * Array with fields, needed to be checked for updates
    $lProjectVars = [

    //get product with changed values from form
    $subject = $event->getSubject();
    if (!$subject instanceof ProductInterface || null == $this->requestStack->getCurrentRequest()) {
        // don't do anything if it's not a product OR not a HTTP request

    //get product with old values from database
    $product = $this->productRepository->findOneByIdentifier($subject->getIdentifier());

    foreach ($subject->getAttributes() as $attribute) {
        if (in_array($attribute->getCode(), $lProjectVars)) {
            if ($subject->getValue($attribute->getCode()) !== $product->getValue($attribute->getCode())) {
                $this->propertySetter->setData($subject, "last_modification", date('Y-m-d'), ['locale' => null, 'scope' => null]);


Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *