10 use Magento\Catalog\Model\ResourceModel\Product\Collection\ProductLimitationFactory;
20 class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection
32 private $itemPrototype =
null;
37 private $catalogRuleProcessor =
null;
44 private $websiteScopePriceJoined =
false;
83 \
Magento\Framework\Event\ManagerInterface $eventManager,
86 \
Magento\Eav\Model\EntityFactory $eavEntityFactory,
91 \
Magento\Catalog\Model\Indexer\
Product\Flat\State $catalogProductFlatState,
93 \
Magento\Catalog\Model\
Product\OptionFactory $productOptionFactory,
96 \
Magento\Customer\Model\Session $customerSession,
100 ProductLimitationFactory $productLimitationFactory =
null,
102 \
Magento\Catalog\Model\Indexer\Category\
Product\TableMaintainer $tableMaintainer =
null,
117 $catalogProductFlatState,
119 $productOptionFactory,
126 $productLimitationFactory,
131 $this->stockItem = $stockItem
142 parent::_construct();
144 $this->_selectionTable = $this->
getTable(
'catalog_product_bundle_selection');
154 return parent::_afterLoad();
164 parent::_initSelect();
166 [
'selection' => $this->_selectionTable],
167 'selection.product_id = e.entity_id',
182 'price.selection_price_type IS NOT NULL',
183 'price.selection_price_type',
184 'selection.selection_price_type' 187 'price.selection_price_value IS NOT NULL',
188 'price.selection_price_value',
189 'selection.selection_price_value' 192 [
'price' => $this->
getTable(
'catalog_product_bundle_selection_price')],
193 'selection.selection_id = price.selection_id AND price.website_id = ' . (
int)
$websiteId .
194 ' AND selection.parent_product_id = price.parent_product_id',
197 'selection_price_value' => $priceValue,
198 'parent_product_id' =>
'price.parent_product_id',
199 'price_scope' =>
'price.website_id' 202 $this->websiteScopePriceJoined =
true;
229 if (!empty($selectionIds)) {
230 $this->
getSelect()->where(
'selection.selection_id IN (?)', $selectionIds);
242 $this->
getSelect()->order(
'selection.position asc')->order(
'selection.selection_id asc');
254 $manageStockExpr = $this->stockItem->getManageStockExpr(
'stock_item');
255 $backordersExpr = $this->stockItem->getBackordersExpr(
'stock_item');
257 'selection.selection_can_change_qty',
258 $this->stockItem->getMinSaleQtyExpr(
'stock_item'),
259 'selection.selection_qty' 262 $where = $manageStockExpr .
' = 0';
268 . $minQtyExpr .
' <= stock_item.qty' 274 [
'stock_item' => $this->stockItem->getMainTable()],
275 'selection.product_id = stock_item.product_id',
288 if (
null === $this->itemPrototype) {
289 $this->itemPrototype = parent::getNewEmptyItem();
291 return clone $this->itemPrototype;
308 if ($useRegularPrice) {
309 $minimalPriceExpression = self::INDEX_TABLE_ALIAS .
'.price';
311 $this->getCatalogRuleProcessor()->addPriceData($this,
'selection.product_id');
312 $minimalPriceExpression =
'LEAST(minimal_price, IFNULL(catalog_rule_price, minimal_price))';
314 $orderByValue = new \Zend_Db_Expr(
316 $minimalPriceExpression .
317 ' * selection.selection_qty' .
323 'price.selection_price_type',
324 'selection.selection_price_type' 327 'price.selection_price_value',
328 'selection.selection_price_value' 330 if (!$this->websiteScopePriceJoined) {
331 $websiteId = $this->_storeManager->getStore()->getWebsiteId();
333 [
'price' => $this->
getTable(
'catalog_product_bundle_selection_price')],
334 'selection.selection_id = price.selection_id AND price.website_id = ' . (
int)
$websiteId,
340 (
float)
$product->getPrice() .
' * '. $priceValue .
' / 100',
343 $orderByValue = new \Zend_Db_Expr(
'('.
$price.
' * '.
'selection.selection_qty)');
359 private function getCatalogRuleProcessor()
361 if (
null === $this->catalogRuleProcessor) {
366 return $this->catalogRuleProcessor;
setOptionIdsFilter($optionIds)
setSelectionIdsFilter($selectionIds)
addPriceData($customerGroupId=null, $websiteId=null)
setRowIdFieldName($fieldName)
addPriceFilter($product, $searchMin, $useRegularPrice=false)
__construct(\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\App\ResourceConnection $resource, \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, \Magento\Catalog\Model\ResourceModel\Url $catalogUrl, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Customer\Api\GroupManagementInterface $groupManagement, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null, ProductLimitationFactory $productLimitationFactory=null, \Magento\Framework\EntityManager\MetadataPool $metadataPool=null, \Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer $tableMaintainer=null, \Magento\CatalogInventory\Model\ResourceModel\Stock\Item $stockItem=null)