Skip to content

Commit 2dfe31a

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop Minor Fixes
Accepted Public Pull Requests: - #22054: fix strpos args order (by @quasilyte) - #21966: Remove timestap from current date when saving product special price from date (by @JeroenVanLeusden) - #21948: Fixed WhiteSpace issue in product grid (by @shrinet) - #21928: Set minimum qty 1 after cast to int (by @likemusic) - #19987: Fix broken widget placeholders after upgrading from 2.2 (by @vovayatsyuk) - #18933: Update typeReferenceBlock definition (by @leandrommedeiros) - #21647: MFTF / Remove redundant ActionGroups (by @lbajsarowicz) - #21818: Remove all marketing get params on Varnish to minimize the cache objects (by @ihor-sviziev) - #21754: Fixes nested array for used products cache key (by @michaellehmkuhl) - #21545: Ensure `__toString()` catches all error types (by @tylerssn) - #21008: [Widget] Fixing the multidimensional array as value for the widget's parameter (by @eduard13) - #18440: [2.3] Reworked gallery.phtml to move generation of gallery json strings to own block functions (by @gwharton) Fixed GitHub Issues: - #20140: Product per row not proper on listing page (reported by @dipti2jcommerce) has been fixed in #21948 by @shrinet in 2.3-develop branch Related commits: 1. 120a8c0 - #21244: Luma theme huge whitespace on category grid (reported by @Zyles) has been fixed in #21948 by @shrinet in 2.3-develop branch Related commits: 1. 120a8c0 - #21926: Exception on reorder from admin (reported by @likemusic) has been fixed in #21928 by @likemusic in 2.3-develop branch Related commits: 1. d073b0c 2. b82503a - #19909: Not possible to use multidimensional arrays in widget parameters (reported by @ilnytskyi) has been fixed in #21008 by @eduard13 in 2.3-develop branch Related commits: 1. fa22418 2. f353926 3. 7eb567e 4. 718bb76
2 parents 5791131 + 9437111 commit 2dfe31a

File tree

23 files changed

+451
-139
lines changed

23 files changed

+451
-139
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Block\Product\View;
7+
8+
use Magento\Framework\View\Element\Block\ArgumentInterface;
9+
use Magento\Framework\Serialize\Serializer\Json;
10+
use Magento\Catalog\Block\Product\Context;
11+
use Magento\Framework\Stdlib\ArrayUtils;
12+
13+
/**
14+
* Gallery options block.
15+
*/
16+
class GalleryOptions extends AbstractView implements ArgumentInterface
17+
{
18+
/**
19+
* @var Json
20+
*/
21+
private $jsonSerializer;
22+
23+
/**
24+
* @var Gallery
25+
*/
26+
private $gallery;
27+
28+
/**
29+
* @param Context $context
30+
* @param ArrayUtils $arrayUtils
31+
* @param Json $jsonSerializer
32+
* @param Gallery $gallery
33+
* @param array $data
34+
*/
35+
public function __construct(
36+
Context $context,
37+
ArrayUtils $arrayUtils,
38+
Json $jsonSerializer,
39+
Gallery $gallery,
40+
array $data = []
41+
) {
42+
$this->gallery = $gallery;
43+
$this->jsonSerializer = $jsonSerializer;
44+
parent::__construct($context, $arrayUtils, $data);
45+
}
46+
47+
/**
48+
* Retrieve gallery options in JSON format
49+
*
50+
* @return string
51+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
52+
* @SuppressWarnings(PHPMD.NPathComplexity)
53+
* @SuppressWarnings(PHPMD.ElseExpression)
54+
*/
55+
public function getOptionsJson()
56+
{
57+
$optionItems = null;
58+
59+
//Special case for gallery/nav which can be the string "thumbs/false/dots"
60+
if (is_bool($this->getVar("gallery/nav"))) {
61+
$optionItems['nav'] = $this->getVar("gallery/nav") ? 'true' : 'false';
62+
} else {
63+
$optionItems['nav'] = $this->escapeHtml($this->getVar("gallery/nav"));
64+
}
65+
66+
$optionItems['loop'] = $this->getVar("gallery/loop");
67+
$optionItems['keyboard'] = $this->getVar("gallery/keyboard");
68+
$optionItems['arrows'] = $this->getVar("gallery/arrows");
69+
$optionItems['allowfullscreen'] = $this->getVar("gallery/allowfullscreen");
70+
$optionItems['showCaption'] = $this->getVar("gallery/caption");
71+
$optionItems['width'] = (int)$this->escapeHtml(
72+
$this->gallery->getImageAttribute('product_page_image_medium', 'width')
73+
);
74+
$optionItems['thumbwidth'] = (int)$this->escapeHtml(
75+
$this->gallery->getImageAttribute('product_page_image_small', 'width')
76+
);
77+
78+
if ($this->gallery->getImageAttribute('product_page_image_small', 'height') ||
79+
$this->gallery->getImageAttribute('product_page_image_small', 'width')) {
80+
$optionItems['thumbheight'] = (int)$this->escapeHtml(
81+
$this->gallery->getImageAttribute('product_page_image_small', 'height') ?:
82+
$this->gallery->getImageAttribute('product_page_image_small', 'width')
83+
);
84+
}
85+
86+
if ($this->gallery->getImageAttribute('product_page_image_medium', 'height') ||
87+
$this->gallery->getImageAttribute('product_page_image_medium', 'width')) {
88+
$optionItems['height'] = (int)$this->escapeHtml(
89+
$this->gallery->getImageAttribute('product_page_image_medium', 'height') ?:
90+
$this->gallery->getImageAttribute('product_page_image_medium', 'width')
91+
);
92+
}
93+
94+
if ($this->getVar("gallery/transition/duration")) {
95+
$optionItems['transitionduration'] =
96+
(int)$this->escapeHtml($this->getVar("gallery/transition/duration"));
97+
}
98+
99+
$optionItems['transition'] = $this->escapeHtml($this->getVar("gallery/transition/effect"));
100+
$optionItems['navarrows'] = $this->getVar("gallery/navarrows");
101+
$optionItems['navtype'] = $this->escapeHtml($this->getVar("gallery/navtype"));
102+
$optionItems['navdir'] = $this->escapeHtml($this->getVar("gallery/navdir"));
103+
104+
if ($this->getVar("gallery/thumbmargin")) {
105+
$optionItems['thumbmargin'] = (int)$this->escapeHtml($this->getVar("gallery/thumbmargin"));
106+
}
107+
108+
return $this->jsonSerializer->serialize($optionItems);
109+
}
110+
111+
/**
112+
* Retrieve gallery fullscreen options in JSON format
113+
*
114+
* @return string
115+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
116+
* @SuppressWarnings(PHPMD.NPathComplexity)
117+
* @SuppressWarnings(PHPMD.ElseExpression)
118+
*/
119+
public function getFSOptionsJson()
120+
{
121+
$fsOptionItems = null;
122+
123+
//Special case for gallery/nav which can be the string "thumbs/false/dots"
124+
if (is_bool($this->getVar("gallery/fullscreen/nav"))) {
125+
$fsOptionItems['nav'] = $this->getVar("gallery/fullscreen/nav") ? 'true' : 'false';
126+
} else {
127+
$fsOptionItems['nav'] = $this->escapeHtml($this->getVar("gallery/fullscreen/nav"));
128+
}
129+
130+
$fsOptionItems['loop'] = $this->getVar("gallery/fullscreen/loop");
131+
$fsOptionItems['navdir'] = $this->escapeHtml($this->getVar("gallery/fullscreen/navdir"));
132+
$fsOptionItems['navarrows'] = $this->getVar("gallery/fullscreen/navarrows");
133+
$fsOptionItems['navtype'] = $this->escapeHtml($this->getVar("gallery/fullscreen/navtype"));
134+
$fsOptionItems['arrows'] = $this->getVar("gallery/fullscreen/arrows");
135+
$fsOptionItems['showCaption'] = $this->getVar("gallery/fullscreen/caption");
136+
137+
if ($this->getVar("gallery/fullscreen/transition/duration")) {
138+
$fsOptionItems['transitionduration'] = (int)$this->escapeHtml(
139+
$this->getVar("gallery/fullscreen/transition/duration")
140+
);
141+
}
142+
143+
$fsOptionItems['transition'] = $this->escapeHtml($this->getVar("gallery/fullscreen/transition/effect"));
144+
145+
if ($this->getVar("gallery/fullscreen/keyboard")) {
146+
$fsOptionItems['keyboard'] = $this->getVar("gallery/fullscreen/keyboard");
147+
}
148+
149+
if ($this->getVar("gallery/fullscreen/thumbmargin")) {
150+
$fsOptionItems['thumbmargin'] =
151+
(int)$this->escapeHtml($this->getVar("gallery/fullscreen/thumbmargin"));
152+
}
153+
154+
return $this->jsonSerializer->serialize($fsOptionItems);
155+
}
156+
}

app/code/Magento/Catalog/Observer/SetSpecialPriceStartDate.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,33 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Observer;
79

810
use Magento\Framework\Event\ObserverInterface;
11+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
912

1013
/**
1114
* Set value for Special Price start date
1215
*/
1316
class SetSpecialPriceStartDate implements ObserverInterface
1417
{
1518
/**
16-
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
19+
* @var TimezoneInterface
1720
*/
1821
private $localeDate;
1922

2023
/**
21-
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
22-
* @codeCoverageIgnore
24+
* @param TimezoneInterface $localeDate
2325
*/
24-
public function __construct(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate)
26+
public function __construct(TimezoneInterface $localeDate)
2527
{
2628
$this->localeDate = $localeDate;
2729
}
2830

2931
/**
30-
* Set the current date to Special Price From attribute if it empty
32+
* Set the current date to Special Price From attribute if it's empty.
3133
*
3234
* @param \Magento\Framework\Event\Observer $observer
3335
* @return $this
@@ -36,8 +38,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
3638
{
3739
/** @var $product \Magento\Catalog\Model\Product */
3840
$product = $observer->getEvent()->getProduct();
39-
if ($product->getSpecialPrice() && !$product->getSpecialFromDate()) {
40-
$product->setData('special_from_date', $this->localeDate->date());
41+
if ($product->getSpecialPrice() && ! $product->getSpecialFromDate()) {
42+
$product->setData('special_from_date', $this->localeDate->date()->setTime(0, 0));
4143
}
4244

4345
return $this;

app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSet.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/>
3535

3636
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
37-
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$$createAttributeSet.attribute_set_id$$}}/" stepKey="onAttributeSetEdit"/>
37+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$$createAttributeSet.attribute_set_id$$/" stepKey="onAttributeSetEdit"/>
3838
<actionGroup ref="AssignAttributeToGroup" stepKey="assignAttributeToGroup">
3939
<argument name="group" value="Product Details"/>
4040
<argument name="attribute" value="$$createProductAttribute.attribute_code$$"/>

0 commit comments

Comments
 (0)