Skip to content

Commit 8966164

Browse files
author
Andrey Konosov
committed
Merge remote-tracking branch 'main/develop' into epam-4
2 parents bfded9f + 163044a commit 8966164

File tree

76 files changed

+1205
-219
lines changed

Some content is hidden

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

76 files changed

+1205
-219
lines changed

app/code/Magento/Catalog/Block/Product/AbstractProduct.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,4 +598,48 @@ public function isRedirectToCartEnabled()
598598
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
599599
);
600600
}
601+
602+
/**
603+
* Retrieve product details html
604+
*
605+
* @param \Magento\Catalog\Model\Product $product
606+
* @return mixed
607+
*/
608+
public function getProductDetailsHtml(\Magento\Catalog\Model\Product $product)
609+
{
610+
$renderer = $this->getDetailsRenderer($product->getTypeId());
611+
if ($renderer) {
612+
$renderer->setProduct($product);
613+
return $renderer->toHtml();
614+
}
615+
return '';
616+
}
617+
618+
/**
619+
* @param null $type
620+
* @return bool|\Magento\Framework\View\Element\AbstractBlock
621+
*/
622+
public function getDetailsRenderer($type = null)
623+
{
624+
if ($type === null) {
625+
$type = 'default';
626+
}
627+
$rendererList = $this->getDetailsRendererList();
628+
if ($rendererList) {
629+
return $rendererList->getRenderer($type, 'default');
630+
}
631+
return null;
632+
}
633+
634+
/**
635+
* @return \Magento\Framework\View\Element\RendererList
636+
*/
637+
protected function getDetailsRendererList()
638+
{
639+
return $this->getDetailsRendererListName() ? $this->getLayout()->getBlock(
640+
$this->getDetailsRendererListName()
641+
) : $this->getChildBlock(
642+
'details.renderers'
643+
);
644+
}
601645
}

app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
<block class="Magento\Catalog\Block\Category\View" name="category.products" template="Magento_Catalog::category/products.phtml">
1919
<block class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml">
2020
<container name="category.product.list.additional" as="additional" />
21+
<block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
22+
<block class="Magento\Framework\View\Element\Template" as="default"/>
23+
</block>
2124
<block class="Magento\Catalog\Block\Product\ProductList\Toolbar" name="product_list_toolbar" template="product/list/toolbar.phtml">
2225
<block class="Magento\Theme\Block\Html\Pager" name="product_list_toolbar_pager"/>
2326
<!-- The following code shows how to set your own pager increments -->

app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I
6969
</strong>
7070
<?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
7171
<?php echo $block->getProductPrice($_product) ?>
72+
<?php echo $block->getProductDetailsHtml($_product); ?>
7273

7374
<div class="product-item-inner">
7475
<div class="product actions product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>>
@@ -94,7 +95,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I
9495
</div>
9596
<div data-role="add-to-links" class="actions-secondary"<?php echo strpos($pos, $viewMode . '-secondary') ? $position : ''; ?>>
9697
<?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?>
97-
<a href="#"
98+
<a href="#"
9899
class="action towishlist"
99100
title="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
100101
aria-label="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
@@ -107,7 +108,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I
107108
<?php
108109
$compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');
109110
?>
110-
<a href="#"
111+
<a href="#"
111112
class="action tocompare"
112113
title="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"
113114
aria-label="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"

app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_advanced_result.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<action method="setToolbarBlockName">
2323
<argument name="name" xsi:type="string">product_list_toolbar</argument>
2424
</action>
25+
<block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
26+
<block class="Magento\Framework\View\Element\Template" as="default"/>
27+
</block>
2528
</block>
2629
<action method="setListOrders"/>
2730
<action method="setListModes"/>

app/code/Magento/CatalogSearch/view/frontend/layout/catalogsearch_result_index.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<action method="setToolbarBlockName">
2424
<argument name="name" xsi:type="string">product_list_toolbar</argument>
2525
</action>
26+
<block class="Magento\Framework\View\Element\RendererList" name="category.product.type.details.renderers" as="details.renderers">
27+
<block class="Magento\Framework\View\Element\Template" as="default"/>
28+
</block>
2629
</block>
2730
<action method="setListOrders"/>
2831
<action method="setListModes"/>

app/code/Magento/ConfigurableProduct/Model/SuggestedAttributeList.php

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,45 @@ class SuggestedAttributeList
1414
*
1515
* @var \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory
1616
*/
17-
protected $_attributeColFactory;
17+
protected $attributeCollectionFactory;
1818

