1515use Magento \Catalog \Model \ResourceModel \Product \Collection ;
1616use Magento \Catalog \Model \ResourceModel \Product \CollectionFactory ;
1717use Magento \Catalog \Pricing \Price \FinalPrice ;
18+ use Magento \Catalog \ViewModel \Product \OptionsData ;
1819use Magento \CatalogWidget \Model \Rule ;
1920use Magento \Framework \App \ActionInterface ;
2021use Magento \Framework \App \Http \Context as HttpContext ;
@@ -130,6 +131,11 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
130131 */
131132 private $ categoryRepository ;
132133
134+ /**
135+ * @var OptionsData
136+ */
137+ private OptionsData $ optionsData ;
138+
133139 /**
134140 * @param Context $context
135141 * @param CollectionFactory $productCollectionFactory
@@ -143,6 +149,7 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
143149 * @param LayoutFactory|null $layoutFactory
144150 * @param EncoderInterface|null $urlEncoder
145151 * @param CategoryRepositoryInterface|null $categoryRepository
152+ * @param OptionsData|null $optionsData
146153 *
147154 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
148155 */
@@ -158,7 +165,8 @@ public function __construct(
158165 Json $ json = null ,
159166 LayoutFactory $ layoutFactory = null ,
160167 EncoderInterface $ urlEncoder = null ,
161- CategoryRepositoryInterface $ categoryRepository = null
168+ CategoryRepositoryInterface $ categoryRepository = null ,
169+ OptionsData $ optionsData = null
162170 ) {
163171 $ this ->productCollectionFactory = $ productCollectionFactory ;
164172 $ this ->catalogProductVisibility = $ catalogProductVisibility ;
@@ -171,6 +179,7 @@ public function __construct(
171179 $ this ->urlEncoder = $ urlEncoder ?: ObjectManager::getInstance ()->get (EncoderInterface::class);
172180 $ this ->categoryRepository = $ categoryRepository ?? ObjectManager::getInstance ()
173181 ->get (CategoryRepositoryInterface::class);
182+ $ this ->optionsData = $ optionsData ?: ObjectManager::getInstance ()->get (OptionsData::class);
174183 parent ::__construct (
175184 $ context ,
176185 $ data
@@ -306,6 +315,17 @@ public function getAddToCartPostParams(Product $product)
306315 ];
307316 }
308317
318+ /**
319+ * Return product options
320+ *
321+ * @param Product $product
322+ * @return array
323+ */
324+ public function getOptionsData (Product $ product ): array
325+ {
326+ return $ this ->optionsData ->getOptionsData ($ product );
327+ }
328+
309329 /**
310330 * @inheritdoc
311331 */
0 commit comments