Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-bundle
Model
OptionManagement.php
Go to the documentation of this file.
1
<?php
8
namespace
Magento\Bundle\Model
;
9
10
use
Magento\Framework\Exception\InputException
;
11
12
class
OptionManagement
implements
\Magento\Bundle\Api\ProductOptionManagementInterface
13
{
17
protected
$optionRepository
;
18
22
protected
$productRepository
;
23
28
public
function
__construct
(
29
\
Magento
\Bundle\Api\ProductOptionRepositoryInterface
$optionRepository
,
30
\
Magento
\Catalog\Api\
ProductRepositoryInterface
$productRepository
31
) {
32
$this->optionRepository =
$optionRepository
;
33
$this->productRepository =
$productRepository
;
34
}
35
39
public
function
save
(\
Magento
\Bundle\Api\Data\
OptionInterface
$option
)
40
{
41
$product
= $this->productRepository->get(
$option
->getSku(),
true
);
42
if
(
$product
->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
43
throw
new
InputException
(
__
(
'This is implemented for bundle products only.'
));
44
}
45
return
$this->optionRepository->save(
$product
,
$option
);
46
}
47
}
Magento\Bundle\Api\ProductOptionManagementInterface
Definition:
ProductOptionManagementInterface.php:15
Magento\Bundle\Model\OptionManagement
Definition:
OptionManagement.php:12
Magento\Bundle\Api\Data\OptionInterface
Definition:
OptionInterface.php:15
Magento\Bundle\Model
__
__()
Definition:
__.php:13
Magento\Framework\Exception\InputException
Definition:
InputException.php:17
Magento\Catalog\Api\ProductRepositoryInterface
Definition:
ProductRepositoryInterface.php:14
Magento\Bundle\Model\OptionManagement\$productRepository
$productRepository
Definition:
OptionManagement.php:22
Magento\Bundle\Model\OptionManagement\$optionRepository
$optionRepository
Definition:
OptionManagement.php:17
Magento
Magento\Bundle\Model\OptionManagement\__construct
__construct(\Magento\Bundle\Api\ProductOptionRepositoryInterface $optionRepository, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository)
Definition:
OptionManagement.php:28
$product
$product
Definition:
bundle_product_with_not_visible_children.php:22
Magento\Bundle\Model\OptionManagement\save
save(\Magento\Bundle\Api\Data\OptionInterface $option)
Definition:
OptionManagement.php:39
$option
$option
Definition:
product_configurable_with_single_child.php:38