![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-quote/Model/Quote/Item/ |
<?php /** * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Quote\Model\Quote\Item; class RelatedProducts { /** * List of related product types * * @var array */ protected $_relatedProductTypes; /** * @param array $relatedProductTypes */ public function __construct($relatedProductTypes = []) { $this->_relatedProductTypes = $relatedProductTypes; } /** * Retrieve Array of product ids which have special relation with products in Cart * * @param \Magento\Quote\Model\Quote\Item[] $quoteItems * @return int[] */ public function getRelatedProductIds(array $quoteItems) { $productIds = []; /** @var $quoteItems \Magento\Quote\Model\Quote\Item[] */ foreach ($quoteItems as $quoteItem) { $productTypeOpt = $quoteItem->getOptionByCode('product_type'); if ($productTypeOpt instanceof \Magento\Quote\Model\Quote\Item\Option) { if (in_array( $productTypeOpt->getValue(), $this->_relatedProductTypes ) && $productTypeOpt->getProductId() ) { $productIds[] = $productTypeOpt->getProductId(); } } } return $productIds; } }