Skip to content

Commit d709e73

Browse files
Merge branch '1.1-develop' into MC-18071
2 parents 890cef9 + a80fe04 commit d709e73

File tree

104 files changed

+2462
-1263
lines changed

Some content is hidden

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

104 files changed

+2462
-1263
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Controller\Adminhtml\Stage;
10+
11+
use Magento\Framework\Controller\ResultFactory;
12+
use Magento\Framework\App\Action\HttpPostActionInterface;
13+
14+
/**
15+
* Preview controller to render blocks preview on Stage
16+
*/
17+
class Preview extends \Magento\Backend\App\Action implements HttpPostActionInterface
18+
{
19+
const ADMIN_RESOURCE = 'Magento_Backend::content';
20+
21+
/**
22+
* @var \Magento\PageBuilder\Model\Stage\RendererPool
23+
*/
24+
private $rendererPool;
25+
26+
/**
27+
* @var \Magento\PageBuilder\Model\Stage\Preview
28+
*/
29+
private $preview;
30+
31+
/**
32+
* @param \Magento\Backend\App\Action\Context $context
33+
* @param \Magento\PageBuilder\Model\Stage\RendererPool $rendererPool
34+
* @param \Magento\PageBuilder\Model\Stage\Preview $preview
35+
*/
36+
public function __construct(
37+
\Magento\Backend\App\Action\Context $context,
38+
\Magento\PageBuilder\Model\Stage\RendererPool $rendererPool,
39+
\Magento\PageBuilder\Model\Stage\Preview $preview
40+
) {
41+
parent::__construct($context);
42+
43+
$this->rendererPool = $rendererPool;
44+
$this->preview = $preview;
45+
}
46+
47+
/**
48+
* Generates an HTML preview for the stage
49+
*
50+
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|mixed
51+
* @throws \Exception
52+
*/
53+
public function execute()
54+
{
55+
return $this->preview->startPreviewMode(
56+
function () {
57+
$pageResult = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
58+
// Some template filters and directive processors expect this to be called in order to function.
59+
$pageResult->initLayout();
60+
61+
$params = $this->getRequest()->getParams();
62+
$renderer = $this->rendererPool->getRenderer($params['role']);
63+
$result = ['data' => $renderer->render($params)];
64+
65+
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);
66+
}
67+
);
68+
}
69+
}

app/code/Magento/PageBuilder/Controller/ContentType/Preview.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* This isn't placed within the adminhtml folder as it has to extend from the front-end controllers app action to
1818
* ensure the content is rendered in the storefront scope.
1919
*
20+
* @deprecated use \Magento\PageBuilder\Controller\Adminhtml\Stage\Preview
21+
*
2022
* @api
2123
*/
2224
class Preview extends \Magento\Framework\App\Action\Action implements HttpPostActionInterface

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class SimpleOption implements OptionInterface
2525
*/
2626
private $sortDirection;
2727

28+
/**
29+
* @var string
30+
*/
31+
private $secondarySortDirection;
32+
2833
/**
2934
* @var string
3035
*/
@@ -34,15 +39,18 @@ class SimpleOption implements OptionInterface
3439
* @param string $label
3540
* @param string $sortDirection
3641
* @param string $attributeField
42+
* @param string|null $secondarySortDirection
3743
*/
3844
public function __construct(
3945
string $label,
4046
string $sortDirection,
41-
string $attributeField
47+
string $attributeField,
48+
string $secondarySortDirection = null
4249
) {
4350
$this->label = $label;
4451
$this->sortDirection = $sortDirection;
4552
$this->attributeField = $attributeField;
53+
$this->secondarySortDirection = $secondarySortDirection ?? $sortDirection;
4654
}
4755

4856
/**
@@ -53,7 +61,7 @@ public function sort(
5361
): \Magento\Catalog\Model\ResourceModel\Product\Collection {
5462
$collection->getSelect()->reset(Select::ORDER);
5563
$collection->addAttributeToSort($this->attributeField, $this->sortDirection);
56-
$collection->addAttributeToSort('entity_id', $this->sortDirection);
64+
$collection->addAttributeToSort('entity_id', $this->secondarySortDirection);
5765

5866
return $collection;
5967
}

0 commit comments

Comments
 (0)