31 private $entityManager;
54 $this->entityManager = $entityManager
65 $this->
_init(
'catalog_product_bundle_selection',
'selection_id');
83 $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField();
86 [
'product_id',
'parent_product_id',
'option_id']
88 [
'e' => $this->
getTable(
'catalog_product_entity')],
89 'e.entity_id = tbl_selection.product_id AND e.required_options=0',
92 [
'parent' => $this->
getTable(
'catalog_product_entity')],
93 'tbl_selection.parent_product_id = parent.' . $linkField
95 [
'tbl_option' => $this->
getTable(
'catalog_product_bundle_option')],
96 'tbl_option.option_id = tbl_selection.option_id',
99 'parent.entity_id = :parent_id' 102 if (
$row[
'required']) {
103 $childrenIds[
$row[
'option_id']][
$row[
'product_id']] =
$row[
'product_id'];
105 $notRequired[
$row[
'option_id']][
$row[
'product_id']] =
$row[
'product_id'];
110 $childrenIds = array_merge($childrenIds, $notRequired);
113 foreach ($notRequired as $groupedChildrenIds) {
114 foreach ($groupedChildrenIds as $childId) {
115 $childrenIds[0][$childId] = $childId;
136 $metadata = $this->metadataPool->getMetadata(ProductInterface::class);
143 [
'e' => $this->metadataPool->getMetadata(ProductInterface::class)->getEntityTable()],
144 'e.' . $metadata->getLinkField() .
' = ' . $this->
getMainTable() .
'.parent_product_id',
145 [
'e.entity_id as parent_product_id']
163 if (
$item->getDefaultPriceScope()) {
165 $this->
getTable(
'catalog_product_bundle_selection_price'),
167 'selection_id = ?' =>
$item->getSelectionId(),
168 'website_id = ?' =>
$item->getWebsiteId(),
169 'parent_product_id = ?' =>
$item->getParentProductId(),
174 'selection_id' =>
$item->getSelectionId(),
175 'website_id' =>
$item->getWebsiteId(),
176 'selection_price_type' =>
$item->getSelectionPriceType(),
177 'selection_price_value' =>
$item->getSelectionPriceValue(),
178 'parent_product_id' =>
$item->getParentProductId(),
181 $this->
getTable(
'catalog_product_bundle_selection_price'),
183 [
'selection_price_type',
'selection_price_value']
192 public function save(\
Magento\Framework\Model\AbstractModel $object)
194 $this->entityManager->save($object);
getParentIdsByChild($childId)
_init($mainTable, $idFieldName)
saveSelectionPrice($item)
save(\Magento\Framework\Model\AbstractModel $object)
__construct(Context $context, MetadataPool $metadataPool, $connectionName=null, EntityManager $entityManager=null)
getChildrenIds($parentId, $required=true)