Skip to content

Commit b4f29c4

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop-fast-lane-prs' into 2.4-develop-temporary-five-prs
2 parents e387e66 + 641d5bb commit b4f29c4

File tree

23 files changed

+643
-142
lines changed

23 files changed

+643
-142
lines changed

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/components/dynamic-rows-configurable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ define([
219219
_.each(tmpData, function (row, index) {
220220
path = this.dataScope + '.' + this.index + '.' + (this.startIndex + index);
221221
row.attributes = $('<i></i>').text(row.attributes).html();
222-
row.sku = $('<i></i>').text(row.sku).html();
222+
row.sku = row.sku;
223223
this.source.set(path, row);
224224
}, this);
225225

@@ -405,7 +405,7 @@ define([
405405
'id': row.productId,
406406
'product_link': row.productUrl,
407407
'name': $('<i></i>').text(row.name).html(),
408-
'sku': $('<i></i>').text(row.sku).html(),
408+
'sku': row.sku,
409409
'status': row.status,
410410
'price': row.price,
411411
'price_currency': row.priceCurrency,
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Developer\Console\Command;
9+
10+
use Magento\Framework\App\Config\ReinitableConfigInterface;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
12+
use Magento\Framework\Console\Cli;
13+
use Symfony\Component\Console\Command\Command;
14+
use Symfony\Component\Console\Input\InputInterface;
15+
use Symfony\Component\Console\Output\OutputInterface;
16+
17+
/**
18+
* Command to show frontend template hints status
19+
*/
20+
class TemplateHintsStatusCommand extends Command
21+
{
22+
const COMMAND_NAME = 'dev:template-hints:status';
23+
const TEMPLATE_HINTS_STOREFRONT_PATH = 'dev/debug/template_hints_storefront';
24+
25+
/**
26+
* @var ScopeConfigInterface
27+
*/
28+
private $scopeConfig;
29+
30+
/**
31+
* @var ReinitableConfigInterface
32+
*/
33+
private $reinitableConfig;
34+
35+
/**
36+
* Initialize dependencies.
37+
*
38+
* @param ScopeConfigInterface $scopeConfig
39+
* @param ReinitableConfigInterface $reinitableConfig
40+
*/
41+
public function __construct(
42+
ScopeConfigInterface $scopeConfig,
43+
ReinitableConfigInterface $reinitableConfig
44+
) {
45+
parent::__construct();
46+
$this->scopeConfig = $scopeConfig;
47+
$this->reinitableConfig = $reinitableConfig;
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
public function configure()
54+
{
55+
$this->setName(self::COMMAND_NAME)
56+
->setDescription('Show frontend template hints status.');
57+
58+
parent::configure();
59+
}
60+
61+
/**
62+
* @inheritdoc
63+
* @throws \InvalidArgumentException
64+
*/
65+
public function execute(InputInterface $input, OutputInterface $output)
66+
{
67+
$this->reinitableConfig->reinit();
68+
$templateHintsStatus =
69+
($this->isTemplateHintsEnabled())
70+
? 'enabled'
71+
: 'disabled';
72+
$templateHintsMessage = __("Template hints are %status", ['status' => $templateHintsStatus]);
73+
$output->writeln("<info>$templateHintsMessage</info>");
74+
75+
return Cli::RETURN_SUCCESS;
76+
}
77+
78+
/**
79+
* Check if template hints enabled
80+
*
81+
* @return bool
82+
*/
83+
private function isTemplateHintsEnabled(): bool
84+
{
85+
return $this->scopeConfig->isSetFlag(self::TEMPLATE_HINTS_STOREFRONT_PATH, 'default');
86+
}
87+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Developer\Test\Unit\Console\Command;
9+
10+
use Magento\Developer\Console\Command\TemplateHintsStatusCommand;
11+
use Magento\Framework\App\Config\ReinitableConfigInterface;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\Console\Cli;
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Console\Tester\CommandTester;
16+
17+
/**
18+
* Class TemplateHintsStatusCommandTest
19+
*
20+
* Tests dev:template-hints:status command.
21+
*/
22+
class TemplateHintsStatusCommandTest extends TestCase
23+
{
24+
/**
25+
* @var TemplateHintsStatusCommand
26+
*/
27+
private $command;
28+
/**
29+
* @var ScopeConfigInterface
30+
*/
31+
private $scopeConfigMock;
32+
/**
33+
* @var ReinitableConfigInterface
34+
*/
35+
private $reinitableConfigMock;
36+
37+
/**
38+
* @inheritDoc
39+
*/
40+
protected function setUp()
41+
{
42+
$this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
43+
$this->reinitableConfigMock = $this->getMockForAbstractClass(ReinitableConfigInterface::class);
44+
45+
$this->command = new TemplateHintsStatusCommand(
46+
$this->scopeConfigMock,
47+
$this->reinitableConfigMock
48+
);
49+
}
50+
51+
/**
52+
* Verify ScopeConfigInterface instance
53+
*/
54+
public function testScopeConfigInterfaceInstance()
55+
{
56+
$this->assertInstanceOf(ScopeConfigInterface::class, $this->scopeConfigMock);
57+
}
58+
59+
/**
60+
* Verify ReinitableConfigInterface instance
61+
*/
62+
public function testReinitableConfigInterfaceInstance()
63+
{
64+
$this->assertInstanceOf(ReinitableConfigInterface::class, $this->reinitableConfigMock);
65+
}
66+
67+
/**
68+
* Verify TemplateHintsStatusCommand instance
69+
*/
70+
public function testCommandInstance()
71+
{
72+
$this->assertInstanceOf(TemplateHintsStatusCommand::class, $this->command);
73+
}
74+
}

app/code/Magento/Developer/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
<item name="dev_query_log_disable" xsi:type="object">Magento\Developer\Console\Command\QueryLogDisableCommand</item>
106106
<item name="dev_template_hints_disable" xsi:type="object">Magento\Developer\Console\Command\TemplateHintsDisableCommand</item>
107107
<item name="dev_template_hints_enable" xsi:type="object">Magento\Developer\Console\Command\TemplateHintsEnableCommand</item>
108+
<item name="dev_template_hints_status" xsi:type="object">Magento\Developer\Console\Command\TemplateHintsStatusCommand</item>
108109
<item name="dev_profiler_disable" xsi:type="object">Magento\Developer\Console\Command\ProfilerDisableCommand</item>
109110
<item name="dev_profiler_enable" xsi:type="object">Magento\Developer\Console\Command\ProfilerEnableCommand</item>
110111
<item name="dev_generate_patch" xsi:type="object">Magento\Developer\Console\Command\GeneratePatchCommand</item>

app/code/Magento/OfflinePayments/Observer/BeforeOrderPaymentSaveObserver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
3030
Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE,
3131
Cashondelivery::PAYMENT_METHOD_CASHONDELIVERY_CODE
3232
];
33-
if (in_array($payment->getMethod(), $instructionMethods)) {
33+
if (in_array($payment->getMethod(), $instructionMethods)
34+
&& empty($payment->getAdditionalInformation('instructions'))) {
3435
$payment->setAdditionalInformation(
3536
'instructions',
3637
$payment->getMethodInstance()->getInstructions()

app/code/Magento/OfflinePayments/Test/Unit/Observer/BeforeOrderPaymentSaveObserverTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,24 @@ public function testBeforeOrderPaymentSaveWithOthers()
172172

173173
$this->_model->execute($this->observer);
174174
}
175+
176+
/**
177+
* @param string $methodCode
178+
* @dataProvider dataProviderBeforeOrderPaymentSaveWithInstructions
179+
*/
180+
public function testBeforeOrderPaymentSaveWithInstructionsAlreadySet($methodCode)
181+
{
182+
$this->payment
183+
->method('getMethod')
184+
->willReturn($methodCode);
185+
186+
$this->payment->expects(self::once())
187+
->method('getAdditionalInformation')
188+
->willReturn('Test');
189+
190+
$this->payment->expects(self::never())
191+
->method('setAdditionalInformation');
192+
193+
$this->_model->execute($this->observer);
194+
}
175195
}

app/code/Magento/Search/Model/PopularSearchTerms.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Magento\Search\Model;
88

99
/**
10-
* Popular search terms
10+
* Finds top search results in search
1111
*/
1212
class PopularSearchTerms
1313
{
@@ -29,7 +29,7 @@ class PopularSearchTerms
2929

3030
/**
3131
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
32-
* @param \Magento\Search\Model\ResourceModel\Query\Collection
32+
* @param \Magento\Search\Model\ResourceModel\Query\Collection $queryCollection
3333
*/
3434
public function __construct(
3535
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
@@ -48,13 +48,8 @@ public function __construct(
4848
*/
4949
public function isCacheable(string $term, int $storeId)
5050
{
51-
$terms = $this->queryCollection
52-
->setPopularQueryFilter($storeId)
53-
->setPageSize($this->getMaxCountCacheableSearchTerms($storeId))
54-
->load()
55-
->getColumnValues('query_text');
56-
57-
return in_array($term, $terms);
51+
$maxCountCacheableSearchTerms = $this->getMaxCountCacheableSearchTerms($storeId);
52+
return $this->queryCollection->isTopSearchResult($term, $storeId, $maxCountCacheableSearchTerms);
5853
}
5954

6055
/**

app/code/Magento/Search/Model/ResourceModel/Query/Collection.php

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,25 @@
55
*/
66
namespace Magento\Search\Model\ResourceModel\Query;
77

8+
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
9+
use Magento\Framework\Data\Collection\EntityFactoryInterface;
10+
use Magento\Framework\DB\Adapter\AdapterInterface;
11+
use Magento\Framework\DB\Helper;
12+
use Magento\Framework\Event\ManagerInterface;
13+
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
14+
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
815
use Magento\Store\Model\Store;
16+
use Magento\Store\Model\StoreManagerInterface;
17+
use Psr\Log\LoggerInterface;
918

1019
/**
1120
* Search query collection
1221
*
1322
* @api
1423
* @since 100.0.2
24+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1525
*/
16-
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
26+
class Collection extends AbstractCollection
1727
{
1828
/**
1929
* Store for filter
@@ -25,36 +35,38 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab
2535
/**
2636
* Store manager
2737
*
28-
* @var \Magento\Store\Model\StoreManagerInterface
38+
* @var StoreManagerInterface
2939
*/
3040
protected $_storeManager;
3141

3242
/**
3343
* Search resource helper
3444
*
35-
* @var \Magento\Framework\DB\Helper
45+
* @var Helper
3646
*/
3747
protected $_resourceHelper;
3848

3949
/**
40-
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
41-
* @param \Psr\Log\LoggerInterface $logger
42-
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
43-
* @param \Magento\Framework\Event\ManagerInterface $eventManager
44-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
45-
* @param \Magento\Framework\DB\Helper $resourceHelper
46-
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
47-
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
50+
* Constructor
51+
*
52+
* @param EntityFactoryInterface $entityFactory
53+
* @param LoggerInterface $logger
54+
* @param FetchStrategyInterface $fetchStrategy
55+
* @param ManagerInterface $eventManager
56+
* @param StoreManagerInterface $storeManager
57+
* @param Helper $resourceHelper
58+
* @param AdapterInterface $connection
59+
* @param AbstractDb $resource
4860
*/
4961
public function __construct(
50-
\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
51-
\Psr\Log\LoggerInterface $logger,
52-
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
53-
\Magento\Framework\Event\ManagerInterface $eventManager,
54-
\Magento\Store\Model\StoreManagerInterface $storeManager,
55-
\Magento\Framework\DB\Helper $resourceHelper,
56-
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
57-
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
62+
EntityFactoryInterface $entityFactory,
63+
LoggerInterface $logger,
64+
FetchStrategyInterface $fetchStrategy,
65+
ManagerInterface $eventManager,
66+
StoreManagerInterface $storeManager,
67+
Helper $resourceHelper,
68+
AdapterInterface $connection = null,
69+
AbstractDb $resource = null
5870
) {
5971
$this->_storeManager = $storeManager;
6072
$this->_resourceHelper = $resourceHelper;
@@ -149,6 +161,36 @@ public function setPopularQueryFilter($storeIds = null)
149161
return $this;
150162
}
151163

164+
/**
165+
* Determines whether a Search Term belongs to the top results for given storeId
166+
*
167+
* @param string $term
168+
* @param int $storeId
169+
* @param int $maxCountCacheableSearchTerms
170+
* @return bool
171+
*/
172+
public function isTopSearchResult(string $term, int $storeId, int $maxCountCacheableSearchTerms):bool
173+
{
174+
$select = $this->getSelect();
175+
$select->reset(\Magento\Framework\DB\Select::FROM);
176+
$select->reset(\Magento\Framework\DB\Select::COLUMNS);
177+
$select->distinct(true);
178+
$select->from(['main_table' => $this->getTable('search_query')], ['query_text']);
179+
$select->where('main_table.store_id IN (?)', $storeId);
180+
$select->where('num_results > 0');
181+
$select->order(['popularity desc']);
182+
183+
$select->limit($maxCountCacheableSearchTerms);
184+
185+
$subQuery = new \Zend_Db_Expr('(' . $select->assemble() . ')');
186+
187+
$select->reset();
188+
$select->from(['result' => $subQuery ], []);
189+
$select->where('result.query_text = ?', $term);
190+
191+
return $this->getSize() > 0;
192+
}
193+
152194
/**
153195
* Set Recent Queries Order
154196
*

0 commit comments

Comments
 (0)