3

I want to check if some attribute values have changed after editing a Variant group in Akeneo V. 1.3.

Unfortunately I am a little bit lost: Is there a way to get from a Pim\Bundle\CatalogBundle\Entity\Group to the attribute values? Is there another better way to get these values of a Variant group that was edited?

I cannot even find out in which table the attribute values are stored in MySQL (I've just found pim_catalog_product_value for the product values).

Freelancer
  • 4,459
  • 2
  • 22
  • 28
Sonson123
  • 10,879
  • 12
  • 54
  • 72

1 Answers1

8

Yes, it's not easy to dig into this part.

The values of a variant group are not stored in the same way than the products values.

These variant group values are only used to be copied in related products and are stored in a product template.

From a product template, you can fetch the values normalized in json with

$group->getProductTemplate()->getValuesData()`.

You can take a look on ProductTemplateApplier and ProductTemplateUpdater to see how we apply variant group values on products (json format is useable almost directly with product updater).

When we edit a variant group, to be able to use the same form than for the product, we use a subscriber TransformProductTemplateValuesSubscriber.

It denormalizes json values to product values objects with

$this->denormalizer->denormalize($data->getValuesData(), 'ProductValue[]', 'json');`

Don't hesitate if you need any further information.

Freelancer
  • 4,459
  • 2
  • 22
  • 28
nidup
  • 96
  • 2