phpsymfonysyliusresolver

Sylius override AvailableProductOptionValuesResolver


With sylius 1.13 i wan't to override AvailableProductOptionValuesResolver.php

I've copied the original class in src/Component/Product/Resolver/AvailableProductOptionValuesResolver.php

and change the namespace and add debug:

<?php

namespace App\Component\Product\Resolver;
class AvailableProductOptionValuesResolver implements AvailableProductOptionValuesResolverInterface
{
    public function resolve(ProductInterface $product, ProductOptionInterface $productOption): Collection
    {
        dd('modify');

What other changes need to be made for this class to be used? Because here it's always the file in /vendor/.../AvailableProductOptionValuesResolver that's used.


Solution

  • I had forgotten to define the service configuration dans services.yaml:

    App\Component\Product\Resolver\AvailableProductOptionValuesResolver:
            decorates: 'sylius.available_product_option_values_resolver'