Skip to content

Commit

Permalink
Merge pull request #7712 from magento-amigos/2.4-develop-prs
Browse files Browse the repository at this point in the history
[Amigos] Community Contributions - 2.4-develop
  • Loading branch information
sidolov authored Jun 11, 2022
2 parents 0d9d534 + 9878297 commit 5ab2114
Show file tree
Hide file tree
Showing 23 changed files with 393 additions and 162 deletions.
10 changes: 6 additions & 4 deletions app/code/Magento/Analytics/Model/ExportDataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Archive;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
Expand Down Expand Up @@ -89,8 +90,7 @@ public function __construct(
public function prepareExportData()
{
try {
$tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);

$tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
$this->prepareDirectory($tmpDirectory, $this->getTmpFilesDirRelativePath());
$this->reportWriter->write($tmpDirectory, $this->getTmpFilesDirRelativePath());

Expand All @@ -106,8 +106,10 @@ public function prepareExportData()
$this->cryptographer->encode($tmpDirectory->readFile($this->getArchiveRelativePath()))
);
} finally {
$tmpDirectory->delete($this->getTmpFilesDirRelativePath());
$tmpDirectory->delete($this->getArchiveRelativePath());
if (isset($tmpDirectory)) {
$tmpDirectory->delete($this->getTmpFilesDirRelativePath());
$tmpDirectory->delete($this->getArchiveRelativePath());
}
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Magento_Analytics module

The Magento_Analytics module integrates your Magento instance with the [Magento Business Intelligence (MBI)](https://magento.com/products/business-intelligence) to use [Advanced Reporting](https://devdocs.magento.com/guides/v2.4/advanced-reporting/modules.html) functionality.
The Magento_Analytics module integrates your Magento instance with the [Magento Business Intelligence (MBI)](https://business.adobe.com/products/magento/business-intelligence.html) to use [Advanced Reporting](https://devdocs.magento.com/guides/v2.4/advanced-reporting/modules.html) functionality.

The module implements the following functionality:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Magento\Framework\Archive;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -127,7 +127,7 @@ public function testPrepareExportData($isArchiveSourceDirectory)
$this->filesystemMock
->expects($this->once())
->method('getDirectoryWrite')
->with(DirectoryList::SYS_TMP)
->with(DirectoryList::TMP)
->willReturn($this->directoryMock);
$this->directoryMock
->expects($this->exactly(4))
Expand Down Expand Up @@ -228,7 +228,7 @@ public function testPrepareExportDataWithLocalizedException()
$this->filesystemMock
->expects($this->once())
->method('getDirectoryWrite')
->with(DirectoryList::SYS_TMP)
->with(DirectoryList::TMP)
->willReturn($this->directoryMock);
$this->reportWriterMock
->expects($this->once())
Expand Down
12 changes: 6 additions & 6 deletions app/code/Magento/Backend/etc/menu.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<xs:simpleType name="typeId">
<xs:annotation>
<xs:documentation>
Item id attribute can has only [a-z0-9/_]. Minimal length 3 symbol. Case insensitive.
Item id attribute can have only [a-z0-9/_]. Minimal length 3 characters. Case insensitive.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
Expand All @@ -96,7 +96,7 @@
<xs:simpleType name="typeAction">
<xs:annotation>
<xs:documentation>
Item action attribute can has only [a-zA-Z0-9/_]. Minimal length 3 symbol
Item action attribute can have only [a-zA-Z0-9/_]. Minimal length 3 characters.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
Expand All @@ -107,7 +107,7 @@
<xs:simpleType name="typeTitle">
<xs:annotation>
<xs:documentation>
Item title attribute minimal length 3 symbol
Item title attribute minimal length 3 characters.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
Expand All @@ -119,7 +119,7 @@
<xs:simpleType name="typeModule">
<xs:annotation>
<xs:documentation>
Item module attribute can has only [a-z0-9_]. Minimal length 3 symbol. Case insensitive.
Item module attribute can have only [a-z0-9_]. Minimal length 3 characters. Case insensitive.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
Expand All @@ -130,7 +130,7 @@
<xs:simpleType name="typeResource">
<xs:annotation>
<xs:documentation>
Item resource attribute can has only [a-z0-9_]. Minimal length 3 symbol. Case insensitive.
Item resource attribute can have only [a-z0-9_]. Minimal length 3 characters. Case insensitive.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
Expand All @@ -141,7 +141,7 @@
<xs:simpleType name="typeDependsConfig">
<xs:annotation>
<xs:documentation>
Item resource attribute can has only [a-z0-9_]. Minimal length 3 symbol. Case insensitive.
Item dependsOnConfig attribute can have only [a-z0-9_]. Minimal length 3 characters. Case insensitive.
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
Expand Down
12 changes: 6 additions & 6 deletions app/code/Magento/Catalog/Model/Product/Option/SaveHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface as OptionRepository;
use Magento\Catalog\Model\Product\Option;
use Magento\Catalog\Model\ResourceModel\Product\Relation;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
use Magento\Catalog\Model\ResourceModel\Product\Relation;
use Magento\Framework\Exception\CouldNotSaveException;

/**
Expand All @@ -26,12 +26,12 @@ class SaveHandler implements ExtensionInterface
/**
* @var string[]
*/
private $compositeProductTypes = ['grouped', 'configurable', 'bundle'];
private array $compositeProductTypes = ['grouped', 'configurable', 'bundle'];

/**
* @var OptionRepository
*/
protected $optionRepository;
protected OptionRepository $optionRepository;

/**
* @var Relation
Expand All @@ -44,7 +44,7 @@ class SaveHandler implements ExtensionInterface
*/
public function __construct(
OptionRepository $optionRepository,
?Relation $relation = null
?Relation $relation = null
) {
$this->optionRepository = $optionRepository;
$this->relation = $relation ?: ObjectManager::getInstance()->get(Relation::class);
Expand All @@ -57,6 +57,7 @@ public function __construct(
* @param array $arguments
* @return ProductInterface|object
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @throws CouldNotSaveException
*/
public function execute($entity, $arguments = [])
{
Expand Down Expand Up @@ -122,12 +123,11 @@ private function processOptionsSaving(array $options, bool $hasChangedSku, Produ
private function isProductHasRelations(ProductInterface $product): bool
{
$result = true;
if (!in_array($product->getId(), $this->compositeProductTypes)
if (!in_array($product->getTypeId(), $this->compositeProductTypes)
&& $this->relation->getRelationsByChildren([$product->getId()])
) {
$result = false;
}

return $result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ $_helper = $block->getData('outputHelper');
<form data-role="tocart-form"
data-product-sku="<?= $escaper->escapeHtml($_product->getSku()) ?>"
action="<?= $escaper->escapeUrl($postParams['action']) ?>"
data-mage-init='{"catalogAddToCart": {}}'
method="post">
<?php $options = $block->getData('viewModel')->getOptionsData($_product); ?>
<?php foreach ($options as $optionItem): ?>
Expand Down Expand Up @@ -161,13 +162,4 @@ $_helper = $block->getData('outputHelper');
</div>
<?= $block->getChildBlock('toolbar')->setIsBottom(true)->toHtml() ?>
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
<script type="text/x-magento-init">
{
"[data-role=tocart-form], .form.map.checkout": {
"catalogAddToCart": {
"product_sku": "<?= $escaper->escapeJs($_product->getSku()) ?>"
}
}
}
</script>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ define([
isCustomerLoggedIn: customer.isLoggedIn,
forgotPasswordUrl: window.checkoutConfig.forgotPasswordUrl,
emailCheckTimeout: 0,
emailInputId: '#customer-email',

/**
* Initializes regular properties of instance.
Expand Down Expand Up @@ -108,6 +109,8 @@ define([
checkEmailAvailability: function () {
this.validateRequest();
this.isEmailCheckComplete = $.Deferred();
// Clean up errors on email
$(this.emailInputId).removeClass('mage-error').parent().find('.mage-error').remove();
this.isLoading(true);
this.checkRequest = checkEmailAvailability(this.isEmailCheckComplete, this.email());

Expand Down
13 changes: 13 additions & 0 deletions app/code/Magento/CustomerGraphQl/etc/graphql/events.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="customer_login">
<observer name="customer_log_login" instance="Magento\Customer\Observer\LogLastLoginAtObserver" />
</event>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Magento\Framework\Indexer\ConfigInterface;
use Magento\Framework\Console\Cli;

/**
* Command for invalidating indexers.
*/
class IndexerResetStateCommand extends AbstractIndexerManageCommand
{
/**
* {@inheritdoc}
* Configures the current command.
*/
protected function configure()
{
Expand All @@ -29,16 +30,18 @@ protected function configure()
}

/**
* {@inheritdoc}
* Invalidate / reset the indexer
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$indexers = $this->getIndexers($input);
foreach ($indexers as $indexer) {
try {
$indexer->getState()
->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID)
->save();
$indexer->invalidate();
$output->writeln($indexer->getTitle() . ' indexer has been invalidated.');
} catch (LocalizedException $e) {
$output->writeln($e->getMessage());
Expand All @@ -47,5 +50,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln($e->getMessage());
}
}
return Cli::RETURN_SUCCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,17 @@ class IndexerResetStateCommandTest extends AbstractIndexerCommandCommonSetup
*/
private $command;

protected function setUp(): void
{
parent::setUp();
$this->stateMock->expects($this->once())->method('setAreaCode')->with(FrontNameResolver::AREA_CODE);
}

public function testExecute()
{
$this->configureAdminArea();
$indexerOne = $this->getIndexerMock(
['getState'],
['invalidate'],
['indexer_id' => 'indexer_1', 'title' => 'Title_indexerOne']
);
$this->initIndexerCollectionByItems([$indexerOne]);

$stateMock = $this->createMock(State::class);
$stateMock->expects($this->exactly(1))
->method('setStatus')
->with(StateInterface::STATUS_INVALID)->willReturnSelf();

$stateMock->expects($this->exactly(1))
->method('save');

$indexerOne->expects($this->once())
->method('getState')
->willReturn($stateMock);
->method('invalidate');

$this->command = new IndexerResetStateCommand($this->objectManagerFactory);
$commandTester = new CommandTester($this->command);
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/NewRelicReporting/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
</depends>
</field>
<field id="separate_apps" translate="label comment" type="select" sortOrder="9" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Send Adminhtml and Frontend as Separate Apps</label>
<label>Send each Magento Area Code as Separate App</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>In addition to the main app (which includes all PHP execution), separate apps for adminhtml and frontend will be created. Requires New Relic Application Name to be set.</comment>
<comment>In addition to the main app (which includes all PHP execution), separate apps for each Magento area code (adminhtml, frontend, ...) will be created. Requires New Relic Application Name to be set.</comment>
<depends>
<field id="enable">1</field>
</depends>
Expand Down
Loading

0 comments on commit 5ab2114

Please sign in to comment.