1919
/**
2020
* Catalog resource helper
2121
*
2222
* @var \Magento\Catalog\Model\Resource\Helper
2323
*/
24-
protected $_resourceHelper;
24+
protected $resourceHelper;
2525

2626
/**
27-
* @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeColFactory
27+
* Application Event Dispatcher
28+
*
29+
* @var \Magento\Framework\Event\ManagerInterface
30+
*/
31+
protected $eventManager;
32+
33+
/**
34+
* Object Factory
35+
*
36+
* @var \Magento\Framework\ObjectFactory
37+
*/
38+
protected $objectFactory;
39+
40+
/**
41+
* @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory
2842
* @param \Magento\Catalog\Model\Resource\Helper $resourceHelper
43+
* @param \Magento\Framework\Event\ManagerInterface $eventManager
44+
* @param \Magento\Framework\ObjectFactory $objectFactory
2945
*/
3046
public function __construct(
31-
\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeColFactory,
32-
\Magento\Catalog\Model\Resource\Helper $resourceHelper
47+
\Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory,
48+
\Magento\Catalog\Model\Resource\Helper $resourceHelper,
49+
\Magento\Framework\Event\ManagerInterface $eventManager,
50+
\Magento\Framework\ObjectFactory $objectFactory
3351
) {
34-
$this->_attributeColFactory = $attributeColFactory;
35-
$this->_resourceHelper = $resourceHelper;
52+
$this->attributeCollectionFactory = $attributeCollectionFactory;
53+
$this->resourceHelper = $resourceHelper;
54+
$this->objectFactory = $objectFactory;
55+
$this->eventManager = $eventManager;
3656
}
3757

3858
/**
@@ -43,12 +63,14 @@ public function __construct(
4363
*/
4464
public function getSuggestedAttributes($labelPart)
4565
{
46-
$escapedLabelPart = $this->_resourceHelper->addLikeEscape($labelPart, ['position' => 'any']);
66+
$escapedLabelPart = $this->resourceHelper->addLikeEscape($labelPart, ['position' => 'any']);
67+
$availableFrontendTypes = $this->getAvailableFrontendTypes();
68+
4769
/** @var $collection \Magento\Catalog\Model\Resource\Product\Attribute\Collection */
48-
$collection = $this->_attributeColFactory->create();
70+
$collection = $this->attributeCollectionFactory->create();
4971
$collection->addFieldToFilter(
50-
'frontend_input',
51-
'select'
72+
'main_table.frontend_input',
73+
['in' => $availableFrontendTypes->getData('values')]
5274
)->addFieldToFilter(
5375
'frontend_label',
5476
['like' => $escapedLabelPart]
@@ -79,4 +101,22 @@ public function getSuggestedAttributes($labelPart)
79101
}
80102
return $result;
81103
}
104+
105+
/**
106+
* @return \Magento\Framework\Object
107+
*/
108+
private function getAvailableFrontendTypes()
109+
{
110+
$availableFrontendTypes = $this->objectFactory->create();
111+
$availableFrontendTypes->setData(
112+
[
113+
'values' => ['select']
114+
]
115+
);
116+
$this->eventManager->dispatch(
117+
'product_suggested_attribute_frontend_type_init_after',
118+
['types_dto' => $availableFrontendTypes]
119+
);
120+
return $availableFrontendTypes;
121+
}
82122
}

app/code/Magento/ConfigurableProduct/Test/Unit/Model/SuggestedAttributeListTest.php

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ class SuggestedAttributeListTest extends \PHPUnit_Framework_TestCase
2020
*/
2121
protected $attributeFactoryMock;
2222

23+
/**
24+
* @var \PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
protected $eventManagerMock;
27+
28+
/**
29+
* @var \PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
protected $objectFactoryMock;
32+
2333
/**
2434
* @var \PHPUnit_Framework_MockObject_MockObject
2535
*/
@@ -53,6 +63,20 @@ protected function setUp()
5363
'',
5464
false
5565
);
66+
$this->eventManagerMock = $this->getMock(
67+
'\Magento\Framework\Event\ManagerInterface',
68+
[],
69+
[],
70+
'',
71+
false
72+
);
73+
$this->objectFactoryMock = $this->getMock(
74+
'\Magento\Framework\ObjectFactory',
75+
['create'],
76+
[],
77+
'',
78+
false
79+
);
5680
$this->collectionMock = $this->getMock(
5781
'Magento\Catalog\Model\Resource\Product\Attribute\Collection',
5882
[],
@@ -78,7 +102,7 @@ protected function setUp()
78102
$this->returnValue($this->collectionMock)
79103
);
80104
$valueMap = [
81-
['frontend_input', 'select', $this->collectionMock],
105+
['main_table.frontend_input', ['in' => 123 ], $this->collectionMock],
82106
['frontend_label', ['like' => $this->labelPart], $this->collectionMock],
83107
['is_user_defined', 1, $this->collectionMock],
84108
['is_global', \Magento\Catalog\Model\Resource\Eav\Attribute::SCOPE_GLOBAL, $this->collectionMock],
@@ -107,12 +131,19 @@ protected function setUp()
107131
);
108132
$this->suggestedListModel = new \Magento\ConfigurableProduct\Model\SuggestedAttributeList(
109133
$this->attributeFactoryMock,
110-
$this->resourceHelperMock
134+
$this->resourceHelperMock,
135+
$this->eventManagerMock,
136+
$this->objectFactoryMock
111137
);
112138
}
113139

