Skip to content

Commit 25d95ca

Browse files
committed
Merge remote-tracking branch 'commerce/2.4.3-develop' into PWA-1700
2 parents 42bef5b + 8c25bda commit 25d95ca

File tree

11 files changed

+101
-202
lines changed

11 files changed

+101
-202
lines changed

app/code/Magento/Catalog/Model/Product.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ public function beforeSave()
883883

884884
$this->getTypeInstance()->beforeSave($this);
885885

886-
$hasOptions = $this->getData('has_options') === "1";
887-
$hasRequiredOptions = $this->getData('required_options') === "1";
886+
$hasOptions = $this->getData('has_options') === "1" && $this->isProductHasOptions();
887+
$hasRequiredOptions = $this->getData('required_options') === "1" && $this->isProductHasOptions();
888888

889889
/**
890890
* $this->_canAffectOptions - set by type instance only
@@ -934,6 +934,21 @@ public function beforeSave()
934934
parent::beforeSave();
935935
}
936936

937+
/**
938+
* Check based on options data
939+
*
940+
* @return bool
941+
*/
942+
private function isProductHasOptions() : bool
943+
{
944+
if ($this->getData('options') === null) {
945+
$result = true;
946+
} else {
947+
$result = is_array($this->getData('options')) && count($this->getData('options')) > 0;
948+
}
949+
return $result;
950+
}
951+
937952
/**
938953
* Check/set if options can be affected when saving product
939954
*

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,21 @@ public function testSaveWithProvidedRequiredOptions()
11131113
$this->assertTrue($this->model->getRequiredOptions());
11141114
}
11151115

1116+
/**
1117+
* Test for save method with provided options settled via magic method
1118+
*/
1119+
public function testSaveWithProvidedRequiredOptionsValue()
1120+
{
1121+
$this->model->setHasOptions("1");
1122+
$this->model->setRequiredOptions("1");
1123+
$this->model->setData("options", null);
1124+
$this->configureSaveTest();
1125+
$this->model->beforeSave();
1126+
$this->model->afterSave();
1127+
$this->assertTrue($this->model->getHasOptions());
1128+
$this->assertTrue($this->model->getRequiredOptions());
1129+
}
1130+
11161131
public function testGetIsSalableSimple()
11171132
{
11181133
$typeInstanceMock =

app/code/Magento/Paypal/Model/PayLaterConfig.php

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Magento\Paypal\Model;
99

10-
use Magento\Framework\App\Config\ScopeConfigInterface;
11-
1210
/**
1311
* Provides configuration values for PayPal PayLater Banners
1412
*/
@@ -34,25 +32,17 @@ class PayLaterConfig
3432
*/
3533
private $config;
3634

37-
/**
38-
* @var ScopeConfigInterface
39-
*/
40-
private $scopeConfig;
41-
4235
/**
4336
* @var array
4437
*/
4538
private $configData = [];
4639

4740
/**
48-
* @param ScopeConfigInterface $scopeConfig
4941
* @param ConfigFactory $configFactory
5042
*/
5143
public function __construct(
52-
ScopeConfigInterface $scopeConfig,
5344
ConfigFactory $configFactory
5445
) {
55-
$this->scopeConfig = $scopeConfig;
5646
$this->config = $configFactory->create();
5747
}
5848

@@ -76,9 +66,9 @@ public function isEnabled(string $placement): bool
7666
/**
7767
* Check that PayPal Credit enabled with any PayPal express method
7868
*
79-
* @return
69+
* @return bool
8070
*/
81-
private function isPPCreditEnabled()
71+
private function isPPCreditEnabled(): bool
8272
{
8373
$isEnabled = false;
8474
if ($this->config->setMethod(Config::METHOD_EXPRESS)->getValue('in_context')) {
@@ -106,35 +96,47 @@ public function getSectionConfig(string $section, string $key)
10696
$this->configData[$section] = [
10797
'display' => (boolean)$this->config->getPayLaterConfigValue("${sectionName}_display"),
10898
'position' => $this->config->getPayLaterConfigValue("${sectionName}_position"),
109-
'style' => [
110-
'data-pp-style-layout' => $this->config->getPayLaterConfigValue(
111-
"${sectionName}_stylelayout"
112-
),
113-
'data-pp-style-logo-type' => $this->config->getPayLaterConfigValue(
114-
"${sectionName}_logotype"
115-
),
116-
'data-pp-style-logo-position' => $this->config->getPayLaterConfigValue(
117-
"${sectionName}_logoposition"
118-
),
119-
'data-pp-style-text-color' => $this->config->getPayLaterConfigValue(
120-
"${sectionName}_textcolor"
121-
),
122-
'data-pp-style-text-size' => $this->config->getPayLaterConfigValue(
123-
"${sectionName}_textsize"
124-
),
125-
'data-pp-style-color' => $this->config->getPayLaterConfigValue(
126-
"${sectionName}_color"
127-
),
128-
'data-pp-style-ratio' => $this->config->getPayLaterConfigValue(
129-
"${sectionName}_ratio"
130-
)
131-
]
99+
'style' => $this->getConfigStyles($sectionName)
132100
];
133101
}
134102

135103
return $this->configData[$section][$key];
136104
}
137105

106+
/**
107+
* Get only the config styles that are needed
108+
*
109+
* @param string $sectionName
110+
* @return array
111+
*/
112+
private function getConfigStyles(string $sectionName): array
113+
{
114+
$logoType = $logoPosition = $textColor = $textSize = null;
115+
$color = $ratio = null;
116+
$styleLayout = $this->config->getPayLaterConfigValue("${sectionName}_stylelayout");
117+
if ($styleLayout === 'text') {
118+
$logoType = $this->config->getPayLaterConfigValue("${sectionName}_logotype");
119+
if ($logoType === 'primary' || $logoType === 'alternative') {
120+
$logoPosition = $this->config->getPayLaterConfigValue("${sectionName}_logoposition");
121+
}
122+
$textColor = $this->config->getPayLaterConfigValue("${sectionName}_textcolor");
123+
$textSize = $this->config->getPayLaterConfigValue("${sectionName}_textsize");
124+
} elseif ($styleLayout === 'flex') {
125+
$color = $this->config->getPayLaterConfigValue("${sectionName}_color");
126+
$ratio = $this->config->getPayLaterConfigValue("${sectionName}_ratio");
127+
}
128+
129+
return [
130+
'data-pp-style-layout' => $styleLayout,
131+
'data-pp-style-logo-type' => $logoType,
132+
'data-pp-style-logo-position' => $logoPosition,
133+
'data-pp-style-text-color' => $textColor,
134+
'data-pp-style-text-size' => $textSize,
135+
'data-pp-style-color' => $color,
136+
'data-pp-style-ratio' => $ratio
137+
];
138+
}
139+
138140
/**
139141
* Check if billing agreement is enabled
140142
*

app/code/Magento/Paypal/etc/adminhtml/system.xml

Lines changed: 8 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,7 @@
185185
<group id="wpp_advertise_bml" showInDefault="0" showInWebsite="0"/>
186186
</group>
187187
</group>
188-
<group id="payments_pro_hosted_solution_with_express_checkout" extends="payment_all_paypal/payments_pro_hosted_solution_with_express_checkout">
189-
<group id="pphs_required_settings">
190-
<group id="pphs_advertise_paylater">
191-
<field id="paylater_enabled" translate="label comment">
192-
<comment>
193-
<![CDATA[Display pay later messaging on your site for offers like Pay in 3, which
194-
lets customers pay with 3 interest- free monthly payments. We’ll show messages on
195-
your site to promote this feature for you. You may not promote pay later offers
196-
with any other content, marketing, or materials.]]>
197-
</comment>
198-
</field>
199-
</group>
200-
</group>
201-
</group>
188+
<include path="Magento_Paypal::system/payments_pro_hosted_solution_with_express_checkout.xml"/>
202189
<group id="wps_express" translate="label comment" extends="payment_all_paypal/express_checkout" sortOrder="50">
203190
<label>Website Payments Standard</label>
204191
<comment>Accept credit card and PayPal payments securely.</comment>
@@ -217,17 +204,9 @@
217204
</field>
218205
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
219206
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
207+
<field id="enable_paypal_paylater_experience" showInDefault="0" showInWebsite="0"/>
220208
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
221-
<group id="advertise_paylater">
222-
<field id="paylater_enabled" translate="label comment">
223-
<comment>
224-
<![CDATA[Display pay later messaging on your site for offers like Pay in 3,
225-
which lets customers pay with 3 interest- free monthly payments. We’ll show messages
226-
on your site to promote this feature for you. You may not promote pay later offers
227-
with any other content, marketing, or materials.]]>
228-
</comment>
229-
</field>
230-
</group>
209+
<group id="advertise_paylater" showInDefault="0" showInWebsite="0"/>
231210
</group>
232211
<group id="settings_ec" translate="label">
233212
<label>Basic Settings - PayPal Website Payments Standard</label>
@@ -380,13 +359,8 @@
380359
</group>
381360
</group>
382361
<group id="paypal_group_all_in_one">
383-
<group id="wps_other" sortOrder="12">
384-
<group id="express_checkout_required">
385-
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
386-
<group id="advertise_paylater" showInDefault="1" showInWebsite="1"/>
387-
</group>
388-
</group>
389-
<group id="payments_pro_hosted_solution_au" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml" sortOrder="10"/>
362+
<group id="wps_other" sortOrder="12"/>
363+
<group id="payments_pro_hosted_solution_au" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml_and_paylater" sortOrder="10"/>
390364
</group>
391365
<group id="paypal_payment_gateways" showInDefault="1" showInWebsite="1" showInStore="1">
392366
<group id="paypal_payflowpro_au" extends="payment_all_paypal/paypal_payflowpro" sortOrder="20"/>
@@ -424,48 +398,9 @@
424398
</group>
425399
</group>
426400
<group id="paypal_group_all_in_one">
427-
<group id="wps_other" sortOrder="12">
428-
<group id="express_checkout_required">
429-
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
430-
<group id="advertise_paylater" showInDefault="1" showInWebsite="1">
431-
<field id="paylater_enabled">
432-
<comment>
433-
<![CDATA[Affichez le Paiement en 4X PayPal sur votre site. Le Paiement en 4X PayPal
434-
permet aux consommateurs français de payer en 4 versements égaux. Vous pouvez
435-
promouvoir le Paiement en 4X PayPal uniquement si vous êtes un commerçant basé en
436-
France, avec un site internet en français et une intégration PayPal standard. Les
437-
marchands ayant l’outil Vaulting (coffre-fort numérique) ou une intégration de
438-
paiements récurrents/abonnement, ainsi que ceux présentant certaines activités
439-
(vente de biens numériques / de biens non physiques) ne sont pas éligibles pour
440-
promouvoir le Paiement en 4X PayPal. Nous afficherons des messages sur votre site
441-
pour promouvoir le Paiement en 4X PayPal. Vous ne pouvez pas promouvoir le Paiement
442-
en 4X PayPal avec un autre contenu, quel qu’il soit.]]>
443-
</comment>
444-
</field>
445-
</group>
446-
</group>
447-
</group>
448-
<group id="payments_pro_hosted_solution_fr" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml" sortOrder="10">
401+
<group id="wps_other" sortOrder="12"/>
402+
<group id="payments_pro_hosted_solution_fr" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml_and_paylater" sortOrder="10">
449403
<label>Integral Evolution</label>
450-
<group id="pphs_required_settings">
451-
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
452-
<group id="pphs_advertise_paylater">
453-
<field id="paylater_enabled">
454-
<comment>
455-
<![CDATA[Affichez le Paiement en 4X PayPal sur votre site. Le Paiement en 4X PayPal
456-
permet aux consommateurs français de payer en 4 versements égaux. Vous pouvez
457-
promouvoir le Paiement en 4X PayPal uniquement si vous êtes un commerçant basé en
458-
France, avec un site internet en français et une intégration PayPal standard. Les
459-
marchands ayant l’outil Vaulting (coffre-fort numérique) ou une intégration de
460-
paiements récurrents/abonnement, ainsi que ceux présentant certaines activités
461-
(vente de biens numériques / de biens non physiques) ne sont pas éligibles pour
462-
promouvoir le Paiement en 4X PayPal. Nous afficherons des messages sur votre site
463-
pour promouvoir le Paiement en 4X PayPal. Vous ne pouvez pas promouvoir le Paiement
464-
en 4X PayPal avec un autre contenu, quel qu’il soit.]]>
465-
</comment>
466-
</field>
467-
</group>
468-
</group>
469404
</group>
470405
</group>
471406
</section>
@@ -500,12 +435,7 @@
500435
<group id="wps_other"/>
501436
</group>
502437
<group id="paypal_payment_gateways" showInDefault="1" showInWebsite="1" showInStore="1">
503-
<group id="paypal_payflowpro_nz" extends="payment_all_paypal/paypal_payflowpro">
504-
<group id="paypal_payflow_required">
505-
<field id="enable_paypal_paylater_experience" showInDefault="0" showInWebsite="0"/>
506-
<group id="paypal_payflow_advertise_paylater" showInDefault="0" showInWebsite="0"/>
507-
</group>
508-
</group>
438+
<group id="paypal_payflowpro_nz" extends="payment_all_paypal/paypal_payflowpro"/>
509439
</group>
510440
</section>
511441
</system>

app/code/Magento/Paypal/etc/adminhtml/system/payments_pro_hosted_solution_with_express_checkout.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
9-
<group id="payments_pro_hosted_solution_with_express_checkout" translate="label comment" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml" sortOrder="30">
9+
<group id="payments_pro_hosted_solution_with_express_checkout" translate="label comment" extends="payment_all_paypal/payments_pro_hosted_solution_without_bml_and_paylater" sortOrder="30">
1010
<label>Website Payments Pro Hosted Solution</label>
1111
<attribute type="paypal_ec_separate">0</attribute>
1212
<group id="pphs_required_settings">

0 commit comments

Comments
 (0)