File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed
Resources/config/services Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 44
55namespace Setono \SyliusSEOPlugin \Resolver ;
66
7+ use Sylius \Component \Core \Model \ProductInterface ;
78use Sylius \Component \Core \Model \ProductVariantInterface ;
89
910final class CachedProductImagesResolver implements ProductImagesResolverInterface
@@ -15,10 +16,10 @@ public function __construct(private readonly ProductImagesResolverInterface $dec
1516 {
1617 }
1718
18- public function resolve (ProductVariantInterface $ productVariant ): array
19+ public function resolve (ProductInterface | ProductVariantInterface $ product ): array
1920 {
2021 if (null === $ this ->images ) {
21- $ this ->images = $ this ->decorated ->resolve ($ productVariant );
22+ $ this ->images = $ this ->decorated ->resolve ($ product );
2223 }
2324
2425 return $ this ->images ;
Original file line number Diff line number Diff line change 88use Sylius \Component \Core \Model \ImageInterface ;
99use Sylius \Component \Core \Model \ProductInterface ;
1010use Sylius \Component \Core \Model \ProductVariantInterface ;
11+ use Sylius \Component \Product \Resolver \ProductVariantResolverInterface ;
1112
1213final class ProductImagesResolver implements ProductImagesResolverInterface
1314{
1415 public function __construct (
16+ private readonly ProductVariantResolverInterface $ productVariantResolver ,
1517 private readonly CacheManager $ cacheManager ,
1618 private readonly string $ filter = 'sylius_original ' ,
1719 ) {
1820 }
1921
20- public function resolve (ProductVariantInterface $ productVariant ): array
22+ public function resolve (ProductInterface | ProductVariantInterface $ product ): array
2123 {
24+ if ($ product instanceof ProductInterface) {
25+ $ product = $ this ->productVariantResolver ->getVariant ($ product );
26+ if (!$ product instanceof ProductVariantInterface) {
27+ return [];
28+ }
29+ }
30+
2231 $ images = [];
2332
24- foreach (self ::getImages ($ productVariant ) as $ image ) {
33+ foreach (self ::getImages ($ product ) as $ image ) {
2534 $ path = $ image ->getPath ();
2635 if (null === $ path ) {
2736 continue ;
Original file line number Diff line number Diff line change 44
55namespace Setono \SyliusSEOPlugin \Resolver ;
66
7+ use Sylius \Component \Core \Model \ProductInterface ;
78use Sylius \Component \Core \Model \ProductVariantInterface ;
89
910interface ProductImagesResolverInterface
@@ -13,5 +14,5 @@ interface ProductImagesResolverInterface
1314 *
1415 * @return list<string>
1516 */
16- public function resolve (ProductVariantInterface $ productVariant ): array ;
17+ public function resolve (ProductInterface | ProductVariantInterface $ product ): array ;
1718}
Original file line number Diff line number Diff line change 66 alias =" Setono\SyliusSEOPlugin\Resolver\ProductImagesResolver" />
77
88 <service id =" Setono\SyliusSEOPlugin\Resolver\ProductImagesResolver" >
9+ <argument type =" service" id =" sylius.product_variant_resolver.default" />
910 <argument type =" service" id =" liip_imagine.cache.manager" />
1011 </service >
1112
You can’t perform that action at this time.
0 commit comments