diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index 00b093b2918f1..aa99918753e81 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -1130,10 +1130,15 @@ public function reindex()
}
}
$productIndexer = $this->indexerRegistry->get(Indexer\Category\Product::INDEXER_ID);
- if (!$productIndexer->isScheduled()
- && (!empty($this->getAffectedProductIds()) || $this->dataHasChangedFor('is_anchor'))
- ) {
- $productIndexer->reindexList($this->getPathIds());
+
+ if (!empty($this->getAffectedProductIds())
+ || $this->dataHasChangedFor('is_anchor')
+ || $this->dataHasChangedFor('is_active')) {
+ if (!$productIndexer->isScheduled()) {
+ $productIndexer->reindexList($this->getPathIds());
+ } else {
+ $productIndexer->invalidate();
+ }
}
}
@@ -1165,16 +1170,14 @@ public function getIdentities()
$identities[] = self::CACHE_TAG . '_' . $this->getId();
}
- if ($this->hasDataChanges() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
- $identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
- }
-
+ $identities = $this->getCategoryRelationIdentities($identities);
+
if ($this->isObjectNew()) {
$identities[] = self::CACHE_TAG;
}
}
- return $identities;
+ return array_unique($identities);
}
/**
@@ -1460,5 +1463,25 @@ public function setExtensionAttributes(\Magento\Catalog\Api\Data\CategoryExtensi
return $this->_setExtensionAttributes($extensionAttributes);
}
+ /**
+ * Return category relation identities.
+ *
+ * @param array $identities
+ * @return array
+ */
+ private function getCategoryRelationIdentities(array $identities): array
+ {
+ if ($this->hasDataChanges() || $this->isDeleted() || $this->dataHasChangedFor(self::KEY_INCLUDE_IN_MENU)) {
+ $identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $this->getId();
+ if ($this->dataHasChangedFor('is_anchor') || $this->dataHasChangedFor('is_active')) {
+ foreach ($this->getPathIds() as $id) {
+ $identities[] = Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $id;
+ }
+ }
+ }
+
+ return $identities;
+ }
+
//@codeCoverageIgnoreEnd
}
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontCategoryActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontCategoryActionGroup.xml
index 2551bd61580ed..e46bfc7ee8b02 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontCategoryActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontCategoryActionGroup.xml
@@ -19,6 +19,12 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Page/AdminProductUpdateAttributesPage.xml b/app/code/Magento/Catalog/Test/Mftf/Page/AdminProductUpdateAttributesPage.xml
new file mode 100644
index 0000000000000..84996a3814571
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/Page/AdminProductUpdateAttributesPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFiltersSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFiltersSection.xml
index 6844006e4e399..8e13f9c38f805 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFiltersSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFiltersSection.xml
@@ -7,12 +7,13 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductSEOSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductSEOSection.xml
index 1d49d05363612..90c3856933be9 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductSEOSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductSEOSection.xml
@@ -11,5 +11,6 @@
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminUpdateAttributesSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminUpdateAttributesSection.xml
new file mode 100644
index 0000000000000..051fda092d151
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminUpdateAttributesSection.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml
index 1f1a4ce9133e7..3c769f9dbc0ce 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategoryMainSection.xml
@@ -22,5 +22,6 @@
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductAvailableAfterEnablingSubCategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductAvailableAfterEnablingSubCategoriesTest.xml
new file mode 100644
index 0000000000000..fe7858313c848
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductAvailableAfterEnablingSubCategoriesTest.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml
index 68dbe628e9817..e7054839ef4d0 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml
@@ -7,7 +7,7 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
@@ -16,9 +16,6 @@
-
-
-
@@ -65,18 +62,23 @@
+
+
+
+
+
+
-
-
-
-
+
+
+
@@ -100,15 +102,12 @@
-
-
-
-
-
+
+
+
-
@@ -128,16 +127,13 @@
-
-
-
-
-
+
+
+
-
@@ -156,10 +152,7 @@
-
-
-
-
+
@@ -177,23 +170,29 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
@@ -205,14 +204,12 @@
-
-
-
-
-
-
-
+
+
+
+
+
@@ -232,9 +229,7 @@
-
-
-
+
@@ -252,18 +247,26 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -296,8 +299,7 @@
-
-
+
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php
index a53b87dcf1567..c84753ad4adcb 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php
@@ -348,13 +348,15 @@ public function testReindexFlatEnabled($flatScheduled, $productScheduled, $expec
public function reindexFlatDisabledTestDataProvider()
{
return [
- [false, null, null, null, 0],
- [true, null, null, null, 0],
- [false, [], null, null, 0],
- [false, ["1", "2"], null, null, 1],
- [false, null, 1, null, 1],
- [false, ["1", "2"], 0, 1, 1],
- [false, null, 1, 1, 0],
+ [false, null, null, null, null, null, 0],
+ [true, null, null, null, null, null, 0],
+ [false, [], null, null, null, null, 0],
+ [false, ["1", "2"], null, null, null, null, 1],
+ [false, null, 1, null, null, null, 1],
+ [false, ["1", "2"], 0, 1, null, null, 1],
+ [false, null, 1, 1, null, null, 0],
+ [false, ["1", "2"], null, null, 0, 1, 1],
+ [false, ["1", "2"], null, null, 1, 0, 1],
];
}
@@ -363,6 +365,8 @@ public function reindexFlatDisabledTestDataProvider()
* @param array $affectedIds
* @param int|string $isAnchorOrig
* @param int|string $isAnchor
+ * @param mixed $isActiveOrig
+ * @param mixed $isActive,
* @param int $expectedProductReindexCall
*
* @dataProvider reindexFlatDisabledTestDataProvider
@@ -372,12 +376,16 @@ public function testReindexFlatDisabled(
$affectedIds,
$isAnchorOrig,
$isAnchor,
+ $isActiveOrig,
+ $isActive,
$expectedProductReindexCall
) {
$this->category->setAffectedProductIds($affectedIds);
$this->category->setData('is_anchor', $isAnchor);
$this->category->setOrigData('is_anchor', $isAnchorOrig);
$this->category->setAffectedProductIds($affectedIds);
+ $this->category->setData('is_active', $isActive);
+ $this->category->setOrigData('is_active', $isActiveOrig);
$pathIds = ['path/1/2', 'path/2/3'];
$this->category->setData('path_ids', $pathIds);
@@ -387,7 +395,7 @@ public function testReindexFlatDisabled(
->method('isFlatEnabled')
->will($this->returnValue(false));
- $this->productIndexer->expects($this->exactly(1))
+ $this->productIndexer->expects($this->any())
->method('isScheduled')
->willReturn($productScheduled);
$this->productIndexer->expects($this->exactly($expectedProductReindexCall))
diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/ProductToWebsiteChangeObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/ProductToWebsiteChangeObserver.php
index fc2056e83ec70..94798753ca63f 100644
--- a/app/code/Magento/CatalogUrlRewrite/Observer/ProductToWebsiteChangeObserver.php
+++ b/app/code/Magento/CatalogUrlRewrite/Observer/ProductToWebsiteChangeObserver.php
@@ -14,6 +14,9 @@
use Magento\UrlRewrite\Model\UrlPersistInterface;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
+/**
+ * Observer to assign the products to website.
+ */
class ProductToWebsiteChangeObserver implements ObserverInterface
{
/**
@@ -69,12 +72,14 @@ public function execute(\Magento\Framework\Event\Observer $observer)
$this->request->getParam('store_id', Store::DEFAULT_STORE_ID)
);
- $this->urlPersist->deleteByData([
- UrlRewrite::ENTITY_ID => $product->getId(),
- UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
- ]);
- if ($product->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE) {
- $this->urlPersist->replace($this->productUrlRewriteGenerator->generate($product));
+ if (!empty($this->productUrlRewriteGenerator->generate($product))) {
+ $this->urlPersist->deleteByData([
+ UrlRewrite::ENTITY_ID => $product->getId(),
+ UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE,
+ ]);
+ if ($product->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE) {
+ $this->urlPersist->replace($this->productUrlRewriteGenerator->generate($product));
+ }
}
}
}
diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml
new file mode 100644
index 0000000000000..d52395342c092
--- /dev/null
+++ b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml
index f79d59028c468..d20616b4384d1 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml
@@ -7,7 +7,7 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
@@ -37,7 +37,7 @@
-
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckCustomerInfoCreatedByGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckCustomerInfoCreatedByGuestTest.xml
new file mode 100644
index 0000000000000..32cc254543bca
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckCustomerInfoCreatedByGuestTest.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cms/Model/ResourceModel/Block.php b/app/code/Magento/Cms/Model/ResourceModel/Block.php
index 9aab54b02bc14..9b4bc5ec3ea11 100644
--- a/app/code/Magento/Cms/Model/ResourceModel/Block.php
+++ b/app/code/Magento/Cms/Model/ResourceModel/Block.php
@@ -95,9 +95,11 @@ protected function _beforeSave(AbstractModel $object)
}
/**
+ * Get block id.
+ *
* @param AbstractModel $object
* @param mixed $value
- * @param null $field
+ * @param string $field
* @return bool|int|string
* @throws LocalizedException
* @throws \Exception
@@ -183,10 +185,12 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
$entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
$linkField = $entityMetadata->getLinkField();
- if ($this->_storeManager->isSingleStoreMode()) {
- $stores = [Store::DEFAULT_STORE_ID];
- } else {
- $stores = (array)$object->getData('store_id');
+ $stores = (array)$object->getData('store_id');
+ $isDefaultStore = $this->_storeManager->isSingleStoreMode()
+ || array_search(Store::DEFAULT_STORE_ID, $stores) !== false;
+
+ if (!$isDefaultStore) {
+ $stores[] = Store::DEFAULT_STORE_ID;
}
$select = $this->getConnection()->select()
@@ -196,8 +200,11 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
'cb.' . $linkField . ' = cbs.' . $linkField,
[]
)
- ->where('cb.identifier = ?', $object->getData('identifier'))
- ->where('cbs.store_id IN (?)', $stores);
+ ->where('cb.identifier = ?', $object->getData('identifier'));
+
+ if (!$isDefaultStore) {
+ $select->where('cbs.store_id IN (?)', $stores);
+ }
if ($object->getId()) {
$select->where('cb.' . $entityMetadata->getIdentifierField() . ' <> ?', $object->getId());
@@ -236,6 +243,8 @@ public function lookupStoreIds($id)
}
/**
+ * Save an object.
+ *
* @param AbstractModel $object
* @return $this
* @throws \Exception
diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminCmsBlockActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminCmsBlockActionGroup.xml
new file mode 100644
index 0000000000000..597df165f61d1
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminCmsBlockActionGroup.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cms/Test/Mftf/Page/AdminCmsBlockNewPage.xml b/app/code/Magento/Cms/Test/Mftf/Page/AdminCmsBlockNewPage.xml
new file mode 100644
index 0000000000000..2868d832ad762
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/Page/AdminCmsBlockNewPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cms/Test/Mftf/Section/AdminCmsBlockContentSection.xml b/app/code/Magento/Cms/Test/Mftf/Section/AdminCmsBlockContentSection.xml
index 9614f13f9e3d3..20e55c49ec235 100644
--- a/app/code/Magento/Cms/Test/Mftf/Section/AdminCmsBlockContentSection.xml
+++ b/app/code/Magento/Cms/Test/Mftf/Section/AdminCmsBlockContentSection.xml
@@ -11,5 +11,8 @@
diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckCreateStaticBlockOnDuplicateIdentifierTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckCreateStaticBlockOnDuplicateIdentifierTest.xml
new file mode 100644
index 0000000000000..ac1b68269740f
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckCreateStaticBlockOnDuplicateIdentifierTest.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAddCustomerAddressActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAddCustomerAddressActionGroup.xml
new file mode 100644
index 0000000000000..1ffc258e78a43
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAddCustomerAddressActionGroup.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Page/AdminEditCustomerPage.xml b/app/code/Magento/Customer/Test/Mftf/Page/AdminEditCustomerPage.xml
index 72d5d90bdc05f..7cd36c12c80bd 100644
--- a/app/code/Magento/Customer/Test/Mftf/Page/AdminEditCustomerPage.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Page/AdminEditCustomerPage.xml
@@ -12,5 +12,6 @@
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountAddressSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountAddressSection.xml
index db9619dde671f..70042e2a71467 100644
--- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountAddressSection.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountAddressSection.xml
@@ -7,7 +7,7 @@
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountNewAddressSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountNewAddressSection.xml
new file mode 100644
index 0000000000000..8445343c9b9c0
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountNewAddressSection.xml
@@ -0,0 +1,19 @@
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml
index 0a77890033295..9553752539757 100644
--- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml
@@ -7,8 +7,9 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php
index aa298d7d547bf..5ee15287e8899 100644
--- a/app/code/Magento/Eav/Model/Entity/Type.php
+++ b/app/code/Magento/Eav/Model/Entity/Type.php
@@ -167,11 +167,8 @@ public function getAttributeCollection($setId = null)
*/
protected function _getAttributeCollection()
{
- $collection = $this->_attributeFactory->create()->getCollection();
- $objectsModel = $this->getAttributeModel();
- if ($objectsModel) {
- $collection->setModel($objectsModel);
- }
+ $collection = $this->_universalFactory->create($this->getEntityAttributeCollection());
+ $collection->setItemObjectClass($this->getAttributeModel());
return $collection;
}
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php
index 1f90309721c23..9c80f6aa423b8 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php
@@ -6,23 +6,58 @@
namespace Magento\Reports\Block\Adminhtml\Sales\Sales;
+use Magento\Framework\DataObject;
use Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency;
+use Magento\Framework\App\ObjectManager;
+use Magento\Sales\Model\Order\ConfigFactory;
+use Magento\Sales\Model\Order;
/**
* Adminhtml sales report grid block
*
- * @author Magento Core Team
* @SuppressWarnings(PHPMD.DepthOfInheritance)
*/
class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid
{
/**
- * GROUP BY criteria
- *
* @var string
*/
protected $_columnGroupBy = 'period';
+ /**
+ * @var ConfigFactory
+ */
+ private $configFactory;
+
+ /**
+ * @param \Magento\Backend\Block\Template\Context $context
+ * @param \Magento\Backend\Helper\Data $backendHelper
+ * @param \Magento\Reports\Model\ResourceModel\Report\Collection\Factory $resourceFactory
+ * @param \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory
+ * @param \Magento\Reports\Helper\Data $reportsData
+ * @param array $data
+ * @param ConfigFactory|null $configFactory
+ */
+ public function __construct(
+ \Magento\Backend\Block\Template\Context $context,
+ \Magento\Backend\Helper\Data $backendHelper,
+ \Magento\Reports\Model\ResourceModel\Report\Collection\Factory $resourceFactory,
+ \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory,
+ \Magento\Reports\Helper\Data $reportsData,
+ array $data = [],
+ ConfigFactory $configFactory = null
+ ) {
+ parent::__construct(
+ $context,
+ $backendHelper,
+ $resourceFactory,
+ $collectionFactory,
+ $reportsData,
+ $data
+ );
+ $this->configFactory = $configFactory ?: ObjectManager::getInstance()->get(ConfigFactory::class);
+ }
+
/**
* {@inheritdoc}
* @codeCoverageIgnore
@@ -328,4 +363,31 @@ protected function _prepareColumns()
return parent::_prepareColumns();
}
+
+ /**
+ * @inheritdoc
+ *
+ * Filter canceled statuses for orders.
+ *
+ * @return Grid
+ */
+ protected function _prepareCollection()
+ {
+ /** @var DataObject $filterData */
+ $filterData = $this->getData('filter_data');
+ if (!$filterData->hasData('order_statuses')) {
+ $orderConfig = $this->configFactory->create();
+ $statusValues = [];
+ $canceledStatuses = $orderConfig->getStateStatuses(Order::STATE_CANCELED);
+ $statusCodes = array_keys($orderConfig->getStatuses());
+ foreach ($statusCodes as $code) {
+ if (!isset($canceledStatuses[$code])) {
+ $statusValues[] = $code;
+ }
+ }
+ $filterData->setData('order_statuses', $statusValues);
+ }
+
+ return parent::_prepareCollection();
+ }
}
diff --git a/app/code/Magento/Reports/Test/Mftf/ActionGroup/GenerateOrderReportActionGroup.xml b/app/code/Magento/Reports/Test/Mftf/ActionGroup/GenerateOrderReportActionGroup.xml
new file mode 100644
index 0000000000000..8ddfd4092645f
--- /dev/null
+++ b/app/code/Magento/Reports/Test/Mftf/ActionGroup/GenerateOrderReportActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Reports/Test/Mftf/Page/AdminOrdersReportPage.xml b/app/code/Magento/Reports/Test/Mftf/Page/AdminOrdersReportPage.xml
new file mode 100644
index 0000000000000..f0b51f6e39357
--- /dev/null
+++ b/app/code/Magento/Reports/Test/Mftf/Page/AdminOrdersReportPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Reports/Test/Mftf/Section/AdminOrderReportFilterSection.xml b/app/code/Magento/Reports/Test/Mftf/Section/AdminOrderReportFilterSection.xml
new file mode 100644
index 0000000000000..33527e1262020
--- /dev/null
+++ b/app/code/Magento/Reports/Test/Mftf/Section/AdminOrderReportFilterSection.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Reports/Test/Mftf/Section/AdminOrderReportMainActionsSection.xml b/app/code/Magento/Reports/Test/Mftf/Section/AdminOrderReportMainActionsSection.xml
new file mode 100644
index 0000000000000..c4a96537740ee
--- /dev/null
+++ b/app/code/Magento/Reports/Test/Mftf/Section/AdminOrderReportMainActionsSection.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Reports/Test/Mftf/Section/AdminOrderReportTableSection.xml b/app/code/Magento/Reports/Test/Mftf/Section/AdminOrderReportTableSection.xml
new file mode 100644
index 0000000000000..e920d28bcf386
--- /dev/null
+++ b/app/code/Magento/Reports/Test/Mftf/Section/AdminOrderReportTableSection.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml b/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml
new file mode 100644
index 0000000000000..009e4b8e5f6f1
--- /dev/null
+++ b/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Observer/AssignOrderToCustomerObserver.php b/app/code/Magento/Sales/Observer/AssignOrderToCustomerObserver.php
index 9857fa39fa51a..80e909941c5ce 100644
--- a/app/code/Magento/Sales/Observer/AssignOrderToCustomerObserver.php
+++ b/app/code/Magento/Sales/Observer/AssignOrderToCustomerObserver.php
@@ -57,6 +57,17 @@ public function execute(Observer $observer)
$orderId = $delegateData['__sales_assign_order_id'];
$order = $this->orderRepository->get($orderId);
if (!$order->getCustomerId() && $customer->getId()) {
+ // Assign customer info to order after customer creation.
+ $order->setCustomerId($customer->getId())
+ ->setCustomerIsGuest(0)
+ ->setCustomerEmail($customer->getEmail())
+ ->setCustomerFirstname($customer->getFirstname())
+ ->setCustomerLastname($customer->getLastname())
+ ->setCustomerMiddlename($customer->getMiddlename())
+ ->setCustomerPrefix($customer->getPrefix())
+ ->setCustomerSuffix($customer->getSuffix())
+ ->setCustomerGroupId($customer->getGroupId());
+
$this->assignmentService->execute($order, $customer);
}
}
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminAbleToShipPartiallyInvoicedItemsTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminAbleToShipPartiallyInvoicedItemsTest.xml
index cb761dc358abb..d196783744c46 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminAbleToShipPartiallyInvoicedItemsTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminAbleToShipPartiallyInvoicedItemsTest.xml
@@ -14,9 +14,6 @@
-
-
-
diff --git a/app/code/Magento/Sales/Test/Unit/Observer/AssignOrderToCustomerObserverTest.php b/app/code/Magento/Sales/Test/Unit/Observer/AssignOrderToCustomerObserverTest.php
index 18371274049e3..8890f01130c82 100644
--- a/app/code/Magento/Sales/Test/Unit/Observer/AssignOrderToCustomerObserverTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Observer/AssignOrderToCustomerObserverTest.php
@@ -52,9 +52,10 @@ protected function setUp()
*
* @dataProvider getCustomerIds
* @param null|int $customerId
+ * @param null|int $customerOrderId
* @return void
*/
- public function testAssignOrderToCustomerAfterGuestOrder($customerId)
+ public function testAssignOrderToCustomerAfterGuestOrder($customerId, $customerOrderId)
{
$orderId = 1;
/** @var Observer|PHPUnit_Framework_MockObject_MockObject $observerMock */
@@ -64,7 +65,12 @@ public function testAssignOrderToCustomerAfterGuestOrder($customerId)
->setMethods(['getData'])
->getMock();
/** @var CustomerInterface|PHPUnit_Framework_MockObject_MockObject $customerMock */
- $customerMock = $this->createMock(CustomerInterface::class);
+ $customerMock = $this->getMockBuilder(CustomerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+ $customerMock->expects($this->any())
+ ->method('getId')
+ ->willReturn($customerId);
/** @var OrderInterface|PHPUnit_Framework_MockObject_MockObject $orderMock */
$orderMock = $this->getMockBuilder(OrderInterface::class)
->disableOriginalConstructor()
@@ -75,13 +81,24 @@ public function testAssignOrderToCustomerAfterGuestOrder($customerId)
['delegate_data', null, ['__sales_assign_order_id' => $orderId]],
['customer_data_object', null, $customerMock]
]);
- $orderMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
+ $orderMock->expects($this->any())->method('getCustomerId')->willReturn($customerOrderId);
$this->orderRepositoryMock->expects($this->once())->method('get')->with($orderId)
->willReturn($orderMock);
- if ($customerId) {
+ if (!$customerOrderId && $customerId) {
+ $orderMock->expects($this->once())->method('setCustomerId')->willReturn($orderMock);
+ $orderMock->expects($this->once())->method('setCustomerIsGuest')->willReturn($orderMock);
+ $orderMock->expects($this->once())->method('setCustomerEmail')->willReturn($orderMock);
+ $orderMock->expects($this->once())->method('setCustomerFirstname')->willReturn($orderMock);
+ $orderMock->expects($this->once())->method('setCustomerLastname')->willReturn($orderMock);
+ $orderMock->expects($this->once())->method('setCustomerMiddlename')->willReturn($orderMock);
+ $orderMock->expects($this->once())->method('setCustomerPrefix')->willReturn($orderMock);
+ $orderMock->expects($this->once())->method('setCustomerSuffix')->willReturn($orderMock);
+ $orderMock->expects($this->once())->method('setCustomerGroupId')->willReturn($orderMock);
+
$this->assignmentMock->expects($this->once())->method('execute')->with($orderMock, $customerMock);
$this->sut->execute($observerMock);
+
return;
}
@@ -94,8 +111,12 @@ public function testAssignOrderToCustomerAfterGuestOrder($customerId)
*
* @return array
*/
- public function getCustomerIds()
+ public function getCustomerIds(): array
{
- return [[null, 1]];
+ return [
+ [null, null],
+ [1, null],
+ [1, 1],
+ ];
}
}
diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml
index a73740c249b67..b0b52b199978a 100644
--- a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml
+++ b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml
@@ -140,67 +140,76 @@