114140
public function testGetSuggestedAttributesIfTheyApplicable()
115141
{
142+
$object = $this->getMock('\Magento\Framework\Object', [], [], '', false);
143+
$object->expects($this->once())->method('setData');
144+
$object->expects($this->once())->method('getData')->willReturn(123);
145+
$this->objectFactoryMock->expects($this->once())->method('create')->willReturn($object);
146+
116147
$source = $this->getMock(
117148
'Magento\Eav\Model\Entity\Attribute\Source\AbstractSource',
118149
[],
@@ -132,6 +163,10 @@ public function testGetSuggestedAttributesIfTheyApplicable()
132163

133164
public function testGetSuggestedAttributesIfTheyNotApplicable()
134165
{
166+
$object = $this->getMock('\Magento\Framework\Object', [], [], '', false);
167+
$object->expects($this->once())->method('setData');
168+
$object->expects($this->once())->method('getData')->willReturn(123);
169+
$this->objectFactoryMock->expects($this->once())->method('create')->willReturn($object);
135170
$this->attributeMock->expects($this->any())->method('getApplyTo')->will($this->returnValue(['simple']));
136171
$this->attributeMock->expects($this->never())->method('getId');
137172
$this->attributeMock->expects($this->never())->method('getFrontendLabel');

app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public function getStoreOptionValues($storeId)
268268
*
269269
* @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
270270
*/
271-
private function getAttributeObject()
271+
protected function getAttributeObject()
272272
{
273273
return $this->_registry->registry('entity_attribute');
274274
}

app/code/Magento/Payment/Block/Info.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Info extends \Magento\Framework\View\Element\Template
1515
*
1616
* @var \Magento\Framework\Object
1717
*/
18-
protected $_paymentSpecificInformation = null;
18+
protected $_paymentSpecificInformation;
1919

2020
/**
2121
* @var string
@@ -152,10 +152,6 @@ protected function _prepareSpecificInformation($transport = null)
152152
} elseif (is_array($transport)) {
153153
$transport = new \Magento\Framework\Object($transport);
154154
}
155-
$this->_eventManager->dispatch(
156-
'payment_info_block_prepare_specific_information',
157-
['transport' => $transport, 'payment' => $this->getInfo(), 'block' => $this]
158-
);
159155
$this->_paymentSpecificInformation = $transport;
160156
}
161157
return $this->_paymentSpecificInformation;

app/code/Magento/Payment/Block/Transparent/Form.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Payment\Block\Transparent;
77

88
use Magento\Framework\Exception\LocalizedException;
9+
use Magento\Payment\Model\Method\Adapter;
910
use Magento\Payment\Model\Method\TransparentInterface;
1011
use Magento\Checkout\Model\Session;
1112
use Magento\Payment\Model\Config;
@@ -168,7 +169,11 @@ public function getCgiUrl()
168169
*/
169170
public function getMethodConfigData($fieldName)
170171
{
171-
return $this->getMethod()->getConfigInterface()->getValue($fieldName);
172+
$method = $this->getMethod();
173+
if ($method instanceof TransparentInterface) {
174+
return $method->getConfigInterface()->getValue($fieldName);
175+
}
176+
return $method->getConfigData($fieldName);
172177
}
173178

174179
/**
@@ -181,7 +186,7 @@ public function getMethod()
181186
{
182187
$method = parent::getMethod();
183188

184-
if (!$method instanceof TransparentInterface) {
189+
if (!$method instanceof TransparentInterface && !$method instanceof Adapter) {
185190
throw new LocalizedException(
186191
__('We cannot retrieve the transparent payment method model object.')
187192
);

0 commit comments

Comments
 (0)