Skip to content

Commit f41f238

Browse files
authored
Merge pull request #364 from magento-obsessive-owls/PB-364-sync-release-to-develop
[Owls] Sync 1.2.0-release into develop
2 parents 2bd74eb + 9b75f27 commit f41f238

File tree

22 files changed

+485
-158
lines changed

22 files changed

+485
-158
lines changed

app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductTotals.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,12 @@ public function execute()
5454
$conditions = $this->getRequest()->getParam('conditionValue');
5555

5656
try {
57-
$totals = $this->productTotals->getProductTotals($conditions);
58-
$response = [
59-
'total' => $totals['total'],
60-
'disabled' => $totals['disabled'],
61-
'notVisible' => $totals['notVisible'],
62-
'outOfStock' => $totals['outOfStock'],
63-
];
57+
$response = $this->productTotals->getProductTotals($conditions);
6458
} catch (Exception $e) {
6559
$response = [
6660
'total' => 0,
6761
'disabled' => 0,
6862
'notVisible' => 0,
69-
'outOfStock' => 0,
7063
];
7164
}
7265

app/code/Magento/PageBuilder/Model/Catalog/ProductTotals.php

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Catalog\Model\Product\Visibility;
1313
use Magento\Catalog\Model\ResourceModel\Product\Collection;
1414
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
15-
use Magento\CatalogInventory\Helper\Stock;
1615
use Magento\CatalogWidget\Model\Rule;
1716
use Magento\Framework\Exception\LocalizedException;
1817
use Magento\Rule\Model\Condition\Combine;
@@ -45,30 +44,22 @@ class ProductTotals
4544
*/
4645
private $conditionsHelper;
4746

48-
/**
49-
* @var Stock
50-
*/
51-
private $stockFilter;
52-
5347
/**
5448
* @param CollectionFactory $productCollectionFactory
5549
* @param Builder $sqlBuilder
5650
* @param Rule $rule
5751
* @param Conditions $conditionsHelper
58-
* @param Stock $stockFilter
5952
*/
6053
public function __construct(
6154
CollectionFactory $productCollectionFactory,
6255
Builder $sqlBuilder,
6356
Rule $rule,
64-
Conditions $conditionsHelper,
65-
Stock $stockFilter
57+
Conditions $conditionsHelper
6658
) {
6759
$this->productCollectionFactory = $productCollectionFactory;
6860
$this->sqlBuilder = $sqlBuilder;
6961
$this->rule = $rule;
7062
$this->conditionsHelper = $conditionsHelper;
71-
$this->stockFilter = $stockFilter;
7263
}
7364

7465
/**
@@ -155,34 +146,6 @@ private function getNotVisibleCount(Collection $baseCollection): int
155146
return $notVisibleCollection->getSize();
156147
}
157148

158-
/**
159-
* Retrieve count of all out of stock products
160-
*
161-
* @param Collection $baseCollection
162-
* @return int number of out of stock products
163-
* @throws Zend_Db_Select_Exception
164-
*/
165-
private function getOutOfStockCount(Collection $baseCollection): int
166-
{
167-
// Retrieve in stock products, then subtract them from the total
168-
$outOfStockCollection = clone $baseCollection;
169-
$this->stockFilter->addIsInStockFilterToCollection($outOfStockCollection);
170-
// Remove existing stock_status where condition from query
171-
$outOfStockWhere = $outOfStockCollection->getSelect()->getPart('where');
172-
$outOfStockWhere = array_filter(
173-
$outOfStockWhere,
174-
function ($whereCondition) {
175-
return !stristr($whereCondition, 'stock_status');
176-
}
177-
);
178-
$outOfStockCollection->getSelect()->setPart('where', $outOfStockWhere);
179-
$outOfStockCollection->getSelect()->where(
180-
'stock_status_index.stock_status = ?',
181-
\Magento\CatalogInventory\Model\Stock\Status::STATUS_OUT_OF_STOCK
182-
);
183-
return $outOfStockCollection->getSize();
184-
}
185-
186149
/**
187150
* Retrieve product totals for collection
188151
*
@@ -209,13 +172,11 @@ public function getProductTotals(string $conditions): array
209172

210173
$disabledCount = $this->getDisabledCount($collection);
211174
$notVisibleCount = $this->getNotVisibleCount($collection);
212-
$outOfStockCount = $this->getOutOfStockCount($collection);
213175

214176
return [
215177
'total' => $collection->getSize(),
216178
'disabled' => $disabledCount,
217179
'notVisible' => $notVisibleCount,
218-
'outOfStock' => $outOfStockCount,
219180
];
220181
}
221182
}

app/code/Magento/PageBuilder/Model/Catalog/Sorting.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ public function getSortingOptions(): array
6262
* Get the instance of the first option which is None
6363
*
6464
* @param string $sortOption
65-
* @return Sorting\OptionInterface
65+
* @return Sorting\OptionInterface|null
6666
*/
67-
public function getSortingInstance($sortOption): Sorting\OptionInterface
67+
public function getSortingInstance($sortOption): ?Sorting\OptionInterface
6868
{
6969
if (isset($this->sortInstances[$sortOption])) {
7070
return $this->sortInstances[$sortOption];
7171
}
72+
73+
return null;
7274
}
7375

7476
/**
@@ -83,12 +85,14 @@ public function applySorting(
8385
\Magento\Catalog\Model\ResourceModel\Product\Collection $collection
8486
): \Magento\Catalog\Model\ResourceModel\Product\Collection {
8587
$sortBuilder = $this->getSortingInstance($option);
86-
$_collection = $sortBuilder->sort($collection);
88+
if ($sortBuilder) {
89+
$collection = $sortBuilder->sort($collection);
90+
}
8791

88-
if ($_collection->isLoaded()) {
89-
$_collection->clear();
92+
if ($collection->isLoaded()) {
93+
$collection->clear();
9094
}
9195

92-
return $_collection;
96+
return $collection;
9397
}
9498
}

app/code/Magento/PageBuilder/Model/Filter/Template.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ public function filter(string $result) : string
9191
if (!empty($matches)) {
9292
$docHtml = $matches[1];
9393

94+
// restore any encoded directives
95+
$docHtml = preg_replace_callback(
96+
'/=\"(%7B%7B[^"]*%7D%7D)\"/m',
97+
function ($matches) {
98+
return urldecode($matches[0]);
99+
},
100+
$docHtml
101+
);
102+
94103
if (isset($uniqueNodeNameToDecodedOuterHtmlMap)) {
95104
foreach ($uniqueNodeNameToDecodedOuterHtmlMap as $uniqueNodeName => $decodedOuterHtml) {
96105
$docHtml = str_replace(

app/code/Magento/PageBuilder/Model/Stage/HtmlFilter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ public function __construct(
4040
*/
4141
public function filterHtml(string $content): string
4242
{
43-
$dom = new \DOMDocument();
43+
$dom = new \DOMDocument('1.0', 'UTF-8');
4444
try {
4545
//this code is required because of https://bugs.php.net/bug.php?id=60021
4646
$previous = libxml_use_internal_errors(true);
47-
$dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
47+
$string = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
48+
$dom->loadHTML($string, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
4849
} catch (\Exception $e) {
4950
$this->loggerInterface->critical($e->getMessage());
5051
}

app/code/Magento/PageBuilder/Model/Wysiwyg/DefaultConfigProvider.php

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,41 +39,43 @@ public function __construct(
3939
*/
4040
public function getConfig(\Magento\Framework\DataObject $config): \Magento\Framework\DataObject
4141
{
42-
$config->addData([
43-
'tinymce4' => [
44-
'toolbar' => 'undo redo | styleselect | fontsizeselect | lineheightselect | forecolor backcolor ' .
45-
'| bold italic underline | alignleft aligncenter alignright | numlist bullist ' .
46-
'| link image table charmap',
42+
$config->addData(
43+
[
44+
'tinymce4' => [
45+
'toolbar' => 'undo redo | styleselect | fontsizeselect | lineheightselect | forecolor backcolor ' .
46+
'| bold italic underline | alignleft aligncenter alignright | numlist bullist ' .
47+
'| link image table charmap',
4748

48-
'plugins' => implode(
49-
' ',
50-
[
51-
'advlist',
52-
'autolink',
53-
'lists',
54-
'link',
55-
'charmap',
56-
'media',
57-
'noneditable',
58-
'table',
59-
'contextmenu',
60-
'paste',
61-
'code',
62-
'help',
63-
'table',
64-
'textcolor',
65-
'image',
66-
'colorpicker',
67-
'lineheight'
49+
'plugins' => implode(
50+
' ',
51+
[
52+
'advlist',
53+
'autolink',
54+
'lists',
55+
'link',
56+
'charmap',
57+
'media',
58+
'noneditable',
59+
'table',
60+
'contextmenu',
61+
'paste',
62+
'code',
63+
'help',
64+
'table',
65+
'textcolor',
66+
'image',
67+
'colorpicker',
68+
'lineheight'
69+
]
70+
),
71+
'content_css' => [
72+
$this->assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/ui.css'),
73+
$this->assetRepo->getUrl('Magento_PageBuilder::css/source/form/element/tinymce.css')
6874
]
69-
),
70-
'content_css' => [
71-
$this->assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/ui.css'),
72-
$this->assetRepo->getUrl('Magento_PageBuilder/css/source/form/element/tinymce.css')
73-
]
74-
],
75-
'settings' => $this->additionalSettings
76-
]);
75+
],
76+
'settings' => $this->additionalSettings
77+
]
78+
);
7779
return $config;
7880
}
7981
}

app/code/Magento/PageBuilder/Plugin/Filter/TemplatePlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
class TemplatePlugin
1414
{
15-
const BACKGROUND_IMAGE_PATTERN = '/data-background-images/si';
15+
const BACKGROUND_IMAGE_PATTERN = '/data-background-images=(?:\'|"){.+}(?:\'|")/si';
1616

1717
const HTML_CONTENT_TYPE_PATTERN = '/data-content-type="html"/si';
1818

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderProductsCommonTests.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,7 +1175,7 @@
11751175
<argument name="category" value="$$createCategory1.name$$"/>
11761176
</actionGroup>
11771177
<actionGroup ref="validateProductTotals" stepKey="validateTotalProductsOnEditPanelAgain1">
1178-
<argument name="productsTotals" value="of 6 total (1 disabled, 1 not visible, 1 out of stock)"/>
1178+
<argument name="productsTotals" value="of 6 total (1 disabled, 1 not visible)"/>
11791179
</actionGroup>
11801180
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanel1"/>
11811181
<actionGroup ref="validateProductCountInProducts" stepKey="validateTotalProductsOnStage1">
@@ -1190,7 +1190,7 @@
11901190
<argument name="property" value="PageBuilderProductsProductCarouselAppearance"/>
11911191
</actionGroup>
11921192
<actionGroup ref="validateProductTotals" stepKey="validateTotalProductsOnEditPanel2">
1193-
<argument name="productsTotals" value="of 6 total (1 disabled, 1 not visible, 1 out of stock)"/>
1193+
<argument name="productsTotals" value="of 6 total (1 disabled, 1 not visible)"/>
11941194
</actionGroup>
11951195
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanel2"/>
11961196
<actionGroup ref="validateProductCountInProducts" stepKey="validateTotalProductsOnStage2">
@@ -1209,7 +1209,7 @@
12091209
<argument name="SKUs" value="$$createDisabledProduct.sku$$,$$createProduct1.sku$$,$$createOutOfStockProduct.sku$$,$$createNotVisibleProduct.sku$$"/>
12101210
</actionGroup>
12111211
<actionGroup ref="validateProductTotals" stepKey="validateTotalProductsOnEditPanelAgain3">
1212-
<argument name="productsTotals" value="of 4 total (1 disabled, 1 not visible, 1 out of stock)"/>
1212+
<argument name="productsTotals" value="of 4 total (1 disabled, 1 not visible)"/>
12131213
</actionGroup>
12141214
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanel3"/>
12151215
<actionGroup ref="validateProductCountInProducts" stepKey="validateTotalProductsOnStage3">
@@ -1224,7 +1224,7 @@
12241224
<argument name="property" value="PageBuilderProductsProductGridAppearance"/>
12251225
</actionGroup>
12261226
<actionGroup ref="validateProductTotals" stepKey="validateTotalProductsOnEditPanel4">
1227-
<argument name="productsTotals" value="of 4 total (1 disabled, 1 not visible, 1 out of stock)"/>
1227+
<argument name="productsTotals" value="of 4 total (1 disabled, 1 not visible)"/>
12281228
</actionGroup>
12291229
<actionGroup ref="saveEditPanelSettings" stepKey="saveEditPanel4"/>
12301230
<actionGroup ref="validateProductCountInProducts" stepKey="validateTotalProductsOnStage4">

0 commit comments

Comments
 (0)