File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
src/EventSubscriber/OpenGraph Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 66
77use Setono \SyliusSEOPlugin \OpenGraph \OpenGraph ;
88use Sylius \Component \Channel \Context \ChannelContextInterface ;
9+ use Sylius \Component \Locale \Context \LocaleContextInterface ;
910use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
1011use Symfony \Component \HttpKernel \KernelEvents ;
1112
1213final class AddChannelInformationSubscriber implements EventSubscriberInterface
1314{
1415 public function __construct (
1516 private readonly ChannelContextInterface $ channelContext ,
17+ private readonly LocaleContextInterface $ localeContext ,
1618 private readonly OpenGraph $ openGraph ,
1719 ) {
1820 }
@@ -29,5 +31,6 @@ public function add(): void
2931 $ channel = $ this ->channelContext ->getChannel ();
3032
3133 $ this ->openGraph ->siteName ((string ) $ channel ->getName ());
34+ $ this ->openGraph ->locale ($ this ->localeContext ->getLocaleCode ());
3235 }
3336}
Original file line number Diff line number Diff line change @@ -33,12 +33,10 @@ public function add(ResourceControllerEvent $event): void
3333 Assert::isInstanceOf ($ product , ProductInterface::class);
3434
3535 $ images = $ this ->productImagesResolver ->resolve ($ product );
36- if ([] = == $ images ) {
37- return ;
36+ if ([] ! == $ images ) {
37+ $ this -> openGraph -> image (( new Image ( $ images [ 0 ]))-> alt ( $ product -> getName ())) ;
3838 }
3939
40- foreach ($ images as $ image ) {
41- $ this ->openGraph ->image (Image::create ($ image ));
42- }
40+ $ this ->openGraph ->description ($ product ->getDescription ());
4341 }
4442}
You can’t perform that action at this time.
0 commit comments