17
17
use Magento \Store \Model \ScopeInterface ;
18
18
use Magento \Store \Model \Store ;
19
19
use Magento \Store \Model \StoreManagerInterface ;
20
+ use Magento \Catalog \Helper \Data ;
20
21
21
22
/**
22
23
* Catalog product custom option resource model
23
24
*
24
- * @author Magento Core Team <core@magentocommerce.com>
25
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
25
26
*/
26
27
class Value extends AbstractDb
27
28
{
@@ -51,6 +52,11 @@ class Value extends AbstractDb
51
52
*/
52
53
private $ localeFormat ;
53
54
55
+ /**
56
+ * @var Data
57
+ */
58
+ private $ dataHelper ;
59
+
54
60
/**
55
61
* Class constructor
56
62
*
@@ -59,17 +65,21 @@ class Value extends AbstractDb
59
65
* @param StoreManagerInterface $storeManager
60
66
* @param ScopeConfigInterface $config
61
67
* @param string $connectionName
68
+ * @param Data $dataHelper
62
69
*/
63
70
public function __construct (
64
71
Context $ context ,
65
72
CurrencyFactory $ currencyFactory ,
66
73
StoreManagerInterface $ storeManager ,
67
74
ScopeConfigInterface $ config ,
68
- $ connectionName = null
75
+ $ connectionName = null ,
76
+ Data $ dataHelper = null
69
77
) {
70
78
$ this ->_currencyFactory = $ currencyFactory ;
71
79
$ this ->_storeManager = $ storeManager ;
72
80
$ this ->_config = $ config ;
81
+ $ this ->dataHelper = $ dataHelper ?: ObjectManager::getInstance ()
82
+ ->get (Data::class);
73
83
parent ::__construct ($ context , $ connectionName );
74
84
}
75
85
@@ -131,7 +141,7 @@ protected function _saveValuePrices(AbstractModel $object)
131
141
$ optionTypeId = $ this ->getConnection ()->fetchOne ($ select );
132
142
133
143
if ($ optionTypeId ) {
134
- if ($ object ->getStoreId () == '0 ' ) {
144
+ if ($ object ->getStoreId () == '0 ' || $ this -> dataHelper -> isPriceGlobal () ) {
135
145
$ bind = ['price ' => $ price , 'price_type ' => $ priceType ];
136
146
$ where = [
137
147
'option_type_id = ? ' => $ optionTypeId ,
0 commit comments