Search code examples
shopwareshopware6

Delete the relation between a product and a property group option


Does anyone know a way to delete the relation between a product and a property group option using DAL?


Solution

  • You would need to delete the corresponding product_property entity. The primary key is the productId combined with the (property group) optionId. So instead of providing an id with the delete, you provide the above attributes.

        $this->productPropertyRepository->delete([
            ['productId' => $data->get('product'), 'optionId' => $data->get('red')],
            ['productId' => $data->get('product'), 'optionId' => $data->get('green')],
        ], Context::createDefaultContext());