Skip to content

Commit 8313e94

Browse files
committed
Merge remote-tracking branch 'remotes/mainline-bluefoot/develop' into team3-delivery-bug-fixes
2 parents 55fdb57 + 7a87ac6 commit 8313e94

File tree

47 files changed

+1179
-671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1179
-671
lines changed

app/code/Magento/PageBuilder/Block/Adminhtml/ContentType/Products/Conditions.php renamed to app/code/Magento/PageBuilder/Block/Adminhtml/Form/Element/ProductConditions.php

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Block\Adminhtml\ContentType\Products;
9+
namespace Magento\PageBuilder\Block\Adminhtml\Form\Element;
1010

1111
use Magento\Backend\Block\Template;
1212

1313
/**
1414
* The block used to render the conditions rule tree form within the PageBuilder interface.
1515
*/
16-
class Conditions extends Template
16+
class ProductConditions extends Template
1717
{
1818
/**
1919
*
2020
* @var string
2121
*/
22-
protected $_template = 'Magento_PageBuilder::content_type/products/conditions.phtml';
22+
protected $_template = 'Magento_PageBuilder::form/element/conditions.phtml';
2323

2424
/**
2525
* @var \Magento\Framework\Serialize\Serializer\Json
@@ -41,42 +41,47 @@ public function __construct(
4141
parent::__construct($context, $data);
4242
}
4343

44-
/**
45-
* Returns the form namespace to be used with the JS config
46-
*
47-
* @return string
48-
*/
49-
public function getFormNamespace(): string
50-
{
51-
return 'pagebuilder_products_form';
52-
}
53-
5444
/**
5545
* Returns an array of arguments to pass to the condition tree UIComponent
5646
*
5747
* @return array
5848
*/
5949
private function getConfig(): array
6050
{
51+
$formNamespace = $this->getData('formNamespace');
52+
$attribute = $this->getData('attribute');
53+
6154
return [
62-
'formNamespace' => $this->getFormNamespace(),
55+
'formNamespace' => $formNamespace,
6356
'componentUrl' => $this->getUrl(
64-
'pagebuilder/contenttype/products_conditions',
65-
['form_namespace' => $this->getFormNamespace()]
57+
'pagebuilder/form/element_productconditions',
58+
[
59+
'form_namespace' => $formNamespace,
60+
'prefix' => $attribute,
61+
]
6662
),
67-
'jsObjectName' => $this->getFormNamespace(),
63+
'jsObjectName' => $formNamespace . '_' . $attribute,
6864
'childComponentUrl' => $this->getUrl(
69-
'pagebuilder/contenttype/products_conditions_child',
70-
['form_namespace' => $this->getFormNamespace()]
65+
'pagebuilder/form/element_productconditions_child',
66+
[
67+
'form_namespace' => $formNamespace,
68+
'prefix' => $attribute,
69+
]
7170
),
71+
'attribute' => $attribute,
7272
];
7373
}
7474

75+
/**
76+
* Creates a JSON string containing the configuration for the needed JS components in the mage-init format
77+
*
78+
* @return string
79+
*/
7580
public function getConfigJson(): string
7681
{
7782
return $this->serializer->serialize([
78-
'[data-role=pagebuilder-product-conditions-form-placeholder]' => [
79-
'Magento_PageBuilder/js/content-type/products/conditions-loader' => $this->getConfig(),
83+
'[data-role=pagebuilder-conditions-form-placeholder-' . $this->getData('attribute') . ']' => [
84+
'Magento_PageBuilder/js/form/element/conditions-loader' => $this->getConfig(),
8085
]
8186
]);
8287
}

app/code/Magento/PageBuilder/Controller/Adminhtml/ContentType/Products/Conditions.php renamed to app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductConditions.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Controller\Adminhtml\ContentType\Products;
9+
namespace Magento\PageBuilder\Controller\Adminhtml\Form\Element;
1010

1111
use Magento\Rule\Model\Condition\Combine;
1212

1313
/**
1414
* Responsible for rendering the top-level conditions rule tree using the provided params
1515
*/
16-
class Conditions extends \Magento\CatalogWidget\Controller\Adminhtml\Product\Widget
16+
class ProductConditions extends \Magento\CatalogWidget\Controller\Adminhtml\Product\Widget
1717
{
1818
/**
1919
* @var \Magento\CatalogWidget\Model\Rule
@@ -45,9 +45,13 @@ public function __construct(
4545
*/
4646
public function execute()
4747
{
48-
$conditions = $this->getRequest()->getParam('conditions');
49-
$this->rule->loadPost(['conditions'=> $this->serializer->unserialize($conditions)]);
48+
$prefix = $this->getRequest()->getParam('prefix', 'conditions');
49+
$conditionsEncoded = $this->getRequest()->getParam('conditions');
5050
$conditions = $this->rule->getConditions();
51+
$conditions->setData('prefix', $prefix);
52+
// The rule class expects something to be set in the prefix field before the conditions are loaded
53+
$conditions->setData($prefix, []);
54+
$this->rule->loadPost(['conditions' => $this->serializer->unserialize($conditionsEncoded)]);
5155
$formName = $this->getRequest()->getParam('form_namespace');
5256
// Combine class recursively sets jsFormObject so we don't need to
5357
$conditions->setJsFormObject($formName);

app/code/Magento/PageBuilder/Controller/Adminhtml/ContentType/Products/Conditions/Child.php renamed to app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductConditions/Child.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66

77
declare(strict_types=1);
88

9-
namespace Magento\PageBuilder\Controller\Adminhtml\ContentType\Products\Conditions;
9+
namespace Magento\PageBuilder\Controller\Adminhtml\Form\Element\ProductConditions;
1010

1111
use Magento\Rule\Model\Condition\AbstractCondition;
12-
use Magento\Rule\Model\Condition\Combine;
1312

1413
/**
1514
* Responsible for rendering the child elements of the conditions rule tree using the provided params
@@ -19,7 +18,7 @@ class Child extends \Magento\CatalogWidget\Controller\Adminhtml\Product\Widget
1918
/**
2019
* @var \Magento\CatalogWidget\Model\Rule
2120
*/
22-
protected $rule;
21+
private $rule;
2322

2423
/**
2524
* @param \Magento\Backend\App\Action\Context $context
@@ -48,7 +47,7 @@ public function execute()
4847
->setId($id)
4948
->setType($className)
5049
->setRule($this->rule)
51-
->setPrefix('conditions');
50+
->setPrefix($this->getRequest()->getParam('prefix', 'conditions'));
5251

5352
if (!empty($typeData[1])) {
5453
$model->setAttribute($typeData[1]);

app/code/Magento/PageBuilder/Setup/DataConverter/Renderer/Product.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ public function render(array $itemData, array $additionalData = [])
134134
'data-role' => 'product',
135135
'data-appearance' => 'grid',
136136
'class' => $eavData['css_classes'] ?? '',
137-
'data-products-count' => $productsCount,
138-
'data-conditions-encoded' => $this->escaper->escapeHtml($this->jsonEncoder->serialize($conditions)),
139-
'data-sku' => $productSku
140137
];
141138

142139
if (isset($itemData['formData'])) {

app/code/Magento/PageBuilder/Setup/DataConverter/Renderer/ProductList.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ public function render(array $itemData, array $additionalData = [])
105105
'data-role' => 'products',
106106
'data-appearance' => 'grid',
107107
'class' => $itemData['formData']['css_classes'] ?? '',
108-
'data-products-count' => $productsCount,
109-
'data-conditions-encoded' => $this->escaper->escapeHtml($this->jsonEncoder->serialize($conditions))
110108
];
111109

112110
if (isset($itemData['formData'])) {

app/code/Magento/PageBuilder/Test/Mftf/Section/PageBuilderProductsSection.xml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="ProductsOnStage">
12-
<element name="base" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}]" parameterized="true"/>
13-
<element name="product" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}]//ol//li[contains(@class,'product-item')]" parameterized="true"/>
14-
<element name="productImage" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count]//ol//li[contains(@class,'product-item')])[{{arg1}}]//img[@class='product-image-photo']" parameterized="true"/>
15-
<element name="productName" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count]//ol//li[contains(@class,'product-item')])[{{arg1}}]//strong//a[@class='product-item-link' and @href and contains(.,'{{arg2}}')]" parameterized="true"/>
16-
<element name="productPrice" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count]//ol//li[contains(@class,'product-item')])[{{arg1}}]//span[@class='price' and .='${{arg2}}']" parameterized="true"/>
17-
<element name="productAddToCart" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count]//ol//li[contains(@class,'product-item')])[{{arg1}}]//button[contains(@class,'tocart') and @title='Add to Cart']" parameterized="true"/>
18-
<element name="productAddToWishList" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count]//ol//li[contains(@class,'product-item')])[{{arg1}}]//a[contains(@class,'towishlist') and @title='Add to Wish List']" parameterized="true"/>
19-
<element name="productAddToCompare" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count]//ol//li[contains(@class,'product-item')])[{{arg1}}]//a[contains(@class,'tocompare') and @title='Add to Compare']" parameterized="true"/>
12+
<element name="base" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}]" parameterized="true"/>
13+
<element name="product" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}]//ol//li[contains(@class,'product-item')]" parameterized="true"/>
14+
<element name="productImage" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')]//ol//li[contains(@class,'product-item')])[{{arg1}}]//img[@class='product-image-photo']" parameterized="true"/>
15+
<element name="productName" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')]//ol//li[contains(@class,'product-item')])[{{arg1}}]//strong//a[@class='product-item-link' and @href and contains(.,'{{arg2}}')]" parameterized="true"/>
16+
<element name="productPrice" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')]//ol//li[contains(@class,'product-item')])[{{arg1}}]//span[@class='price' and .='${{arg2}}']" parameterized="true"/>
17+
<element name="productAddToCart" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')]//ol//li[contains(@class,'product-item')])[{{arg1}}]//button[contains(@class,'tocart') and @title='Add to Cart']" parameterized="true"/>
18+
<element name="productAddToWishList" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')]//ol//li[contains(@class,'product-item')])[{{arg1}}]//a[contains(@class,'towishlist') and @title='Add to Wish List']" parameterized="true"/>
19+
<element name="productAddToCompare" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')]//ol//li[contains(@class,'product-item')])[{{arg1}}]//a[contains(@class,'tocompare') and @title='Add to Compare']" parameterized="true"/>
2020
<!-- Advanced Configuration -->
21-
<element name="alignment" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][contains(@style,'text-align: {{arg2}};')]" parameterized="true"/>
22-
<element name="noAlignment" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][not(contains(@style,'text-align:'))]" parameterized="true"/>
23-
<element name="border" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][contains(@style,'border-style: {{arg2}};')]" parameterized="true"/>
24-
<element name="borderColor" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][contains(@style,'border-color: {{arg2}};')]" parameterized="true"/>
25-
<element name="noBorderColor" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][not(contains(@style,'border-color:'))]" parameterized="true"/>
26-
<element name="borderWidth" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][contains(@style,'border-width: {{arg2}}px;')]" parameterized="true"/>
27-
<element name="borderRadius" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][contains(@style,'border-radius: {{arg2}}px;')]" parameterized="true"/>
28-
<element name="cssClasses" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][contains(@class,'{{arg2}}')]" parameterized="true"/>
29-
<element name="noCssClasses" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][not(@class)]" parameterized="true"/>
30-
<element name="margins" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][contains(@style,'margin: {{arg2}}px;')]" parameterized="true"/>
31-
<element name="padding" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[@data-products-count])[{{arg1}}][contains(@style,'padding: {{arg2}}px;')]" parameterized="true"/>
21+
<element name="alignment" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][contains(@style,'text-align: {{arg2}};')]" parameterized="true"/>
22+
<element name="noAlignment" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][not(contains(@style,'text-align:'))]" parameterized="true"/>
23+
<element name="border" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][contains(@style,'border-style: {{arg2}};')]" parameterized="true"/>
24+
<element name="borderColor" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][contains(@style,'border-color: {{arg2}};')]" parameterized="true"/>
25+
<element name="noBorderColor" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][not(contains(@style,'border-color:'))]" parameterized="true"/>
26+
<element name="borderWidth" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][contains(@style,'border-width: {{arg2}}px;')]" parameterized="true"/>
27+
<element name="borderRadius" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][contains(@style,'border-radius: {{arg2}}px;')]" parameterized="true"/>
28+
<element name="cssClasses" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][contains(@class,'{{arg2}}')]" parameterized="true"/>
29+
<element name="noCssClasses" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][not(@class)]" parameterized="true"/>
30+
<element name="margins" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][contains(@style,'margin: {{arg2}}px;')]" parameterized="true"/>
31+
<element name="padding" type="text" selector="(//div[contains(@class,'pagebuilder-products')]//div[contains(@data-appearance,'grid')])[{{arg1}}][contains(@style,'padding: {{arg2}}px;')]" parameterized="true"/>
3232
</section>
3333
<section name="ProductsContentTypeForm">
3434
<element name="conditionsList" type="text" selector=".rule-param-children"/>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<testCaseId value="MAGETWO-90008"/>
2020
<group value="pagebuilder"/>
2121
<group value="pagebuilder-tabs"/>
22+
<!--Skipped due to MAGETWO-92406-->
23+
<group value="skip"/>
2224
</annotations>
2325
<before>
2426
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>

0 commit comments

Comments
 (0)