11 use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory;
104 private $metadataPool;
109 private $customOptionValuesFactory;
129 \
Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
138 ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory =
null 144 $this->customOptionValuesFactory = $customOptionValuesFactory ?:
166 return $this->_resource ?: parent::_getResource();
175 parent::_construct();
198 if (isset($this->values[$valueId])) {
199 return $this->values[$valueId];
310 if (
$type ===
null) {
313 $optionGroupsToTypes = [
326 return $optionGroupsToTypes[
$type] ??
'';
340 return $this->optionTypeFactory->create(
341 'Magento\Catalog\Model\Product\Option\Type\\' . $this->string->upperCaseWords(
$group)
354 parent::beforeSave();
355 if ($this->
getData(
'previous_type') !=
'') {
356 $previousType = $this->
getData(
'previous_type');
366 if ($this->
getId()) {
371 $this->
setData(
'file_extension',
'');
372 $this->
setData(
'image_size_x',
'0');
373 $this->
setData(
'image_size_y',
'0');
376 $this->
setData(
'max_characters',
'0');
385 if ($this->
getId()) {
392 $this->cleanFileExtensions();
413 $this->customOptionValuesFactory->create()
422 return parent::afterSave();
434 if ($flag && $this->
getPriceType() == self::$typePercent) {
435 $basePrice = $this->
getProduct()->getPriceInfo()->getPrice(BasePrice::PRICE_CODE)->getValue();
439 return $this->
_getData(self::KEY_PRICE);
475 return $this->getOptionRepository()->getProductOptions(
$product, $this->getAddRequiredFilter());
513 $this->
getResource()->duplicate($this, $oldProductId, $newProductId);
538 $this->values =
null;
549 if (!empty($this->values)) {
550 foreach ($this->values as
$value) {
562 return $this->validatorPool->get($this->
getType());
572 $productSku = $this->
_getData(self::KEY_PRODUCT_SKU);
587 return $this->
_getData(self::KEY_OPTION_ID);
597 return $this->
_getData(self::KEY_TITLE);
607 return $this->
_getData(self::KEY_TYPE);
617 return $this->
_getData(self::KEY_SORT_ORDER);
628 return $this->
_getData(self::KEY_IS_REQUIRE);
638 return $this->
_getData(self::KEY_PRICE_TYPE);
648 return $this->
_getData(self::KEY_SKU);
656 return $this->
getData(self::KEY_FILE_EXTENSION);
664 return $this->
getData(self::KEY_MAX_CHARACTERS);
672 return $this->
getData(self::KEY_IMAGE_SIZE_X);
680 return $this->
getData(self::KEY_IMAGE_SIZE_Y);
691 return $this->
setData(self::KEY_PRODUCT_SKU, $productSku);
735 return $this->
setData(self::KEY_SORT_ORDER, $sortOrder);
746 return $this->
setData(self::KEY_IS_REQUIRE, $isRequired);
779 return $this->
setData(self::KEY_SKU, $sku);
788 return $this->
setData(self::KEY_FILE_EXTENSION, $fileExtension);
797 return $this->
setData(self::KEY_MAX_CHARACTERS, $maxCharacters);
806 return $this->
setData(self::KEY_IMAGE_SIZE_X, $imageSizeX);
815 return $this->
setData(self::KEY_IMAGE_SIZE_Y, $imageSizeY);
847 $basePrice = $this->
getProduct()->getPriceInfo()->getPrice(
'regular_price')->getAmount()->getValue();
851 return $this->
_getData(self::KEY_PRICE);
863 $product->
getData($this->getMetadataPool()->getMetadata(ProductInterface::class)->getLinkField())
876 if ($this->getAddRequiredFilter()) {
877 $collection->addRequiredFilter($this->getAddRequiredFilterValue());
899 private function getOptionRepository()
901 if (
null === $this->optionRepository) {
911 private function getMetadataPool()
913 if (
null === $this->metadataPool) {
915 ->get(\
Magento\Framework\EntityManager\MetadataPool::class);
917 return $this->metadataPool;
927 private function cleanFileExtensions()
931 preg_match_all(
'/(?<extensions>[a-z0-9]+)/i', strtolower($rawExtensions), $matches);
932 if (!empty($matches)) {
933 $extensions = implode(
', ', array_unique($matches[
'extensions']));
setFileExtension($fileExtension)
duplicate($oldProductId, $newProductId)
_getExtensionAttributes()
elseif(isset( $params[ 'redirect_parent']))
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
getOptionValuesByOptionId($optionIds, $storeId)
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, Option\Value $productOptionValue, \Magento\Catalog\Model\Product\Option\Type\Factory $optionFactory, \Magento\Framework\Stdlib\StringUtils $string, Option\Validator\Pool $validatorPool, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[], ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory=null)
setImageSizeX($imageSizeX)
const OPTION_GROUP_SELECT
setMaxCharacters($maxCharacters)
setExtensionAttributes(\Magento\Catalog\Api\Data\ProductCustomOptionExtensionInterface $extensionAttributes)
setValues(array $values=null)
_getValidationRulesBeforeSave()
setImageSizeY($imageSizeY)
getData($key='', $index=null)
setData($key, $value=null)
getGroupByType($type=null)
getProductOptions(Product $product)
addValue(Option\Value $value)
getSearchableData($productId, $storeId)
getProductOptionCollection(Product $product)
setProductSku($productSku)
setIsRequire($isRequired)
setProduct(Product $product=null)