Skip to content

Commit b63f781

Browse files
committed
Merge remote-tracking branch 'origin/1.1-develop' into PB-261
2 parents 9c0af96 + 94b3b0f commit b63f781

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
9+
<body>
10+
<referenceContainer name="category.view.container">
11+
<referenceBlock name="category.description" template="Magento_PageBuilder::catalog/category/view/description.phtml"/>
12+
</referenceContainer>
13+
</body>
14+
</page>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
<?php
8+
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
9+
10+
/**
11+
* Category view template
12+
*
13+
* @var $block \Magento\Catalog\Block\Category\View
14+
*/
15+
?>
16+
<?php if ($description = $block->getCurrentCategory()->getDescription()) :?>
17+
<div class="category-description">
18+
<?php $descriptionHtml = $this->helper(Magento\Catalog\Helper\Output::class)->categoryAttribute(
19+
$block->getCurrentCategory(),
20+
$description,
21+
'description'
22+
);?>
23+
<?php if (stripos($description, 'data-appearance="contained"') === false) :?>
24+
<div data-content-type="row" data-appearance="contained" data-element="main">
25+
<div data-enable-parallax="0" data-parallax-speed="0.5" data-background-images="{}" data-element="inner" style="justify-content: flex-start; display: flex; flex-direction: column; background-position: left top; background-size: cover; background-repeat: no-repeat; background-attachment: scroll; border-style: none; border-width: 1px; border-radius: 0px; margin: 0px 0px 10px; padding: 10px;">
26+
<div data-content-type="html" data-appearance="default" data-element="main" style="border-style: none; border-width: 1px; border-radius: 0px; margin: 0px; padding: 0px;">
27+
<?= /* @noEscape */$descriptionHtml; ?>
28+
</div>
29+
</div>
30+
</div>
31+
<?php else : ?>
32+
<?= /* @noEscape */$descriptionHtml; ?>
33+
<?php endif; ?>
34+
</div>
35+
<?php endif; ?>
36+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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\Block\Catalog\Category;
10+
11+
use Magento\Catalog\Api\CategoryRepositoryInterface;
12+
use Magento\Catalog\Block\Category\View;
13+
use Magento\Framework\Registry;
14+
use Magento\Framework\View\LayoutInterface;
15+
use Magento\TestFramework\Helper\Bootstrap;
16+
use Magento\Catalog\Api\Data\CategoryInterface;
17+
use Magento\Framework\ObjectManagerInterface;
18+
use PHPUnit\Framework\TestCase;
19+
20+
/**
21+
* @magentoAppArea frontend
22+
*/
23+
class ViewTest extends TestCase
24+
{
25+
/** @var ObjectManagerInterface */
26+
private $objectManager;
27+
28+
/** @var CategoryRepositoryInterface */
29+
private $categoryRepository;
30+
31+
/** @var View */
32+
private $block;
33+
34+
/** @var LayoutInterface */
35+
private $layout;
36+
37+
/** @var Registry */
38+
private $registry;
39+
40+
/**
41+
* @inheritdoc
42+
*/
43+
protected function setUp()
44+
{
45+
$this->objectManager = Bootstrap::getObjectManager();
46+
$this->categoryRepository = $this->objectManager->create(CategoryRepositoryInterface::class);
47+
$this->registry = $this->objectManager->get(Registry::class);
48+
$this->layout = $this->objectManager->get(LayoutInterface::class);
49+
}
50+
51+
/**
52+
* Check that PageBuilder category description block contents selector
53+
*
54+
* @return void
55+
* @magentoDataFixture Magento/Catalog/_files/category.php
56+
*/
57+
public function testDescription(): void
58+
{
59+
/** @var CategoryInterface $category */
60+
$category = $this->categoryRepository->get(333);
61+
$category->setDescription('This is the description for Category 333 without PageBuilder styles');
62+
$this->categoryRepository->save($category);
63+
$this->registerCategory($category);
64+
$this->block = $this->layout->createBlock(View::class);
65+
$this->block->setTemplate('Magento_PageBuilder::catalog/category/view/description.phtml');
66+
67+
$this->assertContains('data-appearance="contained"', $this->block->toHtml());
68+
}
69+
70+
/**
71+
* Register the category
72+
*
73+
* @param CategoryInterface $category
74+
* @return void
75+
*/
76+
private function registerCategory(CategoryInterface $category): void
77+
{
78+
$this->registry->unregister('current_category');
79+
$this->registry->register('current_category', $category);
80+
}
81+
}

0 commit comments

Comments
 (0)