1717use Magento \Store \Model \ScopeInterface ;
1818use Magento \Store \Model \Store ;
1919use Magento \Store \Model \StoreManagerInterface ;
20+ use Magento \Catalog \Helper \Data ;
2021
2122/**
2223 * Catalog product custom option resource model
2324 *
24- * @author Magento Core Team <[email protected] > 25+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2526 */
2627class Value extends AbstractDb
2728{
@@ -51,6 +52,11 @@ class Value extends AbstractDb
5152 */
5253 private $ localeFormat ;
5354
55+ /**
56+ * @var Data
57+ */
58+ private $ dataHelper ;
59+
5460 /**
5561 * Class constructor
5662 *
@@ -59,17 +65,20 @@ class Value extends AbstractDb
5965 * @param StoreManagerInterface $storeManager
6066 * @param ScopeConfigInterface $config
6167 * @param string $connectionName
68+ * @param Data $dataHelper
6269 */
6370 public function __construct (
6471 Context $ context ,
6572 CurrencyFactory $ currencyFactory ,
6673 StoreManagerInterface $ storeManager ,
6774 ScopeConfigInterface $ config ,
68- $ connectionName = null
75+ $ connectionName = null ,
76+ Data $ dataHelper = null
6977 ) {
7078 $ this ->_currencyFactory = $ currencyFactory ;
7179 $ this ->_storeManager = $ storeManager ;
7280 $ this ->_config = $ config ;
81+ $ this ->dataHelper = $ dataHelper ?: ObjectManager::getInstance ()->get (Data::class);
7382 parent ::__construct ($ context , $ connectionName );
7483 }
7584
@@ -130,7 +139,7 @@ protected function _saveValuePrices(AbstractModel $object)
130139 $ optionTypeId = $ this ->getConnection ()->fetchOne ($ select );
131140
132141 if ($ optionTypeId ) {
133- if ($ object ->getStoreId () == '0 ' ) {
142+ if ($ object ->getStoreId () == '0 ' || $ this -> dataHelper -> isPriceGlobal () ) {
134143 $ bind = ['price ' => $ price , 'price_type ' => $ priceType ];
135144 $ where = [
136145 'option_type_id = ? ' => $ optionTypeId ,
0 commit comments