From 2c4dbba9111184299cba2935b26b23011566ee65 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 12 Dec 2015 21:21:17 +0200 Subject: [PATCH 001/455] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000000..7f0b245ab6b1e --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Login-As-Customer-for-Magento-2 +Allows admin to login as a customer (enter to customer account). From dd15e184efe63d3fa5ebdf6d7906ef5874b5fdf2 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 12 Dec 2015 21:26:13 +0200 Subject: [PATCH 002/455] Initial commit --- .../Block/Adminhtml/Customer/Edit/Login.php | 68 ++++++ .../LoginAsCustomer/Block/Adminhtml/Login.php | 26 +++ .../Adminhtml/System/Config/Form/Info.php | 52 +++++ .../Controller/Adminhtml/Login/Grid.php | 36 ++++ .../Controller/Adminhtml/Login/Index.php | 49 +++++ .../Controller/Adminhtml/Login/Login.php | 58 +++++ .../Controller/Login/Index.php | 65 ++++++ app/code/Magefan/LoginAsCustomer/LICENSE.txt | 48 +++++ .../Model/AdminNotificationFeed.php | 170 +++++++++++++++ .../Magefan/LoginAsCustomer/Model/Login.php | 201 ++++++++++++++++++ .../Model/ResourceModel/Login.php | 27 +++ .../Model/ResourceModel/Login/Collection.php | 28 +++ .../ResourceModel/Login/Grid/Collection.php | 49 +++++ ...redispathAdminActionControllerObserver.php | 55 +++++ app/code/Magefan/LoginAsCustomer/README.md | 1 + .../LoginAsCustomer/Setup/InstallSchema.php | 86 ++++++++ .../Magefan/LoginAsCustomer/composer.json | 21 ++ app/code/Magefan/LoginAsCustomer/etc/acl.xml | 30 +++ .../LoginAsCustomer/etc/adminhtml/events.xml | 14 ++ .../LoginAsCustomer/etc/adminhtml/menu.xml | 14 ++ .../LoginAsCustomer/etc/adminhtml/routes.xml | 16 ++ .../LoginAsCustomer/etc/adminhtml/system.xml | 28 +++ .../LoginAsCustomer/etc/frontend/routes.xml | 16 ++ .../Magefan/LoginAsCustomer/etc/module.xml | 16 ++ .../Magefan/LoginAsCustomer/registration.php | 13 ++ .../layout/loginascustomer_login_grid.xml | 16 ++ .../loginascustomer_login_grid_block.xml | 76 +++++++ .../layout/loginascustomer_login_index.xml | 18 ++ .../adminhtml/ui_component/customer_form.xml | 16 ++ 29 files changed, 1313 insertions(+) create mode 100755 app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php create mode 100755 app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php create mode 100755 app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php create mode 100755 app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php create mode 100755 app/code/Magefan/LoginAsCustomer/LICENSE.txt create mode 100755 app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php create mode 100755 app/code/Magefan/LoginAsCustomer/Model/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php create mode 100755 app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php create mode 100755 app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php create mode 100755 app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php create mode 100755 app/code/Magefan/LoginAsCustomer/README.md create mode 100755 app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php create mode 100755 app/code/Magefan/LoginAsCustomer/composer.json create mode 100755 app/code/Magefan/LoginAsCustomer/etc/acl.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml create mode 100755 app/code/Magefan/LoginAsCustomer/etc/module.xml create mode 100755 app/code/Magefan/LoginAsCustomer/registration.php create mode 100755 app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml create mode 100755 app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml create mode 100755 app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml create mode 100755 app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php new file mode 100755 index 0000000000000..fd184e8be3de1 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php @@ -0,0 +1,68 @@ +_authorization = $authorization; + } + + /** + * @return array + */ + public function getButtonData() + { + $customerId = $this->getCustomerId(); + $data = []; + $canModify = $customerId && $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + if ($canModify) { + $data = [ + 'label' => __('Login As Customer'), + 'class' => 'login login-button', + 'on_click' => 'window.open( \'' . $this->getInvalidateTokenUrl() . + '\')', + 'sort_order' => 70, + ]; + } + return $data; + } + + /** + * @return string + */ + public function getInvalidateTokenUrl() + { + return $this->getUrl('loginascustomer/login/login', ['customer_id' => $this->getCustomerId()]); + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php new file mode 100755 index 0000000000000..50216154da702 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php @@ -0,0 +1,26 @@ +removeButton('add'); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php new file mode 100755 index 0000000000000..ef7a8ed8cccf7 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php @@ -0,0 +1,52 @@ +moduleList = $moduleList; + } + + /** + * Return info block html + * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * @return string + */ + public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + { + $m = $this->moduleList->getOne($this->getModuleName()); + $html = '
+ Login As Customer Extension v' . $m['setup_version'] . ' was developed by MageFan. +
'; + + return $html; + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php new file mode 100755 index 0000000000000..d8182e2536a67 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php @@ -0,0 +1,36 @@ +_view->loadLayout(false); + $this->_view->renderLayout(); + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php new file mode 100755 index 0000000000000..515fdcbbd4517 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php @@ -0,0 +1,49 @@ +getRequest()->getParam('ajax')) { + $this->_forward('grid'); + return; + } + + $this->_objectManager + ->create('\Magefan\LoginAsCustomer\Model\Login') + ->deleteNotUsed(); + + $this->_view->loadLayout(); + $this->_setActiveMenu('Magefan_LoginAsCustomer::login_log'); + $title = __('Login As Customer Log '); + $this->_view->getPage()->getConfig()->getTitle()->prepend($title); + $this->_addBreadcrumb($title, $title); + $this->_view->renderLayout(); + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php new file mode 100755 index 0000000000000..84856552f4b44 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php @@ -0,0 +1,58 @@ +getRequest()->getParam('customer_id'); + + $login = $this->_objectManager + ->create('\Magefan\LoginAsCustomer\Model\Login') + ->setCustomerId($customerId); + + $login->deleteNotUsed(); + + $customer = $login->getCustomer(); + + if (!$customer->getId()) { + $this->messageManager->addError(__('Customer with this ID are no longer exist.')); + $this->_redirect('customer/index/index'); + return; + } + + $user = $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->getUser(); + $login->generate($user->getId()); + + $redirectUrl = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface') + ->getStore($customer->getStoreId()) + ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret()]); + + $this->getResponse()->setRedirect($redirectUrl); + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php b/app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php new file mode 100755 index 0000000000000..f03be149ad8bf --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php @@ -0,0 +1,65 @@ +_initLogin(); + if (!$login) { + $this->_redirect('/'); + return; + } + + try { + $login->authenticateCustomer(); + } catch (Exception $e) { + $this->messageManager->addError($e->getMessage()); + } + + $this->messageManager->addSuccess( + __('You are logged in as customer: %1', $login->getCustomer()->getName()) + ); + + $this->_redirect('customer/account'); + } + + /** + * Init login info + * @return false || \Magefan\LoginAsCustomer\Model\Login + */ + protected function _initLogin() + { + $secret = $this->getRequest()->getParam('secret'); + if (!$secret) { + $this->messageManager->addError(__('Cannot login to account. No secret key provided.')); + return false; + } + + $login = $this->_objectManager + ->create('\Magefan\LoginAsCustomer\Model\Login') + ->loadNotUsed($secret); + + if ($login->getId()) { + return $login; + } else { + $this->messageManager->addError(__('Cannot login to account. Secret key is not valid.')); + return false; + } + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/LICENSE.txt b/app/code/Magefan/LoginAsCustomer/LICENSE.txt new file mode 100755 index 0000000000000..49525fd99da9c --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/LICENSE.txt @@ -0,0 +1,48 @@ + +Open Software License ("OSL") v. 3.0 + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php b/app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php new file mode 100755 index 0000000000000..9e2125551ae71 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php @@ -0,0 +1,170 @@ +_backendAuthSession = $backendAuthSession; + $this->_moduleList = $moduleList; + $this->_moduleManager = $moduleManager; + } + + /** + * Retrieve feed url + * + * @return string + */ + public function getFeedUrl() + { + if (is_null($this->_feedUrl)) { + $this->_feedUrl = 'http://mage'.'fan' + .'.c'.'om/community/notifications'.'/'.'feed/'; + } + + $urlInfo = parse_url($this->urlBuilder->getBaseUrl()); + $domain = isset($urlInfo['host']) ? $urlInfo['host'] : ''; + + $url = $this->_feedUrl . 'domain/' . urlencode($domain); + + $modulesParams = array(); + foreach($this->getMagefanModules() as $key => $module) { + $key = str_replace('Magefan_', '', $key); + $modulesParams[] = $key . ',' . $module['setup_version']; + } + + if (count($modulesParams)) { + $url .= '/modules/'.base64_encode(implode(';', $modulesParams)); + } + + return $url; + } + + /** + * Get Magefan Modules Info + * + * @return $this + */ + protected function getMagefanModules() + { + $modules = array(); + foreach($this->_moduleList->getAll() as $moduleName => $module) { + if ( strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName) ) { + $modules[$moduleName] = $module; + } + } + + return $modules; + } + + /** + * Check feed for modification + * + * @return $this + */ + public function checkUpdate() + { + $session = $this->_backendAuthSession; + $time = time(); + $frequency = $this->getFrequency(); + if (($frequency + $session->getMfNoticeLastUpdate() > $time) + || ($frequency + $this->getLastUpdate() > $time) + ) { + return $this; + } + + $session->setMfNoticeLastUpdate($time); + return parent::checkUpdate(); + } + + /** + * Retrieve Update Frequency + * + * @return int + */ + public function getFrequency() + { + return 86400; + } + + /** + * Retrieve Last update time + * + * @return int + */ + public function getLastUpdate() + { + return $this->_cacheManager->load('magefan_admin_notifications_lastcheck'); + } + + /** + * Set last update time (now) + * + * @return $this + */ + public function setLastUpdate() + { + $this->_cacheManager->save(time(), 'magefan_admin_notifications_lastcheck'); + return $this; + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Model/Login.php b/app/code/Magefan/LoginAsCustomer/Model/Login.php new file mode 100755 index 0000000000000..58d02c0084474 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/Login.php @@ -0,0 +1,201 @@ +getEvent()->getObject() in this case + * + * @var string + */ + protected $_eventObject = 'loginascustomer_login'; + + /** + * @var \Magento\Customer\Model\CustomerFactory + */ + protected $_customerFactory; + + /** + * @var \Magento\Customer\Model\Customer + */ + protected $_customer; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $_eventManager; + + /** + * @var \Magento\Customer\Model\Session + */ + protected $_customerSession; + + /** + * @var \Magento\Framework\Stdlib\DateTime\DateTime + */ + protected $_dateTime; + + /** + * @var \Magento\Framework\Math\Random + */ + protected $_random; + + /** + * Initialize dependencies. + * + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Store\Model\StoreManagerInterface $eventManager + * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime + * @param \Magento\Framework\Math\Random $random + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param array $data + */ + public function __construct( + \Magento\Framework\Model\Context $context, + \Magento\Framework\Registry $registry, + \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Customer\Model\Session $customerSession, + \Magento\Store\Model\StoreManagerInterface $eventManager, + \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, + \Magento\Framework\Math\Random $random, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, + \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, + array $data = [] + ) { + $this->_customerFactory = $customerFactory; + $this->_customerSession = $customerSession; + $this->_eventManager = $eventManager; + $this->_dateTime = $dateTime; + $this->_random = $random; + parent::__construct($context, $registry, $resource, $resourceCollection, $data); + } + + /** + * Initialize resource model + * + * @return void + */ + protected function _construct() + { + $this->_init('Magefan\LoginAsCustomer\Model\ResourceModel\Login'); + } + + /** + * Retrieve not used admin login + * @param string $secret + * @return self + */ + public function loadNotUsed($secret) + { + return $this->getCollection() + ->addFieldToFilter('secret', $secret) + ->addFieldToFilter('used', 0) + ->addFieldToFilter('created_at', ['gt' => $this->getDateTimePoint()]) + ->setPageSize(1) + ->getFirstItem(); + } + + /** + * Delete not used credentials + * @return void + */ + public function deleteNotUsed() + { + $resource = $this->getResource(); + $resource->getConnection()->delete( + $resource->getTable('magefan_login_as_customer'), [ + 'created_at < ?' => $this->getDateTimePoint(), + 'used = ?' => 0, + ] + ); + } + + /** + * Retrieve login datetime point + * @return [type] [description] + */ + protected function getDateTimePoint() + { + return date('Y-m-d H:i:s', $this->_dateTime->gmtTimestamp() - self::TIME_FRAME); + } + + /** + * Retrieve customer + * @return \Magento\Customer\Model\Customer + */ + public function getCustomer() + { + if (is_null($this->_customer)) { + $this->_customer = $this->_customerFactory->create() + ->load($this->getCustomerId()); + } + return $this->_customer; + } + + /** + * Login Customer + * @return false || \Magento\Customer\Model\Customer + */ + public function authenticateCustomer() + { + $customer = $this->getCustomer(); + + if (!$customer->getId()) { + throw new Exception(__("Customer are no longer exist."), 1); + } + + $this->_eventManager->dispatch('customer_data_object_login', ['customer' => $customer]); + + $this->_customerSession->loginById($customer->getId()); + $this->_customerSession->regenerateId(); + + $this->setUsed(1)->save(); + + return $customer; + } + + /** + * Generate new login credentials + * @param int $adminId + * @return $this + */ + public function generate($adminId) + { + return $this->setData([ + 'customer_id' => $this->getCustomerId(), + 'admin_id' => $adminId, + 'secret' => $this->_random->getRandomString(64), + 'used' => 0, + 'created_at' => $this->_dateTime->gmtTimestamp(), + ])->save(); + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php new file mode 100755 index 0000000000000..0902b2b6c8ace --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php @@ -0,0 +1,27 @@ +_init('magefan_login_as_customer', 'login_id'); + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php new file mode 100755 index 0000000000000..25f6d5da09445 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php @@ -0,0 +1,28 @@ +_init('Magefan\LoginAsCustomer\Model\Login', 'Magefan\LoginAsCustomer\Model\ResourceModel\Login'); + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php new file mode 100755 index 0000000000000..79b5f4b7b0567 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php @@ -0,0 +1,49 @@ +_map['fields']['email'] = 'c.email'; + } + + /** + * Init collection select + * + * @return $this + */ + protected function _initSelect() + { + parent::_initSelect(); + $this->getSelect() + ->joinLeft( + array('c' => $this->getTable('customer_entity')), + 'c.entity_id = main_table.customer_id', + array('email') + )->joinLeft( + array('a' => $this->getTable('admin_user')), + 'a.user_id = main_table.admin_id', + array('username') + ); + return $this; + } + +} diff --git a/app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php b/app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php new file mode 100755 index 0000000000000..d89dd247d60c1 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php @@ -0,0 +1,55 @@ +_feedFactory = $feedFactory; + $this->_backendAuthSession = $backendAuthSession; + } + + /** + * Predispath admin action controller + * + * @param \Magento\Framework\Event\Observer $observer + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function execute(\Magento\Framework\Event\Observer $observer) + { + if ($this->_backendAuthSession->isLoggedIn()) { + $feedModel = $this->_feedFactory->create(); + /* @var $feedModel \Magefan\LoginAsCustomer\Model\AdminNotificationFeed */ + $feedModel->checkUpdate(); + } + } +} diff --git a/app/code/Magefan/LoginAsCustomer/README.md b/app/code/Magefan/LoginAsCustomer/README.md new file mode 100755 index 0000000000000..fcc244e87213a --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/README.md @@ -0,0 +1 @@ +The Magefan_LoginAsCustomer implements allow to admins login as customer. \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php b/app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php new file mode 100755 index 0000000000000..a802c3d5e8c2f --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php @@ -0,0 +1,86 @@ +startSetup(); + + /** + * Create table 'magefan_login_as_customer' + */ + $table = $installer->getConnection()->newTable( + $installer->getTable('magefan_login_as_customer') + )->addColumn( + 'login_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['identity' => true, 'nullable' => false, 'primary' => true], + 'Admin Login ID' + )->addColumn( + 'customer_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['nullable' => true], + 'Customer ID' + )->addColumn( + 'admin_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['nullable' => true], + 'Admin ID' + )->addColumn( + 'secret', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + '64', + ['nullable' => true], + 'Login Secret' + )->addColumn( + 'used', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + ['nullable' => false, 'default' => '1'], + 'Is Login Used' + )->addColumn( + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + [], + 'Creation Time' + )->addIndex( + $installer->getIdxName('magefan_login_as_customer', ['customer_id']), + ['customer_id'] + ) + ->addIndex( + $installer->getIdxName('magefan_login_as_customer', ['admin_id']), + ['admin_id'] + )->setComment( + 'Magefan Login As Customer Table' + ); + $installer->getConnection()->createTable($table); + + $installer->endSetup(); + } +} diff --git a/app/code/Magefan/LoginAsCustomer/composer.json b/app/code/Magefan/LoginAsCustomer/composer.json new file mode 100755 index 0000000000000..e6875b595dcfa --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/composer.json @@ -0,0 +1,21 @@ +{ + "name": "magefan/module-loginascustomer", + "description": "N/A", + "require": { + "php": "~5.5.0|~5.6.0|~7.0.0", + "magento/module-customer": "100.0.0", + "magento/framework": "100.0.0" + }, + "type": "magento2-module", + "version": "2.0.0", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ "registration.php" ], + "psr-4": { + "Magefan\\LoginAsCustomer\\": "" + } + } +} diff --git a/app/code/Magefan/LoginAsCustomer/etc/acl.xml b/app/code/Magefan/LoginAsCustomer/etc/acl.xml new file mode 100755 index 0000000000000..948f8f61ca801 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/acl.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml new file mode 100755 index 0000000000000..ecbc7cf570d4c --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml new file mode 100755 index 0000000000000..5a4b630dc5844 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml new file mode 100755 index 0000000000000..75d00df9b72a5 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml @@ -0,0 +1,16 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml new file mode 100755 index 0000000000000..7a0d7ef443200 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml @@ -0,0 +1,28 @@ + + + + + + + +
+ separator-top + + magefan + Magefan_LoginAsCustomer::config_section + + + + Magefan\LoginAsCustomer\Block\Adminhtml\System\Config\Form\Info + + +
+
+
diff --git a/app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml b/app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml new file mode 100755 index 0000000000000..00b11bb15f560 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml @@ -0,0 +1,16 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/etc/module.xml b/app/code/Magefan/LoginAsCustomer/etc/module.xml new file mode 100755 index 0000000000000..001e8e18ea990 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/etc/module.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/registration.php b/app/code/Magefan/LoginAsCustomer/registration.php new file mode 100755 index 0000000000000..f8fc94bd8b290 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/registration.php @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml b/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml new file mode 100755 index 0000000000000..aba5c109be8f5 --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml @@ -0,0 +1,76 @@ + + + + + + + + subscriberGrid + Magefan\LoginAsCustomer\Model\ResourceModel\Login\Grid\Collection + created_at + desc + 1 + + + + + + ID + login_id + col-id + col-id + + + + + Customer ID + customer_id + col-title + col-title + + + + + Customer Email + email + col-title + col-title + + + + + Admin ID + admin_id + col-title + col-title + + + + + Admin Name + username + col-title + col-title + + + + + Logged In + created_at + datetime + col-first-name + col-first-name + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml b/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml new file mode 100755 index 0000000000000..471d96ee418bd --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml b/app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml new file mode 100755 index 0000000000000..a5975968b23bf --- /dev/null +++ b/app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml @@ -0,0 +1,16 @@ + + +
+ + + Magefan\LoginAsCustomer\Block\Adminhtml\Customer\Edit\Login + + +
From 09c2e9be62fd5ff844b3086fea6fdf5b64325a6d Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 26 Mar 2016 10:42:17 +0200 Subject: [PATCH 003/455] Fix error during compilation --- .../LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php index fd184e8be3de1..429dad71eec8c 100755 --- a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php +++ b/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php @@ -30,11 +30,10 @@ class Login extends GenericButton implements ButtonProviderInterface */ public function __construct( \Magento\Backend\Block\Widget\Context $context, - \Magento\Framework\Registry $registry, - \Magento\Framework\AuthorizationInterface $authorization + \Magento\Framework\Registry $registry ) { parent::__construct($context, $registry); - $this->_authorization = $authorization; + $this->_authorization = $context->getAuthorization(); } /** From 8c2fb35a0ff87305b72da0b305b85079bd152a4d Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Thu, 2 Jun 2016 21:56:15 +0300 Subject: [PATCH 004/455] Move project to root --- .../Block => Block}/Adminhtml/Customer/Edit/Login.php | 0 .../Magefan/LoginAsCustomer/Block => Block}/Adminhtml/Login.php | 0 .../Block => Block}/Adminhtml/System/Config/Form/Info.php | 0 .../Controller => Controller}/Adminhtml/Login/Grid.php | 0 .../Controller => Controller}/Adminhtml/Login/Index.php | 0 .../Controller => Controller}/Adminhtml/Login/Login.php | 0 .../LoginAsCustomer/Controller => Controller}/Login/Index.php | 0 app/code/Magefan/LoginAsCustomer/LICENSE.txt => LICENSE.txt | 0 .../LoginAsCustomer/Model => Model}/AdminNotificationFeed.php | 0 {app/code/Magefan/LoginAsCustomer/Model => Model}/Login.php | 0 .../LoginAsCustomer/Model => Model}/ResourceModel/Login.php | 0 .../Model => Model}/ResourceModel/Login/Collection.php | 0 .../Model => Model}/ResourceModel/Login/Grid/Collection.php | 0 .../PredispathAdminActionControllerObserver.php | 0 .../Magefan/LoginAsCustomer/Setup => Setup}/InstallSchema.php | 0 app/code/Magefan/LoginAsCustomer/README.md | 1 - app/code/Magefan/LoginAsCustomer/composer.json => composer.json | 0 {app/code/Magefan/LoginAsCustomer/etc => etc}/acl.xml | 0 .../Magefan/LoginAsCustomer/etc => etc}/adminhtml/events.xml | 0 {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/menu.xml | 0 .../Magefan/LoginAsCustomer/etc => etc}/adminhtml/routes.xml | 0 .../Magefan/LoginAsCustomer/etc => etc}/adminhtml/system.xml | 0 .../code/Magefan/LoginAsCustomer/etc => etc}/frontend/routes.xml | 0 {app/code/Magefan/LoginAsCustomer/etc => etc}/module.xml | 0 .../Magefan/LoginAsCustomer/registration.php => registration.php | 0 .../adminhtml/layout/loginascustomer_login_grid.xml | 0 .../adminhtml/layout/loginascustomer_login_grid_block.xml | 0 .../adminhtml/layout/loginascustomer_login_index.xml | 0 .../view => view}/adminhtml/ui_component/customer_form.xml | 0 29 files changed, 1 deletion(-) rename {app/code/Magefan/LoginAsCustomer/Block => Block}/Adminhtml/Customer/Edit/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Block => Block}/Adminhtml/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Block => Block}/Adminhtml/System/Config/Form/Info.php (100%) rename {app/code/Magefan/LoginAsCustomer/Controller => Controller}/Adminhtml/Login/Grid.php (100%) rename {app/code/Magefan/LoginAsCustomer/Controller => Controller}/Adminhtml/Login/Index.php (100%) rename {app/code/Magefan/LoginAsCustomer/Controller => Controller}/Adminhtml/Login/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Controller => Controller}/Login/Index.php (100%) rename app/code/Magefan/LoginAsCustomer/LICENSE.txt => LICENSE.txt (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/AdminNotificationFeed.php (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/ResourceModel/Login.php (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/ResourceModel/Login/Collection.php (100%) rename {app/code/Magefan/LoginAsCustomer/Model => Model}/ResourceModel/Login/Grid/Collection.php (100%) rename {app/code/Magefan/LoginAsCustomer/Observer => Observer}/PredispathAdminActionControllerObserver.php (100%) rename {app/code/Magefan/LoginAsCustomer/Setup => Setup}/InstallSchema.php (100%) delete mode 100755 app/code/Magefan/LoginAsCustomer/README.md rename app/code/Magefan/LoginAsCustomer/composer.json => composer.json (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/acl.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/events.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/menu.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/routes.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/adminhtml/system.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/frontend/routes.xml (100%) rename {app/code/Magefan/LoginAsCustomer/etc => etc}/module.xml (100%) rename app/code/Magefan/LoginAsCustomer/registration.php => registration.php (100%) rename {app/code/Magefan/LoginAsCustomer/view => view}/adminhtml/layout/loginascustomer_login_grid.xml (100%) rename {app/code/Magefan/LoginAsCustomer/view => view}/adminhtml/layout/loginascustomer_login_grid_block.xml (100%) rename {app/code/Magefan/LoginAsCustomer/view => view}/adminhtml/layout/loginascustomer_login_index.xml (100%) rename {app/code/Magefan/LoginAsCustomer/view => view}/adminhtml/ui_component/customer_form.xml (100%) diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php b/Block/Adminhtml/Customer/Edit/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php rename to Block/Adminhtml/Customer/Edit/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php b/Block/Adminhtml/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Block/Adminhtml/Login.php rename to Block/Adminhtml/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Block/Adminhtml/System/Config/Form/Info.php rename to Block/Adminhtml/System/Config/Form/Info.php diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php b/Controller/Adminhtml/Login/Grid.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php rename to Controller/Adminhtml/Login/Grid.php diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php b/Controller/Adminhtml/Login/Index.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Index.php rename to Controller/Adminhtml/Login/Index.php diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Controller/Adminhtml/Login/Login.php rename to Controller/Adminhtml/Login/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php b/Controller/Login/Index.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Controller/Login/Index.php rename to Controller/Login/Index.php diff --git a/app/code/Magefan/LoginAsCustomer/LICENSE.txt b/LICENSE.txt similarity index 100% rename from app/code/Magefan/LoginAsCustomer/LICENSE.txt rename to LICENSE.txt diff --git a/app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/AdminNotificationFeed.php rename to Model/AdminNotificationFeed.php diff --git a/app/code/Magefan/LoginAsCustomer/Model/Login.php b/Model/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/Login.php rename to Model/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php b/Model/ResourceModel/Login.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login.php rename to Model/ResourceModel/Login.php diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php b/Model/ResourceModel/Login/Collection.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Collection.php rename to Model/ResourceModel/Login/Collection.php diff --git a/app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php b/Model/ResourceModel/Login/Grid/Collection.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php rename to Model/ResourceModel/Login/Grid/Collection.php diff --git a/app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php b/Observer/PredispathAdminActionControllerObserver.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Observer/PredispathAdminActionControllerObserver.php rename to Observer/PredispathAdminActionControllerObserver.php diff --git a/app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php b/Setup/InstallSchema.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/Setup/InstallSchema.php rename to Setup/InstallSchema.php diff --git a/app/code/Magefan/LoginAsCustomer/README.md b/app/code/Magefan/LoginAsCustomer/README.md deleted file mode 100755 index fcc244e87213a..0000000000000 --- a/app/code/Magefan/LoginAsCustomer/README.md +++ /dev/null @@ -1 +0,0 @@ -The Magefan_LoginAsCustomer implements allow to admins login as customer. \ No newline at end of file diff --git a/app/code/Magefan/LoginAsCustomer/composer.json b/composer.json similarity index 100% rename from app/code/Magefan/LoginAsCustomer/composer.json rename to composer.json diff --git a/app/code/Magefan/LoginAsCustomer/etc/acl.xml b/etc/acl.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/acl.xml rename to etc/acl.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml b/etc/adminhtml/events.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/adminhtml/events.xml rename to etc/adminhtml/events.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/adminhtml/menu.xml rename to etc/adminhtml/menu.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/adminhtml/routes.xml rename to etc/adminhtml/routes.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml b/etc/adminhtml/system.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/adminhtml/system.xml rename to etc/adminhtml/system.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml b/etc/frontend/routes.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/frontend/routes.xml rename to etc/frontend/routes.xml diff --git a/app/code/Magefan/LoginAsCustomer/etc/module.xml b/etc/module.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/etc/module.xml rename to etc/module.xml diff --git a/app/code/Magefan/LoginAsCustomer/registration.php b/registration.php similarity index 100% rename from app/code/Magefan/LoginAsCustomer/registration.php rename to registration.php diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml b/view/adminhtml/layout/loginascustomer_login_grid.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml rename to view/adminhtml/layout/loginascustomer_login_grid.xml diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml b/view/adminhtml/layout/loginascustomer_login_grid_block.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml rename to view/adminhtml/layout/loginascustomer_login_grid_block.xml diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml b/view/adminhtml/layout/loginascustomer_login_index.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml rename to view/adminhtml/layout/loginascustomer_login_index.xml diff --git a/app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml b/view/adminhtml/ui_component/customer_form.xml similarity index 100% rename from app/code/Magefan/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml rename to view/adminhtml/ui_component/customer_form.xml From 148a0629ee122cca83d55866852a3eed629225f6 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Thu, 2 Jun 2016 22:01:52 +0300 Subject: [PATCH 005/455] Change composer.json --- composer.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/composer.json b/composer.json index e6875b595dcfa..baa9b1d03dccb 100755 --- a/composer.json +++ b/composer.json @@ -1,11 +1,6 @@ { - "name": "magefan/module-loginascustomer", + "name": "magefan/module-login-as-customer", "description": "N/A", - "require": { - "php": "~5.5.0|~5.6.0|~7.0.0", - "magento/module-customer": "100.0.0", - "magento/framework": "100.0.0" - }, "type": "magento2-module", "version": "2.0.0", "license": [ From ea534dfc8314efddd5d04f1dff1b4fb52744c01e Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Thu, 2 Jun 2016 22:48:39 +0300 Subject: [PATCH 006/455] Fix issue: after login as customer admin session expire --- Controller/Adminhtml/Login/Login.php | 16 ++++++++-------- Model/Login.php | 14 +++----------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php index 84856552f4b44..59f23603a6a18 100755 --- a/Controller/Adminhtml/Login/Login.php +++ b/Controller/Adminhtml/Login/Login.php @@ -13,14 +13,14 @@ */ class Login extends \Magento\Backend\App\Action { - /** + /** * Login as customer action * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { - $customerId = (int) $this->getRequest()->getParam('customer_id'); + $customerId = (int) $this->getRequest()->getParam('customer_id'); $login = $this->_objectManager ->create('\Magefan\LoginAsCustomer\Model\Login') @@ -30,18 +30,18 @@ public function execute() $customer = $login->getCustomer(); - if (!$customer->getId()) { - $this->messageManager->addError(__('Customer with this ID are no longer exist.')); - $this->_redirect('customer/index/index'); - return; - } + if (!$customer->getId()) { + $this->messageManager->addError(__('Customer with this ID are no longer exist.')); + $this->_redirect('customer/index/index'); + return; + } $user = $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->getUser(); $login->generate($user->getId()); $redirectUrl = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface') ->getStore($customer->getStoreId()) - ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret()]); + ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); $this->getResponse()->setRedirect($redirectUrl); } diff --git a/Model/Login.php b/Model/Login.php index 58d02c0084474..cbfb9a02955f4 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -44,10 +44,6 @@ class Login extends \Magento\Framework\Model\AbstractModel */ protected $_customer; - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $_eventManager; /** * @var \Magento\Customer\Model\Session @@ -71,7 +67,6 @@ class Login extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Store\Model\StoreManagerInterface $eventManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime * @param \Magento\Framework\Math\Random $random * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource @@ -83,7 +78,6 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\Session $customerSession, - \Magento\Store\Model\StoreManagerInterface $eventManager, \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, \Magento\Framework\Math\Random $random, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, @@ -92,7 +86,6 @@ public function __construct( ) { $this->_customerFactory = $customerFactory; $this->_customerSession = $customerSession; - $this->_eventManager = $eventManager; $this->_dateTime = $dateTime; $this->_random = $random; parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -172,10 +165,9 @@ public function authenticateCustomer() throw new Exception(__("Customer are no longer exist."), 1); } - $this->_eventManager->dispatch('customer_data_object_login', ['customer' => $customer]); - - $this->_customerSession->loginById($customer->getId()); - $this->_customerSession->regenerateId(); + if ($this->_customerSession->loginById($customer->getId())) { + $this->_customerSession->regenerateId(); + } $this->setUsed(1)->save(); From 0af073e1319c65c643ce6a359af079fb685c8248 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 4 Jun 2016 11:15:30 +0300 Subject: [PATCH 007/455] Up version to 2.0.1 --- composer.json | 2 +- etc/module.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index baa9b1d03dccb..f756fef698590 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magefan/module-login-as-customer", "description": "N/A", "type": "magento2-module", - "version": "2.0.0", + "version": "2.0.1", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index 001e8e18ea990..94fd8a5dede01 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 3dabd5c3b3c5da55ae1b1d466701fa98e1d7b1cb Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Thu, 9 Jun 2016 23:56:01 +0300 Subject: [PATCH 008/455] Fix issue: customer data is not updated after login --- Controller/Login/Index.php | 4 +-- Controller/Login/Post.php | 25 ++++++++++++++++++ Controller/Login/Proceed.php | 26 +++++++++++++++++++ etc/frontend/sections.xml | 13 ++++++++++ .../layout/loginascustomer_login_proceed.xml | 21 +++++++++++++++ view/frontend/templates/login.phtml | 22 ++++++++++++++++ 6 files changed, 109 insertions(+), 2 deletions(-) create mode 100755 Controller/Login/Post.php create mode 100755 Controller/Login/Proceed.php create mode 100644 etc/frontend/sections.xml create mode 100644 view/frontend/layout/loginascustomer_login_proceed.xml create mode 100644 view/frontend/templates/login.phtml diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index f03be149ad8bf..e8d1cf7eb19c7 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -1,6 +1,6 @@ getCustomer()->getName()) ); - $this->_redirect('customer/account'); + $this->_redirect('*/*/proceed'); } /** diff --git a/Controller/Login/Post.php b/Controller/Login/Post.php new file mode 100755 index 0000000000000..d6b144eacd301 --- /dev/null +++ b/Controller/Login/Post.php @@ -0,0 +1,25 @@ +_redirect('customer/account'); + } + +} diff --git a/Controller/Login/Proceed.php b/Controller/Login/Proceed.php new file mode 100755 index 0000000000000..a78108c163113 --- /dev/null +++ b/Controller/Login/Proceed.php @@ -0,0 +1,26 @@ +_view->loadLayout(); + $this->_view->renderLayout(); + } + +} diff --git a/etc/frontend/sections.xml b/etc/frontend/sections.xml new file mode 100644 index 0000000000000..e3569fb0a914e --- /dev/null +++ b/etc/frontend/sections.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/view/frontend/layout/loginascustomer_login_proceed.xml b/view/frontend/layout/loginascustomer_login_proceed.xml new file mode 100644 index 0000000000000..78da65f40ea6d --- /dev/null +++ b/view/frontend/layout/loginascustomer_login_proceed.xml @@ -0,0 +1,21 @@ + + + + + + + You are logged in. + + + + + + + \ No newline at end of file diff --git a/view/frontend/templates/login.phtml b/view/frontend/templates/login.phtml new file mode 100644 index 0000000000000..263edc462de17 --- /dev/null +++ b/view/frontend/templates/login.phtml @@ -0,0 +1,22 @@ + +

+
+ +
+ From fba97888de81bc1df017d9c56dfe5efcd3ba5098 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Tue, 14 Jun 2016 22:47:24 +0300 Subject: [PATCH 009/455] Hide button until waiting login --- view/frontend/templates/login.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/frontend/templates/login.phtml b/view/frontend/templates/login.phtml index 263edc462de17..0ffc6c83dc7df 100644 --- a/view/frontend/templates/login.phtml +++ b/view/frontend/templates/login.phtml @@ -8,7 +8,7 @@ ?>

- +
diff --git a/app/code/Magento/Paypal/view/frontend/web/js/in-context/express-checkout.js b/app/code/Magento/Paypal/view/frontend/web/js/in-context/express-checkout.js deleted file mode 100644 index 7ffb6515b5e46..0000000000000 --- a/app/code/Magento/Paypal/view/frontend/web/js/in-context/express-checkout.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'underscore', - 'jquery', - 'uiComponent', - 'domReady!' -], function (_, $, Component) { - 'use strict'; - - return Component.extend({ - - defaults: { - clientConfig: { - - checkoutInited: false, - - /** - * @param {Object} event - */ - click: function (event) { - $('body').trigger('processStart'); - - event.preventDefault(); - - if (!this.clientConfig.checkoutInited) { - this.clientConfig.checkoutInited = true; - } - } - } - }, - - /** - * @returns {Object} - */ - initialize: function () { - this._super(); - - return this.initClient(); - }, - - /** - * @returns {Object} - */ - initClient: function () { - _.each(this.clientConfig, function (fn, name) { - if (typeof fn === 'function') { - this.clientConfig[name] = fn.bind(this); - } - }, this); - - return this; - } - }); -}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/in-context/express-checkout.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/in-context/express-checkout.test.js deleted file mode 100644 index 0420256e20ef5..0000000000000 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/in-context/express-checkout.test.js +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -/* eslint-disable max-nested-callbacks */ -define([ - 'squire', - 'jquery' -], function (Squire, $) { - 'use strict'; - - describe('Magento_Paypal/js/in-context/express-checkout', function () { - - var model, - event, - paypalExpressCheckout, - injector = new Squire(), - mocks = { - 'paypalInContextExpressCheckout': { - checkout: jasmine.createSpyObj('checkout', - ['setup', 'initXO', 'startFlow', 'closeFlow'] - ) - }, - 'Magento_Customer/js/customer-data': { - set: jasmine.createSpy(), - invalidate: jasmine.createSpy() - } - }; - - /** - * Run before each test method - * - * @return void - */ - beforeEach(function (done) { - event = { - /** Stub */ - preventDefault: jasmine.createSpy('preventDefault') - }; - - injector.mock(mocks); - - injector.require([ - 'paypalInContextExpressCheckout', - 'Magento_Paypal/js/in-context/express-checkout'], function (PayPal, Constr) { - paypalExpressCheckout = PayPal; - model = new Constr(); - - done(); - }); - }); - - afterEach(function () { - try { - injector.clean(); - injector.remove(); - } catch (e) {} - }); - - describe('clientConfig.click method', function () { - - it('Check for properties defined ', function () { - expect(model.hasOwnProperty('clientConfig')).toBeDefined(); - expect(model.clientConfig.hasOwnProperty('click')).toBeDefined(); - expect(model.clientConfig.hasOwnProperty('checkoutInited')).toBeDefined(); - }); - - it('Check properties type', function () { - expect(typeof model.clientConfig.checkoutInited).toEqual('boolean'); - expect(typeof model.clientConfig.click).toEqual('function'); - }); - - it('Check properties value', function () { - expect(model.clientConfig.checkoutInited).toEqual(false); - }); - - it('Check call "click" method', function () { - - spyOn(jQuery.fn, 'trigger'); - spyOn(jQuery, 'get').and.callFake(function () { - var d = $.Deferred(); - - d.resolve({ - 'url': true - }); - - return d.promise(); - }); - - model.clientConfig.click(event); - - expect(event.preventDefault).toHaveBeenCalled(); - expect(paypalExpressCheckout.checkout.initXO).toHaveBeenCalled(); - expect(model.clientConfig.checkoutInited).toEqual(true); - expect(jQuery.get).toHaveBeenCalled(); - expect(jQuery('body').trigger).toHaveBeenCalledWith( - jasmine.arrayContaining(['processStart'], ['processStop']) - ); - }); - - it('Check call "click" method', function () { - var message = { - text: 'text', - type: 'error' - }; - - spyOn(jQuery.fn, 'trigger'); - spyOn(jQuery, 'get').and.callFake(function () { - var d = $.Deferred(); - - d.resolve({ - message: message - }); - - return d.promise(); - }); - - model.clientConfig.click(event); - expect(mocks['Magento_Customer/js/customer-data'].set).toHaveBeenCalledWith('messages', { - messages: [message] - }); - expect(event.preventDefault).toHaveBeenCalled(); - expect(paypalExpressCheckout.checkout.initXO).toHaveBeenCalled(); - expect(model.clientConfig.checkoutInited).toEqual(true); - expect(jQuery.get).toHaveBeenCalled(); - expect(jQuery('body').trigger).toHaveBeenCalledWith( - jasmine.arrayContaining(['processStart'], ['processStop']) - ); - }); - }); - }); -}); From 676e037e28485f53063e2a05d08f43098b42c850 Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" Date: Tue, 14 Apr 2020 18:21:43 +0300 Subject: [PATCH 130/455] MC-32864: Forgot Password redirect issue - with shared website accounts --- .../_files/customer_for_second_website.php | 40 +++++++++++++++++++ .../customer_for_second_website_rollback.php | 28 +++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website.php new file mode 100644 index 0000000000000..c4df3e9fc8137 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website.php @@ -0,0 +1,40 @@ +get(AccountManagementInterface::class); +/** @var CustomerFactory $customerFactory */ +$customerFactory = $objectManager->get(CustomerFactory::class); +/** @var AttributeRepository $attributeRepository */ +$attributeRepository = $objectManager->get(AttributeRepository::class); +$gender = $attributeRepository->get(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, CustomerInterface::GENDER) + ->getSource()->getOptionId('Male'); +$defaultGroupId = $objectManager->get(GroupManagement::class)->getDefaultGroup($store->getStoreId())->getId(); + +$customer = $customerFactory->create(); +$customer->setWebsiteId($websiteId) + ->setEmail('customer@example.com') + ->setGroupId($defaultGroupId) + ->setStoreId($store->getStoreId()) + ->setFirstname('John') + ->setLastname('Smith') + ->setDefaultBilling(1) + ->setDefaultShipping(1) + ->setGender($gender); + +$accountManagment->createAccount($customer, 'Apassword1'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website_rollback.php new file mode 100644 index 0000000000000..2d2bd7b4587d3 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website_rollback.php @@ -0,0 +1,28 @@ +get(CustomerRepositoryInterface::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +try { + $customer = $customerRepository->get('customer@example.com', $websiteId); + $customerRepository->delete($customer); +} catch (NoSuchEntityException $e) { + //customer already deleted +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); From 4b22ea686a48db0338cbc8f89d3d70495865f21f Mon Sep 17 00:00:00 2001 From: Viktor Petryk Date: Tue, 14 Apr 2020 18:42:34 +0300 Subject: [PATCH 131/455] MC-32197: The Video related mftf tests are failed due "Daily limit exceeded" error --- .../Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml | 2 +- .../AdminAddRemoveDefaultVideoDownloadableProductTest.xml | 2 +- .../Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml | 2 +- .../Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml | 4 ++-- .../Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename app/code/Magento/{Bundle => ProductVideo}/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml (98%) rename app/code/Magento/{Downloadable => ProductVideo}/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml (97%) rename app/code/Magento/{GroupedProduct => ProductVideo}/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml (97%) rename app/code/Magento/{Catalog => ProductVideo}/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml (96%) rename app/code/Magento/{Catalog => ProductVideo}/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml (98%) diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml similarity index 98% rename from app/code/Magento/Bundle/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml rename to app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml index 3ce17ecc4155c..f7a80ba3c8739 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - + <description value="Admin should be able to add/remove default product video for a Bundle Product"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml similarity index 97% rename from app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml rename to app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml index 758ad6696a81a..47843c45aa32a 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddRemoveDefaultVideoDownloadableProductTest" extends="AdminAddRemoveDefaultVideoSimpleProductTest"> <annotations> - <features value="Downloadable"/> + <features value="ProductVideo"/> <stories value="Add/remove images and videos for all product types and category"/> <title value="Admin should be able to add/remove default product video for a Downloadable Product"/> <description value="Admin should be able to add/remove default product video for a Downloadable Product"/> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml similarity index 97% rename from app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml rename to app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml index 6a401a7b7cdee..bc64e9eed1050 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddRemoveDefaultVideoGroupedProductTest" extends="AdminAddRemoveDefaultVideoSimpleProductTest"> <annotations> - <features value="GroupedProduct"/> + <features value="ProductVideo"/> <stories value="Add/remove images and videos for all product types and category"/> <title value="Admin should be able to add/remove default product video for a Grouped Product"/> <description value="Admin should be able to add/remove default product video for a Grouped Product"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml similarity index 96% rename from app/code/Magento/Catalog/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml rename to app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml index 695cf919e513b..430d8e30da984 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddRemoveDefaultVideoSimpleProductTest"> <annotations> - <features value="Catalog"/> + <features value="ProductVideo"/> <stories value="Add/remove images and videos for all product types and category"/> <title value="Admin should be able to add/remove default product video for a Simple Product"/> <description value="Admin should be able to add/remove default product video for a Simple Product"/> @@ -23,7 +23,7 @@ <createData entity="ProductVideoYoutubeApiKeyConfig" stepKey="setYoutubeApiKeyConfig"/> <createData entity="SimpleProduct2" stepKey="createProduct"/> <!-- Login to Admin page --> - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> <createData entity="DefaultProductVideoConfig" stepKey="setYoutubeApiKeyDefaultConfig"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml similarity index 98% rename from app/code/Magento/Catalog/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml rename to app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml index e6a48f0c32d31..d614a66cf5cc0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddRemoveDefaultVideoVirtualProductTest" extends="AdminAddRemoveDefaultVideoSimpleProductTest"> <annotations> - <features value="Catalog"/> + <features value="ProductVideo"/> <stories value="Add/remove images and videos for all product types and category"/> <title value="Admin should be able to add/remove default product video for a Virtual Product"/> <description value="Admin should be able to add/remove default product video for a Virtual Product"/> From 30ce748b8dc0b0e61fcd86f65b19014be91ffea4 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Tue, 14 Apr 2020 15:38:52 -0500 Subject: [PATCH 132/455] magento/magento2#27499: Code review fixes --- .../MediaGallery/Model/Asset/Command/Save.php | 47 +++++-------------- .../MediaGallery/Model/Directory/Config.php | 19 ++------ .../Model/Directory/IsBlacklisted.php | 11 +++-- .../Model/ResourceModel/SaveAssets.php | 45 +++++------------- .../Model/Directory/IsBlacklistedTest.php | 7 +-- app/code/Magento/MediaGallery/etc/di.xml | 2 + .../Api/CreateDirectoriesByPathsInterface.php | 1 + .../Api/DeleteDirectoriesByPathsInterface.php | 1 + .../Api/IsPathBlacklistedInterface.php | 4 +- .../Api/SaveAssetsInterface.php | 1 + .../Api/SaveAssetsKeywordsInterface.php | 1 + .../BlacklistPatternsConfigInterface.php | 20 ++++++++ ...or.php => RemoveAssetAfterRemoveImage.php} | 2 +- ...hp => RemoveAssetAfterRemoveImageTest.php} | 8 ++-- .../Magento/MediaGalleryCatalog/etc/di.xml | 3 +- 15 files changed, 74 insertions(+), 98 deletions(-) create mode 100644 app/code/Magento/MediaGalleryApi/Model/BlacklistPatternsConfigInterface.php rename app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/{Processor.php => RemoveAssetAfterRemoveImage.php} (98%) rename app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/{ProcessorTest.php => RemoveAssetAfterRemoveImageTest.php} (94%) diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php index 0ce0d0c18e6d2..b445e9000313c 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php @@ -28,11 +28,6 @@ class Save implements SaveInterface */ private $resourceConnection; - /** - * @var DataObjectProcessor - */ - private $objectProcessor; - /** * @var LoggerInterface */ @@ -42,16 +37,13 @@ class Save implements SaveInterface * Save constructor. * * @param ResourceConnection $resourceConnection - * @param DataObjectProcessor $objectProcessor * @param LoggerInterface $logger */ public function __construct( ResourceConnection $resourceConnection, - DataObjectProcessor $objectProcessor, LoggerInterface $logger ) { $this->resourceConnection = $resourceConnection; - $this->objectProcessor = $objectProcessor; $this->logger = $logger; } @@ -72,37 +64,24 @@ public function execute(AssetInterface $mediaAsset): int $connection->insertOnDuplicate( $tableName, - $this->filterData($this->objectProcessor->buildOutputDataArray($mediaAsset, AssetInterface::class)) + [ + 'id' => $mediaAsset->getId(), + 'path' => $mediaAsset->getPath(), + 'title' => $mediaAsset->getTitle(), + 'source' => $mediaAsset->getSource(), + 'content_type' => $mediaAsset->getContentType(), + 'width' => $mediaAsset->getWidth(), + 'height' => $mediaAsset->getHeight(), + 'size' => $mediaAsset->getSize(), + 'created_at' => $mediaAsset->getCreatedAt(), + 'updated_at' => $mediaAsset->getUpdatedAt(), + ] ); - return (int) $connection->lastInsertId($tableName); + return (int)$connection->lastInsertId($tableName); } catch (\Exception $exception) { $this->logger->critical($exception); $message = __('An error occurred during media asset save: %1', $exception->getMessage()); throw new CouldNotSaveException($message, $exception); } } - - /** - * Filter data to get flat array without null values - * - * @param array $data - * @return array - */ - private function filterData(array $data): array - { - $filteredData = []; - foreach ($data as $key => $value) { - if ($value === null) { - continue; - } - if (is_array($value)) { - continue; - } - if (is_object($value)) { - continue; - } - $filteredData[$key] = $value; - } - return $filteredData; - } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config.php b/app/code/Magento/MediaGallery/Model/Directory/Config.php index 46314be9edfc1..67695080b185f 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config.php @@ -8,11 +8,12 @@ namespace Magento\MediaGallery\Model\Directory; use Magento\Framework\Config\DataInterface; +use Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface; /** * Media gallery directory config */ -class Config +class Config implements BlacklistPatternsConfigInterface { private const XML_PATH_BLACKLIST_PATTERNS = 'blacklist/patterns'; @@ -29,25 +30,13 @@ public function __construct(DataInterface $data) $this->data = $data; } - /** - * Get config value by key. - * - * @param string|null $key - * @param string|null $default - * @return array - */ - public function get($key = null, $default = null) - { - return $this->data->get($key, $default); - } - /** * Returns list of blacklist regexp patterns * * @return array */ - public function getBlacklistPatterns() : array + public function get() : array { - return $this->get(self::XML_PATH_BLACKLIST_PATTERNS); + return $this->data->get(self::XML_PATH_BLACKLIST_PATTERNS); } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php index d2e59b5613b4a..4ca7527ef724b 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php +++ b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php @@ -8,6 +8,7 @@ namespace Magento\MediaGallery\Model\Directory; use Magento\MediaGalleryApi\Api\IsPathBlacklistedInterface; +use Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface; /** * Check if the path is blacklisted for media gallery. Directory path may be blacklisted if it's reserved by the system @@ -15,14 +16,14 @@ class IsBlacklisted implements IsPathBlacklistedInterface { /** - * @var Config + * @var BlacklistPatternsConfigInterface */ private $config; - /** - * @param Config $config + /* + * @param BlacklistPatternsConfigInterface $config */ - public function __construct(Config $config) + public function __construct(BlacklistPatternsConfigInterface $config) { $this->config = $config; } @@ -35,7 +36,7 @@ public function __construct(Config $config) */ public function execute(string $path): bool { - foreach ($this->config->getBlacklistPatterns() as $pattern) { + foreach ($this->config->get() as $pattern) { if (empty($pattern)) { continue; } diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php index 64689d0ab4275..33b5403fda497 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php @@ -26,11 +26,6 @@ class SaveAssets implements SaveAssetsInterface */ private $resourceConnection; - /** - * @var DataObjectProcessor - */ - private $objectProcessor; - /** * @var LoggerInterface */ @@ -40,16 +35,13 @@ class SaveAssets implements SaveAssetsInterface * Save constructor. * * @param ResourceConnection $resourceConnection - * @param DataObjectProcessor $objectProcessor * @param LoggerInterface $logger */ public function __construct( ResourceConnection $resourceConnection, - DataObjectProcessor $objectProcessor, LoggerInterface $logger ) { $this->resourceConnection = $resourceConnection; - $this->objectProcessor = $objectProcessor; $this->logger = $logger; } @@ -66,7 +58,18 @@ public function execute(array $assets): void try { $connection->insertOnDuplicate( $tableName, - $this->filterData($this->objectProcessor->buildOutputDataArray($asset, AssetInterface::class)) + [ + 'id' => $asset->getId(), + 'path' => $asset->getPath(), + 'title' => $asset->getTitle(), + 'source' => $asset->getSource(), + 'content_type' => $asset->getContentType(), + 'width' => $asset->getWidth(), + 'height' => $asset->getHeight(), + 'size' => $asset->getSize(), + 'created_at' => $asset->getCreatedAt(), + 'updated_at' => $asset->getUpdatedAt(), + ] ); } catch (\Exception $exception) { $this->logger->critical($exception); @@ -85,28 +88,4 @@ public function execute(array $assets): void ); } } - - /** - * Filter data to get flat array without null values - * - * @param array $data - * @return array - */ - private function filterData(array $data): array - { - $filteredData = []; - foreach ($data as $key => $value) { - if ($value === null) { - continue; - } - if (is_array($value)) { - continue; - } - if (is_object($value)) { - continue; - } - $filteredData[$key] = $value; - } - return $filteredData; - } } diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php index 84240fb9e3fe7..549974d27b58f 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php @@ -10,6 +10,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\MediaGallery\Model\Directory\IsBlacklisted; use Magento\MediaGallery\Model\Directory\Config; +use Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -24,7 +25,7 @@ class IsBlacklistedTest extends TestCase private $object; /** - * @var Config|MockObject + * @var BlacklistPatternsConfigInterface|MockObject */ private $config; @@ -33,8 +34,8 @@ class IsBlacklistedTest extends TestCase */ protected function setUp(): void { - $this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); - $this->config->expects($this->at(0))->method('getBlacklistPatterns')->willReturn([ + $this->config = $this->getMockBuilder(BlacklistPatternsConfigInterface::class)->disableOriginalConstructor()->getMock(); + $this->config->expects($this->at(0))->method('get')->willReturn([ 'tmp' => '/pub\/media\/tmp/', 'captcha' => '/pub\/media\/captcha/' ]); diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 4fcc18e29726c..73360197bed77 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -56,4 +56,6 @@ <argument name="data" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\Data</argument> </arguments> </type> + + <preference for="Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface" type="Magento\MediaGallery\Model\Directory\Config"/> </config> diff --git a/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php index 65115b940a900..a0a1ec891237f 100644 --- a/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php @@ -17,6 +17,7 @@ interface CreateDirectoriesByPathsInterface * Create new directories by provided paths * * @param string[] $paths + * @return void * @throws \Magento\Framework\Exception\CouldNotSaveException */ public function execute(array $paths): void; diff --git a/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php index 5e04976e32c60..fe3be88fa0073 100644 --- a/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php @@ -17,6 +17,7 @@ interface DeleteDirectoriesByPathsInterface * Deletes the existing folders * * @param string[] $paths + * @return void * @throws \Magento\Framework\Exception\CouldNotDeleteException */ public function execute(array $paths): void; diff --git a/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php b/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php index b2e5afabee11e..cbd23ec3fbde7 100644 --- a/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php @@ -8,7 +8,9 @@ namespace Magento\MediaGalleryApi\Api; /** - * Directory paths that are reserved by system and not be included in the media gallery + * Check if the path is blacklisted for media gallery. + * + * Directory path may be blacklisted if it's reserved by the system. * @api */ interface IsPathBlacklistedInterface diff --git a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php index eb9f7d70bbccf..c63f7bd8c0818 100644 --- a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php @@ -18,6 +18,7 @@ interface SaveAssetsInterface * Save media asset. The saved asset can later be retrieved by path * * @param \Magento\MediaGalleryApi\Api\Data\AssetInterface[] $assets + * @return void * @throws \Magento\Framework\Exception\CouldNotSaveException */ public function execute(array $assets): void; diff --git a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php index 072ae7a4ec6d5..04efe7d32ccc1 100644 --- a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php @@ -17,6 +17,7 @@ interface SaveAssetsKeywordsInterface * Save assets keywords * * @param \Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface[] $assetKeywords + * @return void * @throws \Magento\Framework\Exception\CouldNotSaveException */ public function execute(array $assetKeywords): void; diff --git a/app/code/Magento/MediaGalleryApi/Model/BlacklistPatternsConfigInterface.php b/app/code/Magento/MediaGalleryApi/Model/BlacklistPatternsConfigInterface.php new file mode 100644 index 0000000000000..b4710f32e0c46 --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Model/BlacklistPatternsConfigInterface.php @@ -0,0 +1,20 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\MediaGalleryApi\Model; + +/** + * Returns list of blacklist regexp patterns + */ +interface BlacklistPatternsConfigInterface +{ + /** + * Get regexp patterns + * + * @return array + */ + public function get(): array; +} diff --git a/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/Processor.php b/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/RemoveAssetAfterRemoveImage.php similarity index 98% rename from app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/Processor.php rename to app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/RemoveAssetAfterRemoveImage.php index c595d43009dd4..865b40ce90a18 100644 --- a/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/Processor.php +++ b/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/RemoveAssetAfterRemoveImage.php @@ -15,7 +15,7 @@ /** * Ensures that metadata is removed from the database when an image has been deleted (from legacy media gallery) */ -class Processor +class RemoveAssetAfterRemoveImage { /** * @var DeleteAssetsByPathsInterface diff --git a/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php b/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/RemoveAssetAfterRemoveImageTest.php similarity index 94% rename from app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php rename to app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/RemoveAssetAfterRemoveImageTest.php index 3a8c9294259f9..7cb071a5aebe4 100644 --- a/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php +++ b/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/RemoveAssetAfterRemoveImageTest.php @@ -10,7 +10,7 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Gallery\Processor as ProcessorSubject; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use Magento\MediaGalleryCatalog\Plugin\Product\Gallery\Processor; +use Magento\MediaGalleryCatalog\Plugin\Product\Gallery\RemoveAssetAfterRemoveImage; use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -19,7 +19,7 @@ /** * Unit test for \Magento\MediaGalleryCatalog\Plugin\Product\Gallery\Processor */ -class ProcessorTest extends TestCase +class RemoveAssetAfterRemoveImageTest extends TestCase { private const STUB_FILE_NAME = 'file'; @@ -44,7 +44,7 @@ class ProcessorTest extends TestCase private $productMock; /** - * @var Processor + * @var RemoveAssetAfterRemoveImage */ private $plugin; @@ -60,7 +60,7 @@ protected function setUp() $this->loggerMock = $this->createMock(LoggerInterface::class); $this->plugin = (new ObjectManagerHelper($this))->getObject( - Processor::class, + RemoveAssetAfterRemoveImage::class, [ 'deleteByPaths' => $this->deleteMediaAssetByPathMock, 'logger' => $this->loggerMock diff --git a/app/code/Magento/MediaGalleryCatalog/etc/di.xml b/app/code/Magento/MediaGalleryCatalog/etc/di.xml index 41dfeaf14aace..8145134025990 100644 --- a/app/code/Magento/MediaGalleryCatalog/etc/di.xml +++ b/app/code/Magento/MediaGalleryCatalog/etc/di.xml @@ -7,7 +7,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Catalog\Model\Product\Gallery\Processor"> - <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\Processor" - sortOrder="10" disabled="false"/> + <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\RemoveAssetAfterRemoveImage"/> </type> </config> From 6a94b59b22a17d20459a66c82df8515dacd09c98 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Tue, 14 Apr 2020 15:44:18 -0500 Subject: [PATCH 133/455] magento/magento2#27499: Code review fixes --- ...Config.php => BlacklistPatternsConfig.php} | 2 +- .../Model/Directory/ConfigInterface.php | 21 ------------------- .../Model/Directory/IsBlacklistedTest.php | 1 - app/code/Magento/MediaGallery/etc/di.xml | 7 ++----- 4 files changed, 3 insertions(+), 28 deletions(-) rename app/code/Magento/MediaGallery/Model/Directory/{Config.php => BlacklistPatternsConfig.php} (91%) delete mode 100644 app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config.php b/app/code/Magento/MediaGallery/Model/Directory/BlacklistPatternsConfig.php similarity index 91% rename from app/code/Magento/MediaGallery/Model/Directory/Config.php rename to app/code/Magento/MediaGallery/Model/Directory/BlacklistPatternsConfig.php index 67695080b185f..8fdd4f70d5060 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config.php +++ b/app/code/Magento/MediaGallery/Model/Directory/BlacklistPatternsConfig.php @@ -13,7 +13,7 @@ /** * Media gallery directory config */ -class Config implements BlacklistPatternsConfigInterface +class BlacklistPatternsConfig implements BlacklistPatternsConfigInterface { private const XML_PATH_BLACKLIST_PATTERNS = 'blacklist/patterns'; diff --git a/app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php b/app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php deleted file mode 100644 index 80d6c0be6b746..0000000000000 --- a/app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaGallery\Model\Directory; - -/** - * Media gallery directory config - */ -interface ConfigInterface -{ - /** - * Returns list of blacklist RegEx patterns - * - * @return array - */ - public function getBlacklistPatterns(): array; -} diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php index 549974d27b58f..a60c4d75aee7d 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php @@ -9,7 +9,6 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\MediaGallery\Model\Directory\IsBlacklisted; -use Magento\MediaGallery\Model\Directory\Config; use Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 31c89528c96c9..a85c26e275226 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -9,9 +9,6 @@ <preference for="Magento\MediaGalleryApi\Api\Data\KeywordInterface" type="Magento\MediaGallery\Model\Keyword"/> <preference for="Magento\MediaGalleryApi\Api\Data\AssetInterface" type="Magento\MediaGallery\Model\Asset"/> <preference for="Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface" type="Magento\MediaGallery\Model\AssetKeywords"/> - - <preference for="Magento\MediaGallery\Model\Directory\ConfigInterface" type="Magento\MediaGallery\Model\Directory\Config"/> - <preference for="Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface" type="Magento\MediaGallery\Model\Asset\Command\GetById"/> <preference for="Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface" type="Magento\MediaGallery\Model\Asset\Command\Save"/> <preference for="Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface" type="Magento\MediaGallery\Model\Asset\Command\GetByPath"/> @@ -53,11 +50,11 @@ <argument name="cacheId" xsi:type="string">Media_Gallery_Patterns_CacheId</argument> </arguments> </virtualType> - <type name="Magento\MediaGallery\Model\Directory\Config"> + <type name="Magento\MediaGallery\Model\Directory\BlacklistPatternsConfig"> <arguments> <argument name="data" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\Data</argument> </arguments> </type> - <preference for="Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface" type="Magento\MediaGallery\Model\Directory\Config"/> + <preference for="Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface" type="Magento\MediaGallery\Model\Directory\BlacklistPatternsConfig"/> </config> From e29e3af5b2c38e90c8ee0d02aab82dad604c82cd Mon Sep 17 00:00:00 2001 From: Vitalii Zabaznov <vzabaznov@magento.com> Date: Tue, 14 Apr 2020 17:10:15 -0500 Subject: [PATCH 134/455] MC-32427: Sign locks in order to prevent unlock from parallel request --- .../Magento/Framework/Lock/Backend/Cache.php | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Lock/Backend/Cache.php b/lib/internal/Magento/Framework/Lock/Backend/Cache.php index 5e1cdd706e326..143c76bbb8f33 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Cache.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Cache.php @@ -24,6 +24,13 @@ class Cache implements \Magento\Framework\Lock\LockManagerInterface */ private $cache; + /** + * Sign for locks, helps to avoid removing a lock that was created by another client + * + * @string + */ + private $lockSign; + /** * @param FrontendInterface $cache */ @@ -37,11 +44,25 @@ public function __construct(FrontendInterface $cache) */ public function lock(string $name, int $timeout = -1): bool { - if ((bool)$this->cache->test($this->getIdentifier($name))) { + if (empty($this->lockSign)) { + $this->lockSign = \bin2hex(\random_bytes(8)); + } + + $data = $this->cache->load($this->getIdentifier($name)); + + if (false !== $data) { return false; } - return $this->cache->save('1', $this->getIdentifier($name), [], $timeout); + $saveResult = $this->cache->save($this->lockSign, $this->getIdentifier($name), [], $timeout * 100); + + $data = $this->cache->load($this->getIdentifier($name)); + + if ($data === $this->lockSign && $saveResult) { + return true; + } + + return false; } /** @@ -49,7 +70,22 @@ public function lock(string $name, int $timeout = -1): bool */ public function unlock(string $name): bool { - return (bool)$this->cache->remove($this->getIdentifier($name)); + if (empty($this->lockSign)) { + return false; + } + + $data = $this->cache->load($this->getIdentifier($name)); + + if (false === $data) { + return false; + } + + $removeResult = false; + if ($data === $this->lockSign) { + $removeResult = (bool)$this->cache->remove($this->getIdentifier($name)); + } + + return $removeResult; } /** From 223aebda57ba9eb444f6163441599b566a2bd103 Mon Sep 17 00:00:00 2001 From: Vitalii Zabaznov <vzabaznov@magento.com> Date: Tue, 14 Apr 2020 17:17:13 -0500 Subject: [PATCH 135/455] MC-32337: Product updates clean cache by cat_p tag --- app/code/Magento/Catalog/Model/Product.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index fd59130db4bdf..bc8d274fb6e63 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -73,9 +73,9 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements const STORE_ID = 'store_id'; /** - * @var string + * @var string|bool */ - protected $_cacheTag = self::CACHE_TAG; + protected $_cacheTag = false; /** * @var string @@ -878,7 +878,6 @@ public function getAttributes($groupId = null, $skipSuper = false) */ public function beforeSave() { - $this->cleanCache(); $this->setTypeHasOptions(false); $this->setTypeHasRequiredOptions(false); $this->setHasOptions(false); From 425359cd5a2528c603856771d4645b83c430b373 Mon Sep 17 00:00:00 2001 From: Vitalii Zabaznov <vzabaznov@magento.com> Date: Tue, 14 Apr 2020 17:30:09 -0500 Subject: [PATCH 136/455] MC-32426: Change timeout lockup --- app/code/Magento/Config/etc/di.xml | 2 -- app/etc/di.xml | 2 -- 2 files changed, 4 deletions(-) diff --git a/app/code/Magento/Config/etc/di.xml b/app/code/Magento/Config/etc/di.xml index 920cac382fcbf..70318553710d3 100644 --- a/app/code/Magento/Config/etc/di.xml +++ b/app/code/Magento/Config/etc/di.xml @@ -97,8 +97,6 @@ <virtualType name="systemConfigQueryLocker" type="Magento\Framework\Cache\LockGuardedCacheLoader"> <arguments> <argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Cache</argument> - <argument name="lockTimeout" xsi:type="number">42000</argument> - <argument name="delayTimeout" xsi:type="number">100</argument> </arguments> </virtualType> diff --git a/app/etc/di.xml b/app/etc/di.xml index dbc4a1832adf6..0133288a17ac5 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -1787,8 +1787,6 @@ <type name="Magento\Framework\Cache\LockGuardedCacheLoader"> <arguments> <argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Cache</argument> - <argument name="lockTimeout" xsi:type="number">10000</argument> - <argument name="delayTimeout" xsi:type="number">20</argument> </arguments> </type> <preference for="Magento\Framework\HTTP\AsyncClientInterface" type="Magento\Framework\HTTP\AsyncClient\GuzzleAsyncClient" /> From a3fb28a1086e5431714fd97fdc67fbff35da03da Mon Sep 17 00:00:00 2001 From: Hwashiang Yu <hwyu@adobe.com> Date: Tue, 14 Apr 2020 20:35:09 -0500 Subject: [PATCH 137/455] MC-30175: UI component rendering config - Added CE changes --- .../Product/Form/Modifier/BundlePriceTest.php | 3 ++- .../Form/Modifier/BundleWeightTest.php | 1 + .../Form/Modifier/BundleAdvancedPricing.php | 10 +++++--- .../Form/Modifier/BundleCustomOptions.php | 6 +++-- .../Product/Form/Modifier/BundlePanel.php | 23 +++++++++++++---- .../Product/Form/Modifier/BundlePrice.php | 6 +++-- .../Product/Form/Modifier/BundleWeight.php | 7 +++--- .../Model/Product/AttributeSet/Options.php | 18 +++++++------ .../Unit/Ui/Component/ColumnFactoryTest.php | 2 -- .../Ui/Component/Product/MassActionTest.php | 10 +------- .../Product/Form/Modifier/EavTest.php | 7 ------ .../Catalog/Ui/Component/ColumnFactory.php | 1 - .../Listing/Columns/ProductActions.php | 3 +-- .../Ui/Component/Product/MassAction.php | 4 +-- .../Product/Form/Modifier/AdvancedPricing.php | 4 ++- .../Product/Form/Modifier/AttributeSet.php | 7 ------ .../Product/Form/Modifier/Attributes.php | 18 ++++++++++--- .../Product/Form/Modifier/Categories.php | 1 + .../Product/Form/Modifier/CustomOptions.php | 15 ++++++++--- .../Product/Form/Modifier/Eav.php | 2 -- .../Product/Form/Modifier/General.php | 3 ++- .../Product/Form/Modifier/Related.php | 13 +++++++--- .../Product/Form/Modifier/TierPrice.php | 4 +++ .../Product/Form/Modifier/Websites.php | 3 ++- .../web/js/tier-price/value-type-select.js | 5 ++-- .../Form/Modifier/AdvancedInventory.php | 2 ++ .../Form/Modifier/ProductUrlRewrite.php | 1 + .../Block/Checkout/LayoutProcessor.php | 2 ++ .../Block/Checkout/LayoutProcessorTest.php | 1 + .../Listing/Column/BlockActionsTest.php | 2 -- .../Listing/Column/PageActionsTest.php | 4 --- .../Component/Listing/Column/BlockActions.php | 2 -- .../Component/Listing/Column/PageActions.php | 4 --- .../Model/Config/Source/Email/Template.php | 6 ----- .../Config/Source/Email/TemplateTest.php | 3 --- .../Edit/Tab/Variations/Config/Matrix.php | 3 +++ .../ConfigurableAttributeSetHandler.php | 6 +++-- .../Form/Modifier/ConfigurablePanel.php | 25 ++++++++++++++++--- .../Form/Modifier/ConfigurablePrice.php | 5 ++-- .../Product/Form/Modifier/CustomOptions.php | 8 +++--- .../Form/Modifier/Data/AssociatedProducts.php | 5 ---- .../Product/Form/Modifier/StockData.php | 1 + .../Model/Customer/Attribute/Source/Group.php | 7 ------ .../Customer/Model/Customer/DataProvider.php | 3 ++- .../Unit/Model/Customer/DataProviderTest.php | 2 ++ .../Unit/Ui/Component/ColumnFactoryTest.php | 1 - .../Unit/Ui/Component/FilterFactoryTest.php | 1 - .../Component/Listing/Column/ActionsTest.php | 3 +-- .../Listing/Column/GroupActionsTest.php | 4 --- .../Customer/Ui/Component/ColumnFactory.php | 1 - .../Customer/Ui/Component/FilterFactory.php | 1 - .../Ui/Component/Listing/Column/Actions.php | 1 - .../Component/Listing/Column/GroupActions.php | 2 -- .../Ui/Component/MassAction/Group/Options.php | 4 ++- .../Form/Modifier/DownloadablePanel.php | 11 +++++--- .../Product/Form/Modifier/Links.php | 4 ++- .../Product/Form/Modifier/UsedDefault.php | 9 +++++-- .../Product/Modifier/GiftMessage.php | 2 ++ .../Product/Form/Modifier/Grouped.php | 7 +++++- .../Listing/Column/Method/Options.php | 9 +------ .../DataProvider/Modifier/Notifications.php | 8 ++++-- .../Product/Form/Modifier/Review.php | 6 +++-- .../Listing/Column/Status/OptionsTest.php | 3 +-- .../Listing/Column/Status/Options.php | 10 +------- .../Listing/Column/SynonymActionsTest.php | 2 -- .../Listing/Column/SynonymActions.php | 2 -- .../Listing/Column/EditActionTest.php | 3 +-- .../Listing/Column/ViewActionTest.php | 2 -- .../Config/SearchRobots/ResetButton.php | 1 + .../Component/Listing/Column/EditAction.php | 3 +-- .../Component/Listing/Column/ViewAction.php | 3 +-- app/code/Magento/Ui/Component/MassAction.php | 2 +- .../Ui/Test/Unit/Component/MassActionTest.php | 4 +-- .../Config/Source/Group/MultiselectTest.php | 5 +--- 74 files changed, 201 insertions(+), 181 deletions(-) diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePriceTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePriceTest.php index b0519f1ebddba..5d06150d197a9 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePriceTest.php @@ -68,7 +68,8 @@ public function testModifyMeta() ]; $priceParams = [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ]; $priceMeta = [ diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleWeightTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleWeightTest.php index 8c89a18c292f6..c826bba4dbabb 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleWeightTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleWeightTest.php @@ -58,6 +58,7 @@ public function testModifyMeta() $weightParams = [ 'imports' => [ 'disabled' => 'ns = ${ $.ns }, index = ' . BundleWeight::CODE_WEIGHT_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ]; $hasWeightParams = [ diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php index 1b04bdc4f8104..312a812402e97 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php @@ -34,7 +34,7 @@ public function __construct(ArrayManager $arrayManager) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -63,7 +63,7 @@ public function modifyMeta(array $meta) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -88,7 +88,8 @@ private function modifyMsrpMeta(array $meta) $meta, [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); @@ -103,7 +104,8 @@ private function modifyMsrpMeta(array $meta) $meta, [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleCustomOptions.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleCustomOptions.php index 1a0e08bd07255..b25fad0a40677 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleCustomOptions.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleCustomOptions.php @@ -15,7 +15,7 @@ class BundleCustomOptions extends AbstractModifier { /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -55,6 +55,7 @@ public function modifyCustomOptionsButton(array $meta, $group, $container, $butt if (!empty($meta[$group]['children'][$container]['children'][$button])) { $meta[$group]['children'][$container]['children'][$button]['arguments']['data']['config']['imports'] = [ 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['visible' => false], ]; } return $meta; @@ -79,6 +80,7 @@ public function getErrorMessage($sortOrder) 'sortOrder' => $sortOrder, 'imports' => [ 'visible' => 'ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['visible' => false], ], ], ], @@ -87,7 +89,7 @@ public function getErrorMessage($sortOrder) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php index 18f970069c3c9..5ff9e674acad9 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php @@ -319,6 +319,7 @@ protected function getBundleHeader() * Get Bundle Options structure * * @return array + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function getBundleOptions() { @@ -348,7 +349,8 @@ protected function getBundleOptions() 'component' => 'Magento_Ui/js/dynamic-rows/record', 'positionProvider' => 'product_bundle_container.position', 'imports' => [ - 'label' => '${ $.name }' . '.product_bundle_container.option_info.title:value' + 'label' => '${ $.name }' . '.product_bundle_container.option_info.title:value', + '__disableTmpl' => ['label' => false], ], ], ], @@ -381,6 +383,7 @@ protected function getBundleOptions() 'template' => 'ui/dynamic-rows/templates/default', 'provider' => 'product_form.product_form_data_source', 'dataProvider' => '${ $.dataScope }' . '.bundle_button_proxy', + '__disableTmpl' => ['dataProvider' => false], 'identificationDRProperty' => 'product_id', 'identificationProperty' => 'product_id', 'map' => [ @@ -395,9 +398,13 @@ protected function getBundleOptions() 'selection_price_value' => '', 'selection_qty' => '', ], - 'links' => ['insertData' => '${ $.provider }:${ $.dataProvider }'], + 'links' => [ + 'insertData' => '${ $.provider }:${ $.dataProvider }', + '__disableTmpl' => ['insertData' => false], + ], 'imports' => [ 'inputType' => '${$.provider}:${$.dataScope}.type', + '__disableTmpl' => ['inputType' => false], ], 'source' => 'product', ], @@ -619,9 +626,11 @@ protected function getBundleSelections() 'is_collection' => true, 'imports' => [ 'inputType' => '${$.parentName}:inputType', + '__disableTmpl' => ['inputType' => false], ], 'exports' => [ 'isDefaultValue' => '${$.parentName}:isDefaultValue.${$.index}', + '__disableTmpl' => ['isDefaultValue' => false], ], ], ], @@ -702,7 +711,8 @@ protected function getBundleSelections() 'validate-greater-than-zero' => true ], 'imports' => [ - 'isInteger' => '${ $.provider }:${ $.parentScope }.selection_qty_is_integer' + 'isInteger' => '${ $.provider }:${ $.parentScope }.selection_qty_is_integer', + '__disableTmpl' => ['isInteger' => false], ], ], ], @@ -723,6 +733,7 @@ protected function getBundleSelections() 'sortOrder' => 110, 'imports' => [ 'inputType' => '${$.parentName}:inputType', + '__disableTmpl' => ['inputType' => false], ], ], ], @@ -764,7 +775,8 @@ protected function getSelectionPriceValue() 'dataScope' => 'selection_price_value', 'value' => '0.00', 'imports' => [ - 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked' + 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['visible' => false], ], 'sortOrder' => 80, ], @@ -801,7 +813,8 @@ protected function getSelectionPriceType() ] ], 'imports' => [ - 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked' + 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['visible' => false], ], 'sortOrder' => 90, ], diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php index d7da7513c3aac..598b762c061a1 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php @@ -71,7 +71,8 @@ public function modifyMeta(array $meta) $meta, [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); @@ -86,7 +87,8 @@ public function modifyMeta(array $meta) $meta, [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php index 83e045d3562cf..39e9b3d7b5cd4 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php @@ -30,7 +30,7 @@ public function __construct(ArrayManager $arrayManager) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -73,15 +73,16 @@ public function modifyMeta(array $meta) [ 'imports' => [ 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_WEIGHT_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); - + return $meta; } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { diff --git a/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php b/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php index 57d08916bcd40..89c550d4e0ab3 100644 --- a/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php +++ b/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php @@ -10,11 +10,22 @@ */ class Options implements \Magento\Framework\Data\OptionSourceInterface { + /** * @var array */ protected $options; + /** + * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory + */ + protected $collectionFactory; + + /** + * @var \Magento\Catalog\Model\ResourceModel\Product + */ + protected $product; + /** * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $collectionFactory * @param \Magento\Catalog\Model\ResourceModel\Product $product @@ -36,13 +47,6 @@ public function toOptionArray() $this->options = $this->collectionFactory->create() ->setEntityTypeFilter($this->product->getTypeId()) ->toOptionArray(); - - array_walk( - $this->options, - function (&$option) { - $option['__disableTmpl'] = true; - } - ); } return $this->options; diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php index b3acaa4b8bbed..ba81d42e75c76 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -129,7 +129,6 @@ public function testCreateWithNotFilterableInGridAttribute(array $filterModifier 'visible' => null, 'filter' => $filter, 'component' => 'Magento_Ui/js/grid/columns/column', - '__disableTmpl' => ['label' => true] ], ], 'context' => $this->context, @@ -206,7 +205,6 @@ public function testCreateDateColumn( 'component' => 'Magento_Ui/js/grid/columns/date', 'timezone' => $expectedTimezone, 'dateFormat' => $expectedDateFormat, - '__disableTmpl' => ['label' => true], 'options' => [ 'showsTime' => $showsTime ] diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php index c704d9f89581d..966d5bc308c09 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php @@ -13,7 +13,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; /** - * MassAction test + * MassAction test for Component Product */ class MassActionTest extends \PHPUnit\Framework\TestCase { @@ -107,7 +107,6 @@ public function getPrepareDataProvider() : array 'type' => 'first_action', 'label' => 'First Action', 'url' => '/module/controller/firstAction', - '__disableTmpl' => true ], ], [ @@ -127,7 +126,6 @@ public function getPrepareDataProvider() : array 'url' => '/module/controller/secondSubAction2' ], ], - '__disableTmpl' => true ], ], [ @@ -147,7 +145,6 @@ public function getPrepareDataProvider() : array 'url' => '/module/controller/disable' ], ], - '__disableTmpl' => true ], ], [ @@ -167,7 +164,6 @@ public function getPrepareDataProvider() : array 'url' => '/module/controller/disable' ], ], - '__disableTmpl' => true ], false, false @@ -178,7 +174,6 @@ public function getPrepareDataProvider() : array 'type' => 'delete', 'label' => 'First Action', 'url' => '/module/controller/delete', - '__disableTmpl' => true ], ], [ @@ -187,7 +182,6 @@ public function getPrepareDataProvider() : array 'type' => 'delete', 'label' => 'First Action', 'url' => '/module/controller/delete', - '__disableTmpl' => true ], false, false @@ -198,7 +192,6 @@ public function getPrepareDataProvider() : array 'type' => 'delete', 'label' => 'First Action', 'url' => '/module/controller/attributes', - '__disableTmpl' => true ], ], [ @@ -207,7 +200,6 @@ public function getPrepareDataProvider() : array 'type' => 'delete', 'label' => 'First Action', 'url' => '/module/controller/attributes', - '__disableTmpl' => true ], false, false diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php index 91e22407acc43..917ef2bd522f8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php @@ -570,7 +570,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'default_null_prod_not_new_locked_and_required' => [ @@ -590,7 +589,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], 'locked' => true, ], @@ -611,7 +609,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'default_null_prod_new_and_not_required' => [ @@ -631,7 +628,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'default_null_prod_new_locked_and_not_required' => [ @@ -651,7 +647,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], 'locked' => true, ], @@ -672,7 +667,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'datetime_null_prod_not_new_and_required' => [ @@ -692,7 +686,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], 'locked' => false, 'frontendInput' => 'datetime', diff --git a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php index b902e741c006c..c7afc61e38ca4 100644 --- a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php +++ b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php @@ -92,7 +92,6 @@ public function create($attribute, $context, array $config = []) 'filter' => ($attribute->getIsFilterableInGrid() || array_key_exists($columnName, $filterModifiers)) ? $this->getFilterType($attribute->getFrontendInput()) : null, - '__disableTmpl' => ['label' => true], ], $config ); diff --git a/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php b/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php index 596b0f4118599..c54cfa28fcda0 100644 --- a/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php +++ b/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php @@ -11,7 +11,7 @@ use Magento\Framework\UrlInterface; /** - * Class ProductActions + * Class ProductActions for Listing Columns * * @api * @since 100.0.2 @@ -60,7 +60,6 @@ public function prepareDataSource(array $dataSource) ), 'label' => __('Edit'), 'hidden' => false, - '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php b/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php index f770f6b9c497f..be6de45e20de2 100644 --- a/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php +++ b/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php @@ -13,7 +13,7 @@ use Magento\Ui\Component\AbstractComponent; /** - * Class MassAction + * Class MassAction for Component Product */ class MassAction extends AbstractComponent { @@ -53,7 +53,7 @@ public function prepare() : void $actionType = $actionComponent->getConfiguration()['type']; if ($this->isActionAllowed($actionType)) { // phpcs:ignore Magento2.Performance.ForeachArrayMerge - $config['actions'][] = array_merge($actionComponent->getConfiguration(), ['__disableTmpl' => true]); + $config['actions'][] = array_merge($actionComponent->getConfiguration()); } } $origConfig = $this->getConfiguration(); diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php index f19f5abd0b423..174a01b72a109 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php @@ -26,7 +26,7 @@ use Magento\Framework\Stdlib\ArrayManager; /** - * Class AdvancedPricing + * Class for Product Modifier Advanced Pricing * * @api * @@ -559,6 +559,7 @@ private function getTierPriceStructure($tierPricePath) ], 'imports' => [ 'priceValue' => '${ $.provider }:data.product.price', + '__disableTmpl' => ['priceValue' => false], ], ], ], @@ -664,6 +665,7 @@ private function customizeAdvancedPricing() 'actions' => [ [ 'targetName' => '${ $.name }', + '__disableTmpl' => ['targetName' => false], 'actionName' => 'actionDone' ] ] diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php index 53c9595b59e76..cb87e4dc9910f 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php @@ -80,13 +80,6 @@ public function getOptions() $collectionData = $collection->getData() ?? []; - array_walk( - $collectionData, - function (&$attribute) { - $attribute['__disableTmpl'] = true; - } - ); - return $collectionData; } diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php index a6b9856a4a0ed..5690e4af72375 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php @@ -13,7 +13,7 @@ use Magento\Ui\Component\Container; /** - * Class Attributes + * Class for Product Modifier Attributes * * @api * @since 101.0.0 @@ -138,6 +138,7 @@ private function customizeAddAttributeModal(array $meta) 'actions' => [ [ 'targetName' => '${ $.name }', + '__disableTmpl' => ['targetName' => false], 'actionName' => 'actionCancel' ] ] @@ -148,6 +149,7 @@ private function customizeAddAttributeModal(array $meta) 'actions' => [ [ 'targetName' => '${ $.name }.product_attributes_grid', + '__disableTmpl' => ['targetName' => false], 'actionName' => 'save' ], [ @@ -271,6 +273,7 @@ private function customizeCreateAttributeModal(array $meta) 'externalProvider' => 'product_attribute_add_form' . '.product_attribute_add_form_data_source', 'toolbarContainer' => '${ $.parentName }', + '__disableTmpl' => ['toolbarContainer' => false], 'formSubmitType' => 'ajax', 'saveUrl' => $this->urlBuilder->getUrl('catalog/product_attribute/save', $params), 'validateUrl' => $this->urlBuilder->getUrl( @@ -281,11 +284,17 @@ private function customizeCreateAttributeModal(array $meta) 'productType' => $this->locator->getProduct()->getTypeId(), 'imports' => [ 'attributeSetId' => '${ $.provider }:data.product.attribute_set_id', + '__disableTmpl' => ['attributeSetId' => false], ], 'exports' => [ 'saveUrl' => '${ $.externalProvider }:client.urls.save', 'validateUrl' => '${ $.externalProvider }:client.urls.beforeSave', 'attributeSetId' => '${ $.externalProvider }:params.set', + '__disableTmpl' => [ + 'saveUrl' => false, + 'validateUrl' => false, + 'attributeSetId' => false + ], ] ] ] @@ -321,6 +330,7 @@ private function customizeAttributesGrid(array $meta) 'externalFilterMode' => true, 'dataLinks' => ['imports' => false, 'exports' => false], 'formProvider' => 'ns = ${ $.namespace }, index = product_form', + '__disableTmpl' => ['selectionsProvider' => false, 'formProvider' => false], 'groupCode' => static::GROUP_CODE, 'groupName' => static::GROUP_NAME, 'groupSortOrder' => static::GROUP_SORT_ORDER, @@ -330,10 +340,12 @@ private function customizeAttributesGrid(array $meta) 'productType' => $this->locator->getProduct()->getTypeId(), 'loading' => false, 'imports' => [ - 'attributeSetId' => '${ $.provider }:data.product.attribute_set_id' + 'attributeSetId' => '${ $.provider }:data.product.attribute_set_id', + '__disableTmpl' => ['attributeSetId' => false], ], 'exports' => [ - 'attributeSetId' => '${ $.externalProvider }:params.template_id' + 'attributeSetId' => '${ $.externalProvider }:params.template_id', + '__disableTmpl' => ['attributeSetId' => false], ] ], ], diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php index cd1f8e8e3379b..7608173c8edfc 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php @@ -210,6 +210,7 @@ protected function createNewCategoryModal(array $meta) 'ns' => 'new_category_form', 'externalProvider' => 'new_category_form.new_category_form_data_source', 'toolbarContainer' => '${ $.parentName }', + '__disableTmpl' => ['toolbarContainer' => false], 'formSubmitType' => 'ajax', ], ], diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php index 65792b395dc06..2e1ea59573c3b 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php @@ -351,6 +351,7 @@ protected function getHeaderContainerConfig($sortOrder) [ 'targetName' => '${ $.ns }.${ $.ns }.' . static::GROUP_CUSTOM_OPTIONS_NAME . '.' . static::GRID_OPTIONS_NAME, + '__disableTmpl' => ['targetName' => false], 'actionName' => 'processingAddChild', ] ] @@ -388,7 +389,10 @@ protected function getOptionsGridConfig($sortOrder) 'collapsibleHeader' => true, 'sortOrder' => $sortOrder, 'dataProvider' => static::CUSTOM_OPTIONS_LISTING, - 'imports' => ['insertData' => '${ $.provider }:${ $.dataProvider }'], + 'imports' => [ + 'insertData' => '${ $.provider }:${ $.dataProvider }', + '__disableTmpl' => ['insertData' => false], + ], ], ], ], @@ -513,7 +517,8 @@ protected function getImportOptionsModalConfig() 'exports' => true ], 'exports' => [ - 'currentProductId' => '${ $.externalProvider }:params.current_product_id' + 'currentProductId' => '${ $.externalProvider }:params.current_product_id', + '__disableTmpl' => ['currentProductId' => false], ] ], ], @@ -559,7 +564,8 @@ protected function getCommonContainerConfig($sortOrder) 'valueUpdate' => 'input', 'imports' => [ 'optionId' => '${ $.provider }:${ $.parentScope }.option_id', - 'isUseDefault' => '${ $.provider }:${ $.parentScope }.is_use_default' + 'isUseDefault' => '${ $.provider }:${ $.parentScope }.is_use_default', + '__disableTmpl' => ['optionId' => false, 'isUseDefault' => false], ] ], ], @@ -638,7 +644,8 @@ protected function getSelectTypeGridConfig($sortOrder) 'imports' => [ 'optionId' => '${ $.provider }:${ $.parentScope }.option_id', 'optionTypeId' => '${ $.provider }:${ $.parentScope }.option_type_id', - 'isUseDefault' => '${ $.provider }:${ $.parentScope }.is_use_default' + 'isUseDefault' => '${ $.provider }:${ $.parentScope }.is_use_default', + '__disableTmpl' => ['optionId' => false, 'optionTypeId' => false, 'isUseDefault' => false], ], 'service' => [ 'template' => 'Magento_Catalog/form/element/helper/custom-option-type-service', diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php index 25e816f79639a..0295e778f2b9b 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php @@ -686,7 +686,6 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC 'scopeLabel' => $this->getScopeLabel($attribute), 'globalScope' => $this->isScopeGlobal($attribute), 'sortOrder' => $sortOrder * self::SORT_ORDER_MULTIPLIER, - '__disableTmpl' => ['label' => true, 'code' => true] ] ); $product = $this->locator->getProduct(); @@ -861,7 +860,6 @@ public function setupAttributeContainerMeta(ProductAttributeInterface $attribute 'breakLine' => false, 'label' => $attribute->getDefaultFrontendLabel(), 'required' => $attribute->getIsRequired(), - '__disableTmpl' => ['label' => true] ] ); diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php index ebc0425be0188..371022e70123d 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php @@ -228,7 +228,8 @@ protected function customizeWeightField(array $meta) 'addafter' => $this->locator->getStore()->getConfig('general/locale/weight_unit'), 'imports' => $disabled ? [] : [ 'disabled' => '!${$.provider}:' . self::DATA_SCOPE_PRODUCT - . '.product_has_weight:value' + . '.product_has_weight:value', + '__disableTmpl' => ['disabled' => false], ] ] ); diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php index b4acb93dcd14f..fb1c310a8a2b4 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php @@ -25,7 +25,7 @@ use Magento\Catalog\Model\Product\Attribute\Source\Status; /** - * Class Related + * Class for Product Modifier Related * * @api * @@ -143,7 +143,8 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc + * * @since 101.0.0 */ public function modifyMeta(array $meta) @@ -182,7 +183,8 @@ public function modifyMeta(array $meta) } /** - * {@inheritdoc} + * @inheritdoc + * * @since 101.0.0 */ public function modifyData(array $data) @@ -528,10 +530,12 @@ protected function getGenericModal(Phrase $title, $scope) 'imports' => [ 'productId' => '${ $.provider }:data.product.current_product_id', 'storeId' => '${ $.provider }:data.product.current_store_id', + '__disableTmpl' => ['productId' => false, 'storeId' => false], ], 'exports' => [ 'productId' => '${ $.externalProvider }:params.current_product_id', 'storeId' => '${ $.externalProvider }:params.current_store_id', + '__disableTmpl' => ['productId' => false, 'storeId' => false], ] ], ], @@ -582,7 +586,8 @@ protected function getGrid($scope) 'thumbnail' => 'thumbnail_src', ], 'links' => [ - 'insertData' => '${ $.provider }:${ $.dataProvider }' + 'insertData' => '${ $.provider }:${ $.dataProvider }', + '__disableTmpl' => ['insertData' => false], ], 'sortOrder' => 2, ], diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php index 9c5fffc5db9b9..c64d3e2e4effb 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php @@ -138,6 +138,10 @@ private function getUpdatedTierPriceStructure(array $priceMeta) . ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE, ProductPriceOptionsInterface::VALUE_PERCENT => '${ $.parentName }.' . ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PERCENTAGE_VALUE, + '__disableTmpl' => [ + ProductPriceOptionsInterface::VALUE_FIXED => false, + ProductPriceOptionsInterface::VALUE_PERCENT => false, + ], ], ], ], diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php index de204b312a3fd..430b6c004e772 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php @@ -259,7 +259,8 @@ protected function getDynamicRow($websiteId, $sortOrder) 'columnsHeader' => true, 'dndConfig' => ['enabled' => false], 'imports' => [ - 'visible' => '${$.namespace}.${$.namespace}.websites.' . $websiteId . ':checked' + 'visible' => '${$.namespace}.${$.namespace}.websites.' . $websiteId . ':checked', + '__disableTmpl' => ['visible' => false], ], 'itemTemplate' => 'record', 'dataScope' => '', diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/tier-price/value-type-select.js b/app/code/Magento/Catalog/view/adminhtml/web/js/tier-price/value-type-select.js index e1a15a93e793d..ff8a3586d0077 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/tier-price/value-type-select.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/tier-price/value-type-select.js @@ -19,8 +19,9 @@ define([ * {@inheritdoc} */ initialize: function () { - this._super() - .prepareForm(); + this._super(); + delete this.prices.__disableTmpl; + this.prepareForm(); }, /** diff --git a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php index 38a33b75f552a..c8509f665876d 100644 --- a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php +++ b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php @@ -197,6 +197,7 @@ private function prepareMeta() 'scopeLabel' => '[GLOBAL]', 'imports' => [ 'visible' => '${$.provider}:data.product.stock_data.manage_stock', + '__disableTmpl' => ['visible' => false], ], ] ); @@ -240,6 +241,7 @@ private function prepareMeta() ], 'imports' => [ 'handleChanges' => '${$.provider}:data.product.stock_data.is_qty_decimal', + '__disableTmpl' => ['handleChanges' => false], ], 'sortOrder' => 10, 'disabled' => $this->locator->getProduct()->isLockedAttribute($fieldCode), diff --git a/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php b/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php index 10791eae5405f..9567f78414d78 100644 --- a/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php +++ b/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php @@ -125,6 +125,7 @@ protected function addUrlRewriteCheckbox(array $meta) 'handleUseDefault' => '${ $.parentName }.url_key:isUseDefault', 'handleChanges' => '${ $.provider }:data.product.' . ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY, + '__disableTmpl' => ['urlKey' => false, 'handleUseDefault' => false, 'handleChanges' => false], ], 'description' => __('Create Permanent Redirect for old URL'), 'dataScope' => 'url_key_create_redirect', diff --git a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php index 00cc06ea0ff47..16450ec6ff2c2 100644 --- a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php +++ b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php @@ -299,6 +299,7 @@ private function getBillingAddressComponent($paymentCode, $elements) 'deps' => 'checkoutProvider', 'dataScopePrefix' => 'billingAddress' . $paymentCode, 'billingAddressListProvider' => '${$.name}.billingAddressList', + '__disableTmpl' => ['billingAddressListProvider' => false], 'sortOrder' => 1, 'children' => [ 'billingAddressList' => [ @@ -329,6 +330,7 @@ private function getBillingAddressComponent($paymentCode, $elements) ], 'filterBy' => [ 'target' => '${ $.provider }:${ $.parentScope }.country_id', + '__disableTmpl' => ['target' => false], 'field' => 'country_id', ], ], diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php index 9fff4b622e596..7b7d956f457f0 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php @@ -255,6 +255,7 @@ private function getBillingComponent($paymentCode) ], 'filterBy' => [ 'target' => '${ $.provider }:${ $.parentScope }.country_id', + '__disableTmpl' => ['target' => false], 'field' => 'country_id', ], ], diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php index 4ffe4a6ad8774..e38f7b7fc6704 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php @@ -96,7 +96,6 @@ public function testPrepareDataSource() 'edit' => [ 'href' => 'test/url/edit', 'label' => __('Edit'), - '__disableTmpl' => true, ], 'delete' => [ 'href' => 'test/url/delete', @@ -106,7 +105,6 @@ public function testPrepareDataSource() 'message' => __('Are you sure you want to delete a %1 record?', $title), ], 'post' => true, - '__disableTmpl' => true, ], ], ], diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php index 781d6d31246ca..a6c0c4349707e 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php @@ -176,7 +176,6 @@ public function configDataProvider():array 'edit' => [ 'href' => 'test/url/edit', 'label' => __('Edit'), - '__disableTmpl' => true, ], 'delete' => [ 'href' => 'test/url/delete', @@ -184,15 +183,12 @@ public function configDataProvider():array 'confirm' => [ 'title' => __('Delete %1', $title), 'message' => __('Are you sure you want to delete a %1 record?', $title), - '__disableTmpl' => true, ], 'post' => true, - '__disableTmpl' => true, ], 'preview' => [ 'href' => 'test/url/view', 'label' => __('View'), - '__disableTmpl' => true, 'target' => '_blank' ] ], diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php index 65940c5d7b4f9..6e9eef47281c0 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php @@ -70,7 +70,6 @@ public function prepareDataSource(array $dataSource) ] ), 'label' => __('Edit'), - '__disableTmpl' => true, ], 'delete' => [ 'href' => $this->urlBuilder->getUrl( @@ -85,7 +84,6 @@ public function prepareDataSource(array $dataSource) 'message' => __('Are you sure you want to delete a %1 record?', $title), ], 'post' => true, - '__disableTmpl' => true, ], ]; } diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php index 0c6000bdbab84..7c04ce3e2e09e 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php @@ -87,7 +87,6 @@ public function prepareDataSource(array $dataSource) $item[$name]['edit'] = [ 'href' => $this->urlBuilder->getUrl($this->editUrl, ['page_id' => $item['page_id']]), 'label' => __('Edit'), - '__disableTmpl' => true, ]; $title = $this->getEscaper()->escapeHtml($item['title']); $item[$name]['delete'] = [ @@ -96,10 +95,8 @@ public function prepareDataSource(array $dataSource) 'confirm' => [ 'title' => __('Delete %1', $title), 'message' => __('Are you sure you want to delete a %1 record?', $title), - '__disableTmpl' => true, ], 'post' => true, - '__disableTmpl' => true, ]; } if (isset($item['identifier'])) { @@ -110,7 +107,6 @@ public function prepareDataSource(array $dataSource) isset($item['store_code']) ? $item['store_code'] : null ), 'label' => __('View'), - '__disableTmpl' => true, 'target' => '_blank' ]; } diff --git a/app/code/Magento/Config/Model/Config/Source/Email/Template.php b/app/code/Magento/Config/Model/Config/Source/Email/Template.php index e4f1ae65bcacd..ac168f16ca182 100644 --- a/app/code/Magento/Config/Model/Config/Source/Email/Template.php +++ b/app/code/Magento/Config/Model/Config/Source/Email/Template.php @@ -64,12 +64,6 @@ public function toOptionArray() $templateLabel = $this->_emailConfig->getTemplateLabel($templateId); $templateLabel = __('%1 (Default)', $templateLabel); array_unshift($options, ['value' => $templateId, 'label' => $templateLabel]); - array_walk( - $options, - function (&$item) { - $item['__disableTmpl'] = true; - } - ); return $options; } } diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php index 9fabe6fef0c8e..76b9032de84e2 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php @@ -82,17 +82,14 @@ public function testToOptionArray() [ 'value' => 'template_new', 'label' => 'Template New (Default)', - '__disableTmpl' => true ], [ 'value' => 'template_one', 'label' => 'Template One', - '__disableTmpl' => true ], [ 'value' => 'template_two', 'label' => 'Template Two', - '__disableTmpl' => true ], ]; $this->_model->setPath('template/new'); diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php index b9fcf307b613f..e9d95c36ad9bb 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php @@ -12,6 +12,9 @@ /** * Product variations matrix block + * All disableTmpl flag are required here for configurable products + * + * All disableTmpl flag are required here for configurable products * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandler.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandler.php index 67773f019be8c..82bc6faac6bcc 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandler.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandler.php @@ -33,7 +33,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -41,7 +41,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -204,6 +204,7 @@ protected function getNewAttributeSet() 'visible' => 'ns = ${ $.ns }, index = affectedAttributeSetNew:checked', 'disabled' => '!ns = ${ $.ns }, index = affectedAttributeSetNew:checked', + '__disableTmpl' => ['disabled' => false, 'visible' => false], ] ], ], @@ -243,6 +244,7 @@ protected function getExistingAttributeSet($meta) 'visible' => 'ns = ${ $.ns }, index = affectedAttributeSetExisting:checked', 'disabled' => '!ns = ${ $.ns }, index = affectedAttributeSetExisting:checked', + '__disableTmpl' => ['disabled' => false, 'value' => false, 'visible' => false], ], ], ], diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php index 16119dcb5c866..4e11c49f10162 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php @@ -167,6 +167,7 @@ public function modifyMeta(array $meta) 'imports' => [ 'visible' => '!ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['visible' => false], ], ], ], @@ -185,6 +186,7 @@ public function modifyMeta(array $meta) 'imports' => [ 'visible' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['visible' => false], ], ], ], @@ -284,6 +286,7 @@ protected function getButtonSet() ), 'template' => 'ui/form/components/complex', 'createConfigurableButton' => 'ns = ${ $.ns }, index = create_configurable_products_button', + '__disableTmpl' => ['createConfigurableButton' => false], ], ], ], @@ -314,6 +317,7 @@ protected function getButtonSet() 'imports' => [ 'visible' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isShowAddProductButton', + '__disableTmpl' => ['visible' => false], ], ], ], @@ -392,6 +396,11 @@ protected function getGrid() 'insertDataFromGrid' => '${$.provider}:${$.dataProviderFromGrid}', 'insertDataFromWizard' => '${$.provider}:${$.dataProviderFromWizard}', 'changeDataFromGrid' => '${$.provider}:${$.dataProviderChangeFromGrid}', + '__disableTmpl' => [ + 'insertDataFromGrid' => false, + 'insertDataFromWizard' => false, + 'changeDataFromGrid' => false + ], ], 'sortOrder' => 20, 'columnsHeader' => false, @@ -445,6 +454,11 @@ protected function getRows() 'thumbnailUrl' => '${$.provider}:${$.parentScope}.thumbnail_image', 'thumbnail' => '${$.provider}:${$.parentScope}.thumbnail', 'smallImage' => '${$.provider}:${$.parentScope}.small_image', + '__disableTmpl' => [ + 'thumbnailUrl' => false, + 'thumbnail' => false, + 'smallImage' => false + ], ], 'uploaderConfig' => [ 'url' => $this->urlBuilder->getUrl( @@ -482,7 +496,10 @@ protected function getRows() 'price', __('Price'), [ - 'imports' => ['addbefore' => '${$.provider}:${$.parentScope}.price_currency'], + 'imports' => [ + 'addbefore' => '${$.provider}:${$.parentScope}.price_currency', + '__disableTmpl' => ['addbefore' => false], + ], 'validation' => ['validate-zero-or-greater' => true] ], ['dataScope' => 'price_string'] @@ -564,7 +581,8 @@ protected function getColumn( 'fit' => true, 'visibleIfCanEdit' => true, 'imports' => [ - 'visible' => '${$.provider}:${$.parentScope}.canEdit' + 'visible' => '${$.provider}:${$.parentScope}.canEdit', + '__disableTmpl' => ['visible' => false], ], ]; $fieldText['arguments']['data']['config'] = [ @@ -576,7 +594,8 @@ protected function getColumn( 'visibleIfCanEdit' => false, 'labelVisible' => false, 'imports' => [ - 'visible' => '!${$.provider}:${$.parentScope}.canEdit' + 'visible' => '!${$.provider}:${$.parentScope}.canEdit', + '__disableTmpl' => ['visible' => false], ], ]; $fieldEdit['arguments']['data']['config'] = array_replace_recursive( diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php index d3129a09d0056..241798a5a0fb2 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php @@ -37,7 +37,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -45,7 +45,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -82,6 +82,7 @@ public function modifyMeta(array $meta) 'imports' => [ 'visible' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['visible' => false], ] ]; $config = $visibilityConfig; diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php index 636d832842f92..d791db2ff78b9 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php @@ -40,7 +40,7 @@ public function __construct(LocatorInterface $locator, ArrayManager $arrayManage } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -48,7 +48,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -92,7 +92,8 @@ private function addPriceTypeWarning(array $meta) ), 'imports' => [ 'updateVisibility' => 'ns = ${ $.ns }, index = ' - . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty' + . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['updateVisibility' => false], ] ] ); @@ -128,6 +129,7 @@ private function modifyPriceTypeFields(array $meta) 'imports' => [ 'updateOptions' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['updateOptions' => false], ], ] ); diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php index ec69baeb92cb9..7815408321ed4 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php @@ -215,7 +215,6 @@ public function getConfigurableAttributesData() 'code' => $attribute['code'], 'label' => $attribute['label'], 'position' => $attribute['position'], - '__disableTmpl' => true ]; foreach ($attribute['chosen'] as $chosenOption) { @@ -266,7 +265,6 @@ protected function prepareVariations() 'id' => $attribute->getAttributeId(), 'position' => $configurableAttributes[$attribute->getAttributeId()]['position'], 'chosen' => [], - '__disableTmpl' => true ]; $options = $attribute->usesSource() ? $attribute->getSource()->getAllOptions() : []; foreach ($options as $option) { @@ -277,7 +275,6 @@ protected function prepareVariations() 'id' => $option['value'], 'label' => $option['label'], 'value' => $option['value'], - '__disableTmpl' => true ]; } } @@ -289,7 +286,6 @@ protected function prepareVariations() 'id' => $optionId, 'label' => $variation[$attribute->getId()]['label'], 'value' => $optionId, - '__disableTmpl' => true ]; $variationOptions[] = $variationOption; $attributes[$attribute->getAttributeId()]['chosen'][$optionId] = $variationOption; @@ -315,7 +311,6 @@ protected function prepareVariations() 'newProduct' => 0, 'attributes' => $this->getTextAttributes($variationOptions), 'thumbnail_image' => $this->imageHelper->init($product, 'product_thumbnail_image')->getUrl(), - '__disableTmpl' => true ]; $productIds[] = $product->getId(); } diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/StockData.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/StockData.php index db51e7eebefc4..32b92a197f7d9 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/StockData.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/StockData.php @@ -69,6 +69,7 @@ public function modifyMeta(array $meta) 'imports' => [ 'disabled' => '!ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['disabled' => false], ], ]; diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php index 296d2877df8ea..83aa29ea45265 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php @@ -50,13 +50,6 @@ public function getAllOptions($withEmpty = true, $defaultValues = false) $groups = $this->_groupManagement->getLoggedInGroups(); $this->_options = $this->_converter->toOptionArray($groups, 'id', 'code'); - - array_walk( - $this->_options, - function (&$item) { - $item['__disableTmpl'] = true; - } - ); } return $this->_options; diff --git a/app/code/Magento/Customer/Model/Customer/DataProvider.php b/app/code/Magento/Customer/Model/Customer/DataProvider.php index 0b7c618e6a18b..38e597e4e0fe7 100644 --- a/app/code/Magento/Customer/Model/Customer/DataProvider.php +++ b/app/code/Magento/Customer/Model/Customer/DataProvider.php @@ -365,6 +365,7 @@ private function processWebsiteMeta(&$meta) if (isset($meta[AddressInterface::COUNTRY_ID]) && !$this->getShareConfig()->isGlobalScope()) { $meta[AddressInterface::COUNTRY_ID]['arguments']['data']['config']['filterBy'] = [ 'target' => '${ $.provider }:data.customer.website_id', + '__disableTmpl' => ['target' => false], 'field' => 'website_ids' ]; } @@ -375,7 +376,7 @@ private function processWebsiteMeta(&$meta) * * @param AttributeInterface $attribute * @param array $meta - * @return array + * @return void */ private function processFrontendInput(AttributeInterface $attribute, array &$meta) { diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php index 8ad7363a1c310..30fa27a48de70 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php @@ -243,6 +243,7 @@ public function getAttributesMetaDataProvider() 'componentType' => Field::NAME, 'filterBy' => [ 'target' => '${ $.provider }:data.customer.website_id', + '__disableTmpl' => ['target' => false], 'field' => 'website_ids', ], ], @@ -1280,6 +1281,7 @@ private function getExpectationForVisibleAttributes() 'componentType' => Field::NAME, 'filterBy' => [ 'target' => '${ $.provider }:data.customer.website_id', + '__disableTmpl' => ['target' => false], 'field' => 'website_ids', ], ], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php index d917cc4908ac8..0d46cde3f6df5 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -93,7 +93,6 @@ public function testCreate() ] ], 'component' => 'Magento_Ui/js/grid/columns/column', - '__disableTmpl' => 'true' ], ], 'context' => $this->context, diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php index f3c0a56262622..6398d5af772ef 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php @@ -72,7 +72,6 @@ public function testCreate() 'config' => [ 'dataScope' => $filterName, 'label' => __('Label'), - '__disableTmpl' => 'true', 'options' => [['value' => 'Value', 'label' => 'Label']], 'caption' => __('Select...'), ], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php index 4a16acd98d827..576881bf37dae 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Ui\Component\Listing\Column\Actions; /** - * Class ActionsTest + * Class Actions test for Listing Colummn */ class ActionsTest extends \PHPUnit\Framework\TestCase { @@ -68,7 +68,6 @@ public function testPrepareDataSource() 'href' => 'http://magento.com/customer/index/edit', 'label' => new \Magento\Framework\Phrase('Edit'), 'hidden' => false, - '__disableTmpl' => true, ] ] ], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php index 02cacea5c2601..deec8ab7f7281 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php @@ -202,7 +202,6 @@ public function testPrepareDataSourceWithDefaultGroup() 'edit' => [ 'href' => static::STUB_GROUP_EDIT_URL, 'label' => __('Edit'), - '__disableTmpl' => true, ] ] ], @@ -213,7 +212,6 @@ public function testPrepareDataSourceWithDefaultGroup() 'edit' => [ 'href' => static::STUB_GROUP_EDIT_URL, 'label' => __('Edit'), - '__disableTmpl' => true, ] ] ] @@ -289,13 +287,11 @@ public function customerGroupsDataProvider(): array 'edit' => [ 'href' => static::STUB_GROUP_EDIT_URL, 'label' => __('Edit'), - '__disableTmpl' => true, ], 'delete' => [ 'href' => static::STUB_GROUP_DELETE_URL, 'label' => __('Delete'), 'post' => true, - '__disableTmpl' => true, 'confirm' => [ 'title' => __('Delete %1', 'General'), 'message' => __( diff --git a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php index a69e84ab41a2c..22f1a3315595b 100644 --- a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php +++ b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php @@ -77,7 +77,6 @@ public function create(array $attributeData, $columnName, $context, array $confi 'component' => $this->getJsComponent( $this->getDataType($attributeData[AttributeMetadata::FRONTEND_INPUT]) ), - '__disableTmpl' => 'true' ], $config ); diff --git a/app/code/Magento/Customer/Ui/Component/FilterFactory.php b/app/code/Magento/Customer/Ui/Component/FilterFactory.php index 3e57db06246d4..7575062dd23db 100644 --- a/app/code/Magento/Customer/Ui/Component/FilterFactory.php +++ b/app/code/Magento/Customer/Ui/Component/FilterFactory.php @@ -48,7 +48,6 @@ public function create(array $attributeData, $context) $config = [ 'dataScope' => $attributeData[AttributeMetadata::ATTRIBUTE_CODE], 'label' => __($attributeData[AttributeMetadata::FRONTEND_LABEL]), - '__disableTmpl' => 'true' ]; if ($attributeData[AttributeMetadata::OPTIONS]) { $config['options'] = $attributeData[AttributeMetadata::OPTIONS]; diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php index 9441beeb7dc61..d6a4067ef3db6 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php @@ -60,7 +60,6 @@ public function prepareDataSource(array $dataSource) ), 'label' => __('Edit'), 'hidden' => false, - '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php index e5a536dc6ecd6..459ac3e29e993 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php @@ -96,7 +96,6 @@ public function prepareDataSource(array $dataSource) ] ), 'label' => __('Edit'), - '__disableTmpl' => true ], ]; @@ -117,7 +116,6 @@ public function prepareDataSource(array $dataSource) ) ], 'post' => true, - '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php b/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php index e5739317bca8d..16caf346c808c 100644 --- a/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php +++ b/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php @@ -10,7 +10,9 @@ use Magento\Customer\Model\ResourceModel\Group\CollectionFactory; /** - * Class Options + * Class Options for Mass Action Group + * + * Disable template needed for customers */ class Options implements \JsonSerializable { diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php index a34ef79d70d30..813fcaf863412 100644 --- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php +++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php @@ -45,7 +45,7 @@ public function __construct(LocatorInterface $locator, ArrayManager $arrayManage } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -58,7 +58,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -97,7 +97,8 @@ protected function addMessageBox() 'visible' => false, 'imports' => [ 'visible' => '${$.provider}:' . self::DATA_SCOPE_PRODUCT . '.' - . ProductAttributeInterface::CODE_HAS_WEIGHT + . ProductAttributeInterface::CODE_HAS_WEIGHT, + '__disableTmpl' => ['visible' => false], ], ]; @@ -122,7 +123,8 @@ protected function addCheckboxIsDownloadable() 'sortOrder' => 10, 'imports' => [ 'disabled' => '${$.provider}:' . self::DATA_SCOPE_PRODUCT . '.' - . ProductAttributeInterface::CODE_HAS_WEIGHT + . ProductAttributeInterface::CODE_HAS_WEIGHT, + '__disableTmpl' => ['disabled' => false], ], 'valueMap' => [ 'false' => '0', @@ -130,6 +132,7 @@ protected function addCheckboxIsDownloadable() ], 'samplesFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_SAMPLES, 'linksFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_LINKS, + '__disableTmpl' => ['samplesFieldset' => false, 'linksFieldset' => false], ]; $this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $checkboxConfig); diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php index 8c98d871a12d2..d4c81763c7d11 100644 --- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php +++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php @@ -287,7 +287,8 @@ protected function getPriceColumn() 'imports' => [ 'linksPurchasedSeparately' => '${$.provider}:data.product' . '.links_purchased_separately', - 'useDefaultPrice' => '${$.parentName}.use_default_price:checked' + 'useDefaultPrice' => '${$.parentName}.use_default_price:checked', + '__disableTmpl' => ['linksPurchasedSeparately' => false, 'useDefaultPrice' => false], ], ]; @@ -485,6 +486,7 @@ protected function getMaxDownloadsColumn() ], 'exports' => [ 'checked' => '${$.parentName}.number_of_downloads:disabled', + '__disableTmpl' => ['checked' => false], ], ]; diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php index d0e24ce7c4aca..b00dfef81a705 100644 --- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php +++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php @@ -11,6 +11,9 @@ use Magento\Framework\Stdlib\ArrayManager; use Magento\Ui\Component\Form; +/** + * Class for Product Form Modifier User Default + */ class UsedDefault extends AbstractModifier { /** @@ -49,7 +52,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -57,7 +60,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -124,6 +127,7 @@ protected function priceUsedDefault() ], 'imports' => [ 'linksPurchasedSeparately' => '${$.provider}:data.product.links_purchased_separately', + '__disableTmpl' => ['linksPurchasedSeparately' => false], ], ]; $this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $useDefaultConfig); @@ -159,6 +163,7 @@ protected function titleUsedDefaultInGrid($indexTitle) ], 'exports' => [ 'checked' => '${$.parentName}.' . $indexTitle . ':disabled', + '__disableTmpl' => ['checked' => false], ], ]; $this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $useDefaultConfig); diff --git a/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php b/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php index fe2479d778992..63bf6705854f3 100644 --- a/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php +++ b/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php @@ -161,10 +161,12 @@ protected function customizeAllowGiftMessageField(array $meta) 'exports' => [ 'checked' => '${$.parentName}.' . static::FIELD_MESSAGE_AVAILABLE . ':isUseConfig', + '__disableTmpl' => ['checked' => false], ], 'imports' => [ 'disabled' => '${$.parentName}.' . static::FIELD_MESSAGE_AVAILABLE . ':isUseDefault', + '__disableTmpl' => ['disabled' => false], ] ], ], diff --git a/app/code/Magento/GroupedProduct/Ui/DataProvider/Product/Form/Modifier/Grouped.php b/app/code/Magento/GroupedProduct/Ui/DataProvider/Product/Form/Modifier/Grouped.php index 2ea622c1c2b8f..3ea8c6eb3c2b9 100644 --- a/app/code/Magento/GroupedProduct/Ui/DataProvider/Product/Form/Modifier/Grouped.php +++ b/app/code/Magento/GroupedProduct/Ui/DataProvider/Product/Form/Modifier/Grouped.php @@ -394,9 +394,11 @@ protected function getListing() 'externalFilterMode' => true, 'imports' => [ 'storeId' => '${ $.provider }:data.product.current_store_id', + '__disableTmpl' => ['storeId' => false], ], 'exports' => [ 'storeId' => '${ $.externalProvider }:params.current_store_id', + '__disableTmpl' => ['storeId' => false], ], ], ], @@ -499,7 +501,10 @@ protected function getGrid() 'attribute_set' => 'attribute_set_text', 'thumbnail' => 'thumbnail_src', ], - 'links' => ['insertData' => '${ $.provider }:${ $.dataProvider }'], + 'links' => [ + 'insertData' => '${ $.provider }:${ $.dataProvider }', + '__disableTmpl' => ['insertData' => false], + ], 'sortOrder' => 20, 'columnsHeader' => false, 'columnsHeaderAfterRender' => true, diff --git a/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php b/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php index 71e0384c72f79..b97cf2aa1fc2a 100644 --- a/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php +++ b/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php @@ -7,7 +7,7 @@ namespace Magento\Payment\Ui\Component\Listing\Column\Method; /** - * Class Options + * Class Options for Listing Column Method */ class Options implements \Magento\Framework\Data\OptionSourceInterface { @@ -43,13 +43,6 @@ public function toOptionArray() $this->options = $this->paymentHelper->getPaymentMethodList(true, true); } - array_walk( - $this->options, - function (&$item) { - $item['__disableTmpl'] = true; - } - ); - return $this->options; } } diff --git a/app/code/Magento/ReleaseNotification/Ui/DataProvider/Modifier/Notifications.php b/app/code/Magento/ReleaseNotification/Ui/DataProvider/Modifier/Notifications.php index e82d61d499663..f42aedd9634b5 100644 --- a/app/code/Magento/ReleaseNotification/Ui/DataProvider/Modifier/Notifications.php +++ b/app/code/Magento/ReleaseNotification/Ui/DataProvider/Modifier/Notifications.php @@ -18,6 +18,8 @@ /** * Modifies the metadata returning to the Release Notification data provider + * + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class Notifications implements ModifierInterface { @@ -91,7 +93,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -99,7 +101,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -149,6 +151,7 @@ private function buildNotificationMeta(array $meta, array $page, $isLastPage) 'actions' => [ [ 'targetName' => '${ $.name }', + '__disableTmpl' => ['targetName' => false], 'actionName' => 'closeReleaseNotes' ] ], @@ -232,6 +235,7 @@ private function unserializeContent($modalContent) /** * Returns the current Magento version used to retrieve the release notification content. + * * Version information after the dash (-) character is removed (ex. -dev or -rc). * * @return string diff --git a/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php b/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php index 5f1401a201e3f..13f726f711219 100644 --- a/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php +++ b/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php @@ -85,10 +85,12 @@ public function modifyMeta(array $meta) 'behaviourType' => 'simple', 'externalFilterMode' => true, 'imports' => [ - 'productId' => '${ $.provider }:data.product.current_product_id' + 'productId' => '${ $.provider }:data.product.current_product_id', + '__disableTmpl' => ['productId' => false], ], 'exports' => [ - 'productId' => '${ $.externalProvider }:params.current_product_id' + 'productId' => '${ $.externalProvider }:params.current_product_id', + '__disableTmpl' => ['productId' => false], ], ], ], diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php index fe285d29d703b..b3a419b1b6d97 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php @@ -10,7 +10,7 @@ use Magento\Sales\Ui\Component\Listing\Column\Status\Options; /** - * Class OptionsTest + * Class Options test for Listing Column Status */ class OptionsTest extends \PHPUnit\Framework\TestCase { @@ -54,7 +54,6 @@ public function testToOptionArray() [ 'value' => '1', 'label' => 'Label', - '__disableTmpl' => true ] ]; diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php index 14964f16b701e..680064596d0a7 100644 --- a/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php @@ -9,7 +9,7 @@ use Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory; /** - * Class Options + * Class Options for Listing Column Status */ class Options implements OptionSourceInterface { @@ -42,14 +42,6 @@ public function toOptionArray() { if ($this->options === null) { $options = $this->collectionFactory->create()->toOptionArray(); - - array_walk( - $options, - function (&$option) { - $option['__disableTmpl'] = true; - } - ); - $this->options = $options; } return $this->options; diff --git a/app/code/Magento/Search/Test/Unit/Ui/Component/Listing/Column/SynonymActionsTest.php b/app/code/Magento/Search/Test/Unit/Ui/Component/Listing/Column/SynonymActionsTest.php index d5563ec1cb289..5cf11e9babc25 100644 --- a/app/code/Magento/Search/Test/Unit/Ui/Component/Listing/Column/SynonymActionsTest.php +++ b/app/code/Magento/Search/Test/Unit/Ui/Component/Listing/Column/SynonymActionsTest.php @@ -112,7 +112,6 @@ public function testPrepareDataSourceWithItems() self::STUB_SYNONYM_GROUP_ID ) ], - '__disableTmpl' => true ], 'edit' => [ 'href' => sprintf( @@ -120,7 +119,6 @@ public function testPrepareDataSourceWithItems() self::STUB_SYNONYM_GROUP_ID ), 'label' => (string)__('View/Edit'), - '__disableTmpl' => true ] ] ] diff --git a/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php b/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php index f42ce50d2804b..2fd569642375e 100644 --- a/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php +++ b/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php @@ -64,12 +64,10 @@ public function prepareDataSource(array $dataSource) 'title' => __('Delete'), 'message' => __('Are you sure you want to delete synonym group with id: %1?', $item['group_id']) ], - '__disableTmpl' => true ]; $item[$name]['edit'] = [ 'href' => $this->urlBuilder->getUrl(self::SYNONYM_URL_PATH_EDIT, ['group_id' => $item['group_id']]), 'label' => __('View/Edit'), - '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php index 22cc1c9e89fbe..8d9b11771bb44 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php @@ -10,7 +10,7 @@ use Magento\Theme\Ui\Component\Listing\Column\EditAction; /** - * Class EditActionTest + * Class EditAction test for Listing Column */ class EditActionTest extends \PHPUnit\Framework\TestCase { @@ -67,7 +67,6 @@ public function testPrepareDataSource($dataSourceItem, $scope, $scopeId) 'edit' => [ 'href' => 'http://magento.com/theme/design_config/edit', 'label' => new \Magento\Framework\Phrase('Edit'), - '__disableTmpl' => true, ] ], ]; diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php index 5e2fe51043885..5995b84ef6874 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php @@ -112,7 +112,6 @@ public function getPrepareDataSourceDataProvider() 'view' => [ 'href' => 'url', 'label' => __('View'), - '__disableTmpl' => true, ] ], 'entity_id' => 1 @@ -139,7 +138,6 @@ public function getPrepareDataSourceDataProvider() 'view' => [ 'href' => 'url', 'label' => __('View'), - '__disableTmpl' => true, ] ], 'theme_id' => 2 diff --git a/app/code/Magento/Theme/Ui/Component/Design/Config/SearchRobots/ResetButton.php b/app/code/Magento/Theme/Ui/Component/Design/Config/SearchRobots/ResetButton.php index 5a8829851e8cf..4b71fc6faba15 100644 --- a/app/code/Magento/Theme/Ui/Component/Design/Config/SearchRobots/ResetButton.php +++ b/app/code/Magento/Theme/Ui/Component/Design/Config/SearchRobots/ResetButton.php @@ -76,6 +76,7 @@ public function prepare() [ 'actionName' => 'reset', 'targetName' => '${ $.name }', + '__disableTmpl' => ['targetName' => false], 'params' => [ json_encode($this->getRobotsDefaultCustomInstructions()) ] diff --git a/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php b/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php index 1eeeaccff88ce..821eee8114bae 100644 --- a/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php +++ b/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php @@ -13,7 +13,7 @@ use Magento\Ui\Component\Listing\Columns\Column; /** - * Class EditAction + * Class EditAction for Listing Column */ class EditAction extends Column { @@ -74,7 +74,6 @@ public function prepareDataSource(array $dataSource) ] ), 'label' => __('Edit'), - '__disableTmpl' => true, ] ]; } diff --git a/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php b/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php index 9e47e2c52bddf..a49e622b9d42a 100644 --- a/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php +++ b/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php @@ -14,7 +14,7 @@ use Magento\Ui\Component\Listing\Columns\Column; /** - * Class ViewAction + * Class ViewAction for Listing Column */ class ViewAction extends Column { @@ -66,7 +66,6 @@ public function prepareDataSource(array $dataSource) : array ] ), 'label' => __('View'), - '__disableTmpl' => true, ] ]; } diff --git a/app/code/Magento/Ui/Component/MassAction.php b/app/code/Magento/Ui/Component/MassAction.php index 5af263dd861ce..4cca8d4c012bb 100644 --- a/app/code/Magento/Ui/Component/MassAction.php +++ b/app/code/Magento/Ui/Component/MassAction.php @@ -28,7 +28,7 @@ public function prepare() if ($disabledAction) { continue; } - $config['actions'][] = array_merge($componentConfig, ['__disableTmpl' => true]); + $config['actions'][] = $componentConfig; } $origConfig = $this->getConfiguration(); diff --git a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php index c2e064bb3b069..f8560988168e6 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php @@ -10,7 +10,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; /** - * Class MassActionTest + * Class MassAction test for Component */ class MassActionTest extends \PHPUnit\Framework\TestCase { @@ -105,7 +105,6 @@ public function getPrepareDataProvider() 'type' => 'first_action', 'label' => 'First Action', 'url' => '/module/controller/firstAction', - '__disableTmpl' => true ], ], [ @@ -125,7 +124,6 @@ public function getPrepareDataProvider() 'url' => '/module/controller/secondSubAction2' ], ], - '__disableTmpl' => true ], ], ]; diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php index 9f121268135f8..7ca0e759c8408 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php @@ -23,6 +23,7 @@ public function testToOptionArray() $optionsToCompare = []; foreach ($options as $option) { if (is_array($option['value'])) { + //phpcs:ignore Magento2.Performance.ForeachArrayMerge $optionsToCompare = array_merge($optionsToCompare, $option['value']); } else { $optionsToCompare[] = $option; @@ -36,22 +37,18 @@ public function testToOptionArray() [ 'value' => 1, 'label' => 'Default (General)', - '__disableTmpl' => true, ], [ 'value' => 1, 'label' => 'General', - '__disableTmpl' => true, ], [ 'value' => 2, 'label' => 'Wholesale', - '__disableTmpl' => true, ], [ 'value' => 3, 'label' => 'Retailer', - '__disableTmpl' => true, ], ] ); From 550ce14ed21b2541daeb149c45b900c403656a65 Mon Sep 17 00:00:00 2001 From: Hwashiang Yu <hwyu@adobe.com> Date: Tue, 14 Apr 2020 20:45:20 -0500 Subject: [PATCH 138/455] MC-30175: UI component rendering config - Resolved static and unit test failures --- .../Unit/Ui/Component/Product/MassActionTest.php | 5 +++-- .../Product/Form/Modifier/AdvancedInventory.php | 2 -- .../Component/Listing/Column/BlockActionsTest.php | 2 +- .../Component/Listing/Column/PageActionsTest.php | 2 +- .../Model/Config/Source/Email/TemplateTest.php | 6 ++++-- .../Test/Unit/Model/Customer/DataProviderTest.php | 2 +- .../Test/Unit/Ui/Component/ColumnFactoryTest.php | 13 +++++++------ .../Test/Unit/Ui/Component/FilterFactoryTest.php | 11 ++++++----- .../Ui/Component/Listing/Column/ActionsTest.php | 7 ++++--- .../Listing/Column/Status/OptionsTest.php | 3 ++- .../Component/Listing/Column/EditActionTest.php | 7 ++++--- .../Component/Listing/Column/ViewActionTest.php | 3 ++- .../Ui/Test/Unit/Component/MassActionTest.php | 3 ++- .../Unit/View/Element/UiComponentFactoryTest.php | 15 ++++++++------- 14 files changed, 45 insertions(+), 36 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php index 966d5bc308c09..f34ebd2e1cf4d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php @@ -11,6 +11,7 @@ use Magento\Framework\AuthorizationInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Element\UiComponent\ContextInterface; +use PHPUnit\Framework\MockObject\MockObject; /** * MassAction test for Component Product @@ -18,7 +19,7 @@ class MassActionTest extends \PHPUnit\Framework\TestCase { /** - * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ContextInterface|MockObject */ private $contextMock; @@ -28,7 +29,7 @@ class MassActionTest extends \PHPUnit\Framework\TestCase private $objectManager; /** - * @var AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject + * @var AuthorizationInterface|MockObject */ private $authorizationMock; diff --git a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php index c8509f665876d..64db51132dc36 100644 --- a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php +++ b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php @@ -186,7 +186,6 @@ private function prepareMeta() if ($pathField) { $fieldsetPath = $this->arrayManager->slicePath($pathField, 0, -4); - $this->meta = $this->arrayManager->merge( $pathField . '/arguments/data/config', $this->meta, @@ -271,7 +270,6 @@ private function prepareMeta() 'qty' => $qty, 'advanced_inventory_button' => $advancedInventoryButton, ]; - $this->meta = $this->arrayManager->merge( $fieldsetPath . '/children', $this->meta, diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php index e38f7b7fc6704..e036e2a8ad200 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php @@ -11,7 +11,7 @@ use Magento\Framework\UrlInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponent\Processor; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; /** * BlockActionsTest contains unit tests for \Magento\Cms\Ui\Component\Listing\Column\BlockActions class. diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php index a6c0c4349707e..e187534f46ad5 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php @@ -15,7 +15,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponent\Processor; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; /** * Test for Magento\Cms\Ui\Component\Listing\Column\PageActions class. diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php index 76b9032de84e2..1fc730ccef30e 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php @@ -6,6 +6,8 @@ namespace Magento\Config\Test\Unit\Model\Config\Source\Email; +use PHPUnit\Framework\MockObject\MockObject; + /** * Test class for Template. */ @@ -17,12 +19,12 @@ class TemplateTest extends \PHPUnit\Framework\TestCase protected $_model; /** - * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Registry|MockObject */ protected $_coreRegistry; /** - * @var \Magento\Email\Model\Template\Config|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Email\Model\Template\Config|MockObject */ protected $_emailConfig; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php index 30fa27a48de70..f98759d3f067a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php @@ -26,7 +26,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Ui\Component\Form\Field; use Magento\Ui\DataProvider\EavValidationRules; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; /** * Unit tests for \Magento\Customer\Model\Customer\DataProvider class. diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php index 0d46cde3f6df5..8b926e8dfdec8 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -6,28 +6,29 @@ namespace Magento\Customer\Test\Unit\Ui\Component; use Magento\Customer\Ui\Component\ColumnFactory; +use PHPUnit\Framework\MockObject\MockObject; /** * Test ColumnFactory Class */ class ColumnFactoryTest extends \PHPUnit\Framework\TestCase { - /** @var \Magento\Customer\Api\Data\OptionInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Api\Data\OptionInterface|MockObject */ protected $attributeOption; - /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */ protected $context; - /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */ protected $componentFactory; - /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|MockObject */ protected $attributeMetadata; - /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|MockObject */ protected $column; - /** @var \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater|MockObject */ protected $inlineEditUpdater; /** @var ColumnFactory */ diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php index 6398d5af772ef..3a23cf66faddc 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php @@ -6,25 +6,26 @@ namespace Magento\Customer\Test\Unit\Ui\Component; use Magento\Customer\Ui\Component\FilterFactory; +use PHPUnit\Framework\MockObject\MockObject; /** * Test FilterFactory Class */ class FilterFactoryTest extends \PHPUnit\Framework\TestCase { - /** @var \Magento\Customer\Api\Data\OptionInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Api\Data\OptionInterface|MockObject */ protected $attributeOption; - /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */ protected $context; - /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */ protected $componentFactory; - /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|MockObject */ protected $attributeMetadata; - /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|MockObject */ protected $filter; /** @var FilterFactory */ diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php index 576881bf37dae..3792f0d214537 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php @@ -6,6 +6,7 @@ namespace Magento\Customer\Test\Unit\Ui\Component\Listing\Column; use Magento\Customer\Ui\Component\Listing\Column\Actions; +use PHPUnit\Framework\MockObject\MockObject; /** * Class Actions test for Listing Colummn @@ -15,13 +16,13 @@ class ActionsTest extends \PHPUnit\Framework\TestCase /** @var Actions */ protected $component; - /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */ protected $context; - /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */ protected $uiComponentFactory; - /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\UrlInterface|MockObject */ protected $urlBuilder; public function setup() diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php index b3a419b1b6d97..a62d62f96c560 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php @@ -8,6 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory; use Magento\Sales\Ui\Component\Listing\Column\Status\Options; +use PHPUnit\Framework\MockObject\MockObject; /** * Class Options test for Listing Column Status @@ -20,7 +21,7 @@ class OptionsTest extends \PHPUnit\Framework\TestCase protected $model; /** - * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var CollectionFactory|MockObject */ protected $collectionFactoryMock; diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php index 8d9b11771bb44..5cd27c58d6665 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php @@ -8,6 +8,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Store\Model\ScopeInterface; use Magento\Theme\Ui\Component\Listing\Column\EditAction; +use PHPUnit\Framework\MockObject\MockObject; /** * Class EditAction test for Listing Column @@ -17,13 +18,13 @@ class EditActionTest extends \PHPUnit\Framework\TestCase /** @var EditAction */ protected $component; - /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */ protected $context; - /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */ protected $uiComponentFactory; - /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\UrlInterface|MockObject */ protected $urlBuilder; public function setup() diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php index 5995b84ef6874..a7b5624236b2f 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php @@ -11,6 +11,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\UrlInterface; use Magento\Theme\Ui\Component\Listing\Column\ViewAction; +use PHPUnit\Framework\MockObject\MockObject; /** * Class ViewActionTest contains unit tests for \Magento\Theme\Ui\Component\Listing\Column\ViewAction class @@ -25,7 +26,7 @@ class ViewActionTest extends \PHPUnit\Framework\TestCase protected $model; /** - * @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject + * @var UrlInterface|MockObject */ protected $urlBuilder; diff --git a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php index f8560988168e6..5922055328fc1 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php @@ -8,6 +8,7 @@ use Magento\Ui\Component\MassAction; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Element\UiComponent\ContextInterface; +use PHPUnit\Framework\MockObject\MockObject; /** * Class MassAction test for Component @@ -15,7 +16,7 @@ class MassActionTest extends \PHPUnit\Framework\TestCase { /** - * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ContextInterface|MockObject */ protected $contextMock; diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php index 4f5c332269cf0..b4dddae673090 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Test\Unit\View\Element; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use PHPUnit\Framework\MockObject\MockObject; class UiComponentFactoryTest extends \PHPUnit\Framework\TestCase { @@ -15,25 +16,25 @@ class UiComponentFactoryTest extends \PHPUnit\Framework\TestCase /** @var ObjectManagerHelper */ protected $objectManagerHelper; - /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\ObjectManagerInterface|MockObject */ protected $objectManagerMock; - /** @var \Magento\Framework\Data\Argument\InterpreterInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Data\Argument\InterpreterInterface|MockObject */ protected $interpreterMock; - /** @var \Magento\Framework\View\Element\UiComponent\ContextFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextFactory|MockObject */ protected $contextFactoryMock; - /** @var \Magento\Framework\Config\DataInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Config\DataInterfaceFactory|MockObject */ protected $dataInterfaceFactoryMock; - /** @var \SafeReflectionClass|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \SafeReflectionClass|MockObject */ protected $safeReflectionClassMock; - /** @var \SafeReflectionClass|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \SafeReflectionClass|MockObject */ protected $safeReflectionClassMock2; - /** @var \Magento\Ui\Config\Reader\Definition\Data|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Ui\Config\Reader\Definition\Data|MockObject */ protected $dataMock; protected function setUp() From 99924e5c8260752d6be82b964edcde4ad062c75d Mon Sep 17 00:00:00 2001 From: Hwashiang Yu <hwyu@adobe.com> Date: Tue, 14 Apr 2020 20:57:21 -0500 Subject: [PATCH 139/455] MC-30175: UI component rendering config - Added changes from MC-21979 --- .../Form/Element/AbstractOptionsField.php | 22 ++- .../View/Element/UiComponent/ContextTest.php | 101 ++++++++++ .../View/Element/UiComponentFactoryTest.php | 168 ++++++++++++++++ .../View/Element/UiComponentFactoryTest.php | 7 +- .../Form/Element/MultiSelectTest.php | 89 +++++++++ .../View/Element/UiComponent/Context.php | 19 +- .../UiComponent/DataProvider/Sanitizer.php | 102 ++++++++++ .../View/Element/UiComponentFactory.php | 25 ++- .../DataProvider/SanitizerTest.php | 185 ++++++++++++++++++ 9 files changed, 700 insertions(+), 18 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponent/ContextTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponentFactoryTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Ui/Component/Form/Element/MultiSelectTest.php create mode 100644 lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/Sanitizer.php create mode 100644 lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/SanitizerTest.php diff --git a/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php b/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php index 586d76828ba3a..f1ff9db2dfde6 100644 --- a/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php +++ b/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php @@ -7,6 +7,7 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; /** * Base abstract form element. @@ -23,6 +24,11 @@ abstract class AbstractOptionsField extends AbstractElement */ protected $options; + /** + * @var Sanitizer + */ + private $sanitizer; + /** * Constructor * @@ -30,14 +36,17 @@ abstract class AbstractOptionsField extends AbstractElement * @param array|OptionSourceInterface|null $options * @param array $components * @param array $data + * @param Sanitizer|null $sanitizer */ public function __construct( ContextInterface $context, $options = null, array $components = [], - array $data = [] + array $data = [], + ?Sanitizer $sanitizer = null ) { $this->options = $options; + $this->sanitizer = $sanitizer ?? \Magento\Framework\App\ObjectManager::getInstance()->get(Sanitizer::class); parent::__construct($context, $components, $data); } @@ -62,13 +71,10 @@ public function prepare() if (empty($config['rawOptions'])) { $options = $this->convertOptionsValueToString($options); } - - array_walk( - $options, - function (&$item) { - $item['__disableTmpl'] = true; - } - ); + foreach ($options as &$option) { + //Options contain static or dynamic entity data that is not supposed to contain templates. + $option = $this->sanitizer->sanitize($option); + } $config['options'] = array_values(array_replace_recursive($config['options'], $options)); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponent/ContextTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponent/ContextTest.php new file mode 100644 index 0000000000000..b6c56795ebefe --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponent/ContextTest.php @@ -0,0 +1,101 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\View\Element\UiComponent; + +use Magento\Framework\Api\Search\SearchCriteria; +use Magento\Framework\App\RequestInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Magento\Ui\Component\Form; +use Magento\Ui\Component\FormFactory; +use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; + +/** + * Test UI component context. + */ +class ContextTest extends TestCase +{ + /** + * @var RequestInterface + */ + private $request; + + /** + * @var ContextFactory + */ + private $contextFactory; + + /** + * @var FormFactory + */ + private $componentFactory; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->request = Bootstrap::getObjectManager()->get(RequestInterface::class); + $this->contextFactory = Bootstrap::getObjectManager()->get(ContextFactory::class); + $this->componentFactory = Bootstrap::getObjectManager()->get(FormFactory::class); + } + + /** + * Generate provider for the test. + * + * @return DataProviderInterface + */ + private function generateMockProvider(): DataProviderInterface + { + /** @var DataProviderInterface|MockObject $mock */ + $mock = $this->getMockForAbstractClass(DataProviderInterface::class); + $mock->method('getName')->willReturn('test'); + $mock->method('getPrimaryFieldName')->willReturn('id'); + $mock->method('getRequestFieldName')->willReturn('id'); + $mock->method('getData')->willReturn(['id' => ['some_field' => '${\'some_value\'}']]); + $mock->method('getConfigData')->willReturn([]); + $mock->method('getFieldMetaInfo')->willReturn([]); + $mock->method('getFieldSetMetaInfo')->willReturn('id'); + $mock->method('getFieldsMetaInfo')->willReturn('id'); + $mock->method('getSearchCriteria')->willReturn(new SearchCriteria()); + $mock->method('getSearchResult')->willReturn([]); + + return $mock; + } + + /** + * Check processed provider data. + * + * @return void + */ + public function testGetDataSourceData(): void + { + $dataProvider = $this->generateMockProvider(); + $context = $this->contextFactory->create(['dataProvider' => $dataProvider]); + /** @var Form $component */ + $component = $this->componentFactory->create(['context' => $context]); + $this->request->setParams(['id' => 'id']); + + $data = $context->getDataSourceData($component); + $this->assertEquals( + [ + 'test' => [ + 'type' => 'dataSource', + 'name' => 'test', + 'dataScope' => null, + 'config' => [ + 'data' => ['some_field' => '${\'some_value\'}', '__disableTmpl' => ['some_field' => true]], + 'params' => ['namespace' => null]] + ] + ], + $data + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponentFactoryTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponentFactoryTest.php new file mode 100644 index 0000000000000..8a1064ffe6663 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponentFactoryTest.php @@ -0,0 +1,168 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\View\Element; + +use Magento\Framework\Api\Search\SearchCriteria; +use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Magento\Framework\Config\DataInterface as ConfigData; +use Magento\Framework\Config\DataInterfaceFactory as ConfigDataFactory; + +/** + * Test the component factory. + */ +class UiComponentFactoryTest extends TestCase +{ + /** + * @var UiComponentFactoryFactory + */ + private $factory; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->factory = Bootstrap::getObjectManager()->get(UiComponentFactoryFactory::class); + } + + /** + * Create factory with mock config provided. + * + * @param array $mockConfig + * @return UiComponentFactory + */ + private function createFactory(array $mockConfig): UiComponentFactory + { + $dataMock = $this->getMockForAbstractClass(ConfigData::class); + $dataMock->method('get')->willReturnCallback( + function (string $id) use ($mockConfig) : array { + return $mockConfig[$id]; + } + ); + $dataFactoryMock = $this->getMockBuilder(ConfigDataFactory::class) + ->disableOriginalConstructor() + ->getMock(); + $dataFactoryMock->method('create')->willReturn($dataMock); + + return $this->factory->create(['configFactory' => $dataFactoryMock]); + } + + /** + * Test creating a component. + * + * @return void + * @magentoAppArea adminhtml + */ + public function testCreate(): void + { + //Mocking component config. + $factory = $this->createFactory([ + 'test' => [ + 'arguments' => ['data' => ['config' => ['component' => 'uiComponent']]], + 'attributes' => [ + 'name' => 'test', + 'sorting' => true, + 'class' => 'Magento\Ui\Component\Listing', + 'component' => 'uiComponent' + ], + 'children' => [ + 'test_child' => [ + 'arguments' => [ + 'data' => ['config' => ['component' => 'uiComponent']], + 'dataProvider' => $this->generateMockProvider() + ], + 'attributes' => [ + 'name' => 'test_child', + 'sorting' => true, + 'class' => 'Magento\Ui\Component\Listing', + 'component' => 'uiComponent' + ], + 'children' => [] + ] + ] + ], + 'test_child_child' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'component' => 'uiComponent', + 'label' => '${\'Label\'}', + 'componentType' => 'component' + ] + ], + ], + 'attributes' => [ + 'name' => 'test_child_child', + 'sorting' => true, + 'class' => 'Magento\Ui\Component\Listing', + 'component' => 'uiComponent' + ], + 'children' => [] + ] + ]); + $component = $factory->create('test', null, ['data' => ['label' => '${\'Label\'}']]); + + $componentData = $component->getData(); + //Arguments passed must be sanitized + $this->assertArrayHasKey('__disableTmpl', $componentData); + $this->assertEquals(['label' => true], $componentData['__disableTmpl']); + //Metadata provided by the dataProvider must be sanitized as well. + $this->assertArrayHasKey('test_child_child', $childData = $component->getChildComponents()); + $childData = $component->getChildComponents()['test_child_child']->getData()['config']; + $this->assertArrayHasKey('__disableTmpl', $childData); + $this->assertEquals(['label' => true], $childData['__disableTmpl']); + } + + /** + * Generate provider for the test. + * + * @return DataProviderInterface + */ + private function generateMockProvider(): DataProviderInterface + { + /** @var DataProviderInterface|MockObject $mock */ + $mock = $this->getMockForAbstractClass(DataProviderInterface::class); + $mock->method('getName')->willReturn('test'); + $mock->method('getPrimaryFieldName')->willReturn('id'); + $mock->method('getRequestFieldName')->willReturn('id'); + $mock->method('getData')->willReturn([]); + $mock->method('getConfigData')->willReturn([]); + $mock->method('getFieldMetaInfo')->willReturn([]); + $mock->method('getFieldSetMetaInfo')->willReturn('id'); + $mock->method('getFieldsMetaInfo')->willReturn('id'); + $mock->method('getSearchCriteria')->willReturn(new SearchCriteria()); + $mock->method('getSearchResult')->willReturn([]); + $mock->method('getMeta')->willReturn( + [ + 'test_child_child' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'component' => 'uiComponent', + 'label' => '${\'Label\'}', + 'componentType' => 'component' + ] + ], + ], + 'attributes' => [ + 'name' => 'test_child_child', + 'sorting' => true, + 'class' => 'Magento\Ui\Component\Listing', + 'component' => 'uiComponent' + ] + ] + ] + ); + + return $mock; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php index b4dddae673090..05c12eee3418a 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Test\Unit\View\Element; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; use PHPUnit\Framework\MockObject\MockObject; class UiComponentFactoryTest extends \PHPUnit\Framework\TestCase @@ -59,6 +60,9 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); $this->dataMock = $this->createMock(\Magento\Framework\Config\DataInterface::class); + $sanitizerMock = $this->createMock(Sanitizer::class); + $sanitizerMock->method('sanitize')->willReturnArgument(0); + $sanitizerMock->method('sanitizeComponentMetadata')->willReturnArgument(0); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject( \Magento\Framework\View\Element\UiComponentFactory::class, @@ -69,7 +73,8 @@ protected function setUp() 'configFactory' => $this->dataInterfaceFactoryMock, 'data' => [], 'componentChildFactories' => [], - 'definitionData' => $this->dataMock + 'definitionData' => $this->dataMock, + 'sanitizer' => $sanitizerMock ] ); } diff --git a/dev/tests/integration/testsuite/Magento/Ui/Component/Form/Element/MultiSelectTest.php b/dev/tests/integration/testsuite/Magento/Ui/Component/Form/Element/MultiSelectTest.php new file mode 100644 index 0000000000000..6c7e369419a55 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Ui/Component/Form/Element/MultiSelectTest.php @@ -0,0 +1,89 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Ui\Component\Form\Element; + +use Magento\Framework\Data\OptionSourceInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test MultiSelect component. + */ +class MultiSelectTest extends TestCase +{ + /** + * @var MultiSelectFactory + */ + private $factory; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->factory = Bootstrap::getObjectManager()->get(MultiSelectFactory::class); + } + + /** + * Options data to verify + * + * @return array + */ + public function getTestOptions(): array + { + return [ + 'List' => [ + [ + ['value' => '${\'my-value\'}', 'label' => 'My label'], + ['value' => '1', 'label' => 'Label'], + ['value' => '${\'my-value-2\'}', 'label' => 'This is ${\'My label\'}'] + ], + [ + ['value' => '${\'my-value\'}', 'label' => 'My label', '__disableTmpl' => ['value' => true]], + ['value' => '1', 'label' => 'Label'], + [ + 'value' => '${\'my-value-2\'}', + 'label' => 'This is ${\'My label\'}', + '__disableTmpl' => ['value' => true, 'label' => true] + ] + ] + ], + 'provider' => [ + new class implements OptionSourceInterface + { + /** + * @inheritDoc + */ + public function toOptionArray() + { + return [['value' => '${\'value\'}', 'label' => 'Test']]; + } + }, + [['value' => '${\'value\'}', 'label' => 'Test', '__disableTmpl' => ['value' => true]]] + ] + ]; + } + + /** + * Check that options received from an options provider properly initiated. + * + * @param array|OptionSourceInterface $options Options provided + * @param array $expected Expected initialized options + * @return void + * @dataProvider getTestOptions + */ + public function testOptions($options, array $expected): void + { + /** @var MultiSelect $component */ + $component = $this->factory->create(['options' => $options]); + $component->prepare(); + + $this->assertEquals($expected, $component->getData('config')['options']); + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php index fbb84712b2afd..8f980d82d4be0 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php @@ -15,12 +15,13 @@ use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderFactory; use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Framework\View\Element\UiComponentInterface; use Magento\Framework\View\LayoutInterface as PageLayoutInterface; /** - * Class Context + * Request context for UI components to utilize. * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ @@ -101,6 +102,11 @@ class Context implements ContextInterface */ private $authorization; + /** + * @var Sanitizer + */ + private $sanitizer; + /** * @param PageLayoutInterface $pageLayout * @param RequestInterface $request @@ -113,6 +119,7 @@ class Context implements ContextInterface * @param DataProviderInterface|null $dataProvider * @param string $namespace * @param AuthorizationInterface|null $authorization + * @param Sanitizer|null $sanitizer * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -126,7 +133,8 @@ public function __construct( UiComponentFactory $uiComponentFactory, DataProviderInterface $dataProvider = null, $namespace = null, - AuthorizationInterface $authorization = null + AuthorizationInterface $authorization = null, + ?Sanitizer $sanitizer = null ) { $this->namespace = $namespace; $this->request = $request; @@ -141,6 +149,7 @@ public function __construct( $this->authorization = $authorization ?: ObjectManager::getInstance()->get( AuthorizationInterface::class ); + $this->sanitizer = $sanitizer ?? ObjectManager::getInstance()->get(Sanitizer::class); $this->setAcceptType(); } @@ -241,16 +250,20 @@ public function getDataProvider() */ public function getDataSourceData(UiComponentInterface $component) { + //Getting dynamic data for the component $dataSource = $component->getDataSourceData(); $this->prepareDataSource($dataSource, $component); $dataProviderConfig = $this->getDataProvider()->getConfigData(); + //Dynamic UI component data should not contain templates. + $config = $this->sanitizer->sanitize(array_merge($dataSource, $dataProviderConfig)); + return [ $this->getDataProvider()->getName() => [ 'type' => 'dataSource', 'name' => $this->getDataProvider()->getName(), 'dataScope' => $this->getNamespace(), 'config' => array_replace_recursive( - array_merge($dataSource, $dataProviderConfig), + $config, [ 'params' => [ 'namespace' => $this->getNamespace() diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/Sanitizer.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/Sanitizer.php new file mode 100644 index 0000000000000..27a42fb337ce8 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/Sanitizer.php @@ -0,0 +1,102 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\View\Element\UiComponent\DataProvider; + +use Magento\Framework\Phrase; + +/** + * Sanitizes data received from UI data providers. + */ +class Sanitizer +{ + /** + * Extract rendering config from given UI data. + * + * @param array $data + * @return bool|array + */ + private function extractConfig(array $data) + { + /** @var array|bool $config */ + $config = []; + if (array_key_exists('__disableTmpl', $data)) { + //UI data provider has explicitly provided rendering config. + $config = $data['__disableTmpl']; + unset($data['__disableTmpl']); + } + + return $config; + } + + /** + * Sanitizes data from a UI data provider. + * + * @param array $data + * @return array + */ + public function sanitize(array $data): array + { + $config = $this->extractConfig($data); + $toProcess = []; + array_walk( + $data, + function ($datum, string $key) use (&$config, &$toProcess) : void { + if (is_array($datum)) { + //Each array must have it's own __disableTmpl property + $toProcess[$key] = $datum; + } elseif (( + !is_bool($config) && !array_key_exists($key, $config) + ) + && (is_string($datum) || $datum instanceof Phrase) + && preg_match('/\$\{.+\}/', (string)$datum) + ) { + //Templating is not disabled for all properties or for this property specifically + //Property is a string that contains template syntax so we are disabling it's rendering + $config[$key] = true; + } + } + ); + if ($toProcess) { + //Processing sub-arrays + $data = array_replace($data, array_map([$this, 'sanitize'], $toProcess)); + } + if ($config !== []) { + //Some properties require rendering configuration. + $data['__disableTmpl'] = $config; + } + + return $data; + } + + /** + * Sanitize a component's metadata. + * + * Will sanitize full component's metadata as well as metadata of it's child components. + * + * @param array $meta + * @return array + */ + public function sanitizeComponentMetadata(array $meta): array + { + if (array_key_exists('arguments', $meta) + && is_array($meta['arguments']) + && array_key_exists('data', $meta['arguments']) + && is_array($meta['arguments']['data']) + && array_key_exists('config', $meta['arguments']['data']) + && is_array($meta['arguments']['data']['config']) + ) { + $meta['arguments']['data']['config'] = $this->sanitize($meta['arguments']['data']['config']); + } + if (array_key_exists('children', $meta) && is_array($meta['children'])) { + $meta['children'] = array_map([$this, 'sanitizeComponentMetadata'], $meta['children']); + } + + return $meta; + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php index b395e95f0baaf..16c06fe3abf3a 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php @@ -17,10 +17,11 @@ use Magento\Framework\View\Element\UiComponent\ContextFactory; use Magento\Framework\Phrase; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; use Magento\Framework\View\Element\UiComponent\Factory\ComponentFactoryInterface; /** - * Class UiComponentFactory + * Factory that creates UI component descriptor based on configuration provided. * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -69,6 +70,11 @@ class UiComponentFactory extends DataObject */ private $definitionData; + /** + * @var Sanitizer + */ + private $sanitizer; + /** * @param ObjectManagerInterface $objectManager * @param ManagerInterface $componentManager @@ -78,6 +84,7 @@ class UiComponentFactory extends DataObject * @param array $componentChildFactories * @param DataInterface $definitionData * @param DataInterfaceFactory $configFactory + * @param Sanitizer|null $sanitizer */ public function __construct( ObjectManagerInterface $objectManager, @@ -87,7 +94,8 @@ public function __construct( array $data = [], array $componentChildFactories = [], DataInterface $definitionData = null, - DataInterfaceFactory $configFactory = null + DataInterfaceFactory $configFactory = null, + ?Sanitizer $sanitizer = null ) { $this->objectManager = $objectManager; $this->componentManager = $componentManager; @@ -98,6 +106,7 @@ public function __construct( parent::__construct($data); $this->definitionData = $definitionData ?: $this->objectManager->get(DataInterface::class); + $this->sanitizer = $sanitizer ?? $this->objectManager->get(Sanitizer::class); } /** @@ -198,8 +207,12 @@ protected function argumentsResolver($identifier, array $componentData) */ public function create($identifier, $name = null, array $arguments = []) { + //$argument contain dynamic data generated by UI component classes which should not contain templates. + $arguments = $this->sanitizer->sanitize($arguments); if ($name === null) { - $componentData = $this->configFactory->create(['componentName' => $identifier])->get($identifier); + /** @var DataInterface $config */ + $config = $this->configFactory->create(['componentName' => $identifier]); + $componentData = $config->get($identifier); $bundleComponents = [$identifier => $componentData]; list($className, $componentArguments) = $this->argumentsResolver( @@ -312,10 +325,10 @@ protected function mergeMetadata($identifier, array $bundleComponents, $reverseM { $dataProvider = $this->getDataProvider($identifier, $bundleComponents); if ($dataProvider instanceof DataProviderInterface) { + //Dynamic meta from data providers should not contain templates. + $metadata = $dataProvider->getMeta(); $metadata = [ - $identifier => [ - 'children' => $dataProvider->getMeta(), - ], + $identifier => $this->sanitizer->sanitizeComponentMetadata(['children' => $metadata]) ]; $bundleComponents = $this->mergeMetadataItem($bundleComponents, $metadata, $reverseMerge); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/SanitizerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/SanitizerTest.php new file mode 100644 index 0000000000000..75fbfd868cfc1 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/SanitizerTest.php @@ -0,0 +1,185 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\View\Test\Unit\Element\UiComponent\DataProvider; + +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; +use PHPUnit\Framework\TestCase; + +/** + * Test sanitizer for different kind of scenarios. + */ +class SanitizerTest extends TestCase +{ + /** + * @var Sanitizer + */ + private $sanitizer; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->sanitizer = new Sanitizer(); + } + + /** + * Data sets to sanitize. + * + * @return array + */ + public function getSanitizeDataSets(): array + { + return [ + 'simpleSet' => [ + ['foo' => '${\'bar\'}', 'xyz' => 42], + ['foo' => '${\'bar\'}', 'xyz' => 42, '__disableTmpl' => ['foo' => true]] + ], + 'configuredSet' => [ + ['foo' => 'bar', 'xyz' => '${\'zyx\'}', '__disableTmpl' => true], + ['foo' => 'bar', 'xyz' => '${\'zyx\'}', '__disableTmpl' => true] + ], + 'partiallyConfiguredSet' => [ + ['foo' => '${\'bar\'}', 'xyz' => '${\'zyx\'}', '__disableTmpl' => ['foo' => false]], + ['foo' => '${\'bar\'}', 'xyz' => '${\'zyx\'}', '__disableTmpl' => ['foo' => false, 'xyz' => true]] + ], + 'enabledSet' => [ + ['foo' => 'bar', 'xyz' => '${\'zyx\'}', '__disableTmpl' => false], + ['foo' => 'bar', 'xyz' => '${\'zyx\'}', '__disableTmpl' => false] + ], + 'complexSet' => [ + [ + 'foo' => 'bar', + 'sub1' => ['foo' => '${\'bar\'}'], + 'sub2' => [ + 'field' => '${\'value\'}', + 'subSub1' => ['foo' => 'bar'], + 'subSub2' => ['foo' => '${\'bar\'}', '__disableTmpl' => false], + 'subSub3' => [ + 'fooSub' => [ + 'foo' => '${\'bar\'}', + '__disableTmpl' => false, + 'subSubSub1' => ['field' => '${\'value\'}'] + ] + ], + 'subSub4' => [['foo' => '${\'bar\'}'], ['foo' => '${\'bar\'}', 'xyz' => '${\'zyx\'}']] + ] + ], + [ + 'foo' => 'bar', + 'sub1' => ['foo' => '${\'bar\'}', '__disableTmpl' => ['foo' => true]], + 'sub2' => [ + 'field' => '${\'value\'}', + 'subSub1' => ['foo' => 'bar'], + 'subSub2' => ['foo' => '${\'bar\'}', '__disableTmpl' => false], + 'subSub3' => [ + 'fooSub' => [ + 'foo' => '${\'bar\'}', + '__disableTmpl' => false, + 'subSubSub1' => ['field' => '${\'value\'}', '__disableTmpl' => ['field' => true]] + ] + ], + 'subSub4' => [ + ['foo' => '${\'bar\'}', '__disableTmpl' => ['foo' => true]], + [ + 'foo' => '${\'bar\'}', + 'xyz' => '${\'zyx\'}', + '__disableTmpl' => ['foo' => true, 'xyz' => true] + ] + ], + '__disableTmpl' => ['field' => true] + ] + ] + ] + ]; + } + + /** + * Test sanitize method for different data sets. + * + * @param array $input + * @param array $expectedOutput + * @return void + * @dataProvider getSanitizeDataSets + */ + public function testSanitize(array $input, array $expectedOutput): void + { + $this->assertEquals($expectedOutput, $this->sanitizer->sanitize($input)); + } + + /** + * Full UI component data sets to sanitize. + * + * @return array + */ + public function getSanitizeComponentDataSets(): array + { + return [ + 'simpleComponent' => [ + [ + 'arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}', 'xyz' => 42]]], + 'children' => [ + 'child_component' => [ + 'arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}', 'xyz' => '${\'xyz\'}']]] + ] + ] + ], + [ + 'arguments' => [ + 'data' => [ + 'config' => ['foo' => '${\'bar\'}', 'xyz' => 42, '__disableTmpl' => ['foo' => true]] + ] + ], + 'children' => [ + 'child_component' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'foo' => '${\'bar\'}', + 'xyz' => '${\'xyz\'}', + '__disableTmpl' => ['foo' => true, 'xyz' => true] + ] + ] + ] + ] + ] + ] + ], + 'argumentsOnly' => [ + ['arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}']]]], + ['arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}', '__disableTmpl' => ['foo' => true]]]]] + ], + 'childrenOnly' => [ + ['children' => ['child1' => ['arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}']]]]]], + [ + 'children' => [ + 'child1' => [ + 'arguments' => [ + 'data' => ['config' => ['foo' => '${\'bar\'}', '__disableTmpl' => ['foo' => true]]] + ] + ] + ] + ] + ] + ]; + } + + /** + * Test sanitizeComponentMetadata method for different data sets. + * + * @param array $input + * @param array $expectedOutput + * @return void + * @dataProvider getSanitizeComponentDataSets + */ + public function testSanitizeComponentMetadata(array $input, array $expectedOutput): void + { + $this->assertEquals($expectedOutput, $this->sanitizer->sanitizeComponentMetadata($input)); + } +} From 50d7d2ff6445e4b1bbf27737ee0feaa0f34bef48 Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Wed, 15 Apr 2020 10:18:59 +0530 Subject: [PATCH 140/455] Code review changes --- .../Test/Mftf/ActionGroup/AdminBackupDeleteActionGroup.xml | 2 +- .../Test/Mftf/ActionGroup/deleteBackupActionGroup.xml | 2 +- .../Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml | 6 +++--- .../Mftf/Test/ProductQuickSearchUsingElasticSearchTest.xml | 2 +- .../AdminIndexerSetUpdateOnSaveActionGroup.xml | 2 +- .../Store/Test/Mftf/Test/AdminDeleteStoreGroupTest.xml | 2 +- .../Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Backup/Test/Mftf/ActionGroup/AdminBackupDeleteActionGroup.xml b/app/code/Magento/Backup/Test/Mftf/ActionGroup/AdminBackupDeleteActionGroup.xml index 03d38f6834c72..a5ecc44509604 100644 --- a/app/code/Magento/Backup/Test/Mftf/ActionGroup/AdminBackupDeleteActionGroup.xml +++ b/app/code/Magento/Backup/Test/Mftf/ActionGroup/AdminBackupDeleteActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminBackupDelete"> + <actionGroup name="AdminBackupDeleteActionGroup"> <annotations> <description>Deletes a Backup using provided Backup Entity.</description> </annotations> diff --git a/app/code/Magento/Backup/Test/Mftf/ActionGroup/deleteBackupActionGroup.xml b/app/code/Magento/Backup/Test/Mftf/ActionGroup/deleteBackupActionGroup.xml index 9050d3c334ab5..b879a2aa9647a 100644 --- a/app/code/Magento/Backup/Test/Mftf/ActionGroup/deleteBackupActionGroup.xml +++ b/app/code/Magento/Backup/Test/Mftf/ActionGroup/deleteBackupActionGroup.xml @@ -8,5 +8,5 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="deleteBackup" extends="DeleteBackupActionGroup" deprecated="Use DeleteBackupActionGroup"/> + <actionGroup name="deleteBackup" extends="AdminBackupDeleteActionGroup" deprecated="Use DeleteBackupActionGroup"/> </actionGroups> diff --git a/app/code/Magento/Backup/Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml b/app/code/Magento/Backup/Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml index 55e8244a7a19d..17716a4aa11d2 100644 --- a/app/code/Magento/Backup/Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml +++ b/app/code/Magento/Backup/Test/Mftf/Test/AdminCreateAndDeleteBackupsTest.xml @@ -39,17 +39,17 @@ <actionGroup ref="CreateDatabaseBackupActionGroup" stepKey="createDatabaseBackup"/> <!--Delete system backup--> - <actionGroup ref="AdminBackupDelete" stepKey="deleteSystemBackup"> + <actionGroup ref="AdminBackupDeleteActionGroup" stepKey="deleteSystemBackup"> <argument name="backup" value="SystemBackup"/> </actionGroup> <!--Delete database/media backup--> - <actionGroup ref="AdminBackupDelete" stepKey="deleteMediaBackup"> + <actionGroup ref="AdminBackupDeleteActionGroup" stepKey="deleteMediaBackup"> <argument name="backup" value="MediaBackup"/> </actionGroup> <!--Delete database backup--> - <actionGroup ref="AdminBackupDelete" stepKey="deleteDatabaseBackup"> + <actionGroup ref="AdminBackupDeleteActionGroup" stepKey="deleteDatabaseBackup"> <argument name="backup" value="DatabaseBackup"/> </actionGroup> diff --git a/app/code/Magento/Elasticsearch/Test/Mftf/Test/ProductQuickSearchUsingElasticSearchTest.xml b/app/code/Magento/Elasticsearch/Test/Mftf/Test/ProductQuickSearchUsingElasticSearchTest.xml index 4b959b043be2b..b9310b6c1c207 100644 --- a/app/code/Magento/Elasticsearch/Test/Mftf/Test/ProductQuickSearchUsingElasticSearchTest.xml +++ b/app/code/Magento/Elasticsearch/Test/Mftf/Test/ProductQuickSearchUsingElasticSearchTest.xml @@ -30,7 +30,7 @@ <deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/> <deleteData createDataKey="categoryFirst" stepKey="deleteCategory"/> <comment userInput="The test was moved to elasticsearch suite" stepKey="resetCatalogSearchConfiguration"/> - <actionGroup ref="AdminIndexerSetUpdateOnSave" stepKey="resetIndexerBackToOriginalState"> + <actionGroup ref="AdminIndexerSetUpdateOnSaveActionGroup" stepKey="resetIndexerBackToOriginalState"> <argument name="indexerName" value="catalogsearch_fulltext"/> </actionGroup> <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/> diff --git a/app/code/Magento/Indexer/Test/Mftf/ActionGroup/IndexerActionGroup/AdminIndexerSetUpdateOnSaveActionGroup.xml b/app/code/Magento/Indexer/Test/Mftf/ActionGroup/IndexerActionGroup/AdminIndexerSetUpdateOnSaveActionGroup.xml index 7cd374b56cb1e..bc6bf62172612 100644 --- a/app/code/Magento/Indexer/Test/Mftf/ActionGroup/IndexerActionGroup/AdminIndexerSetUpdateOnSaveActionGroup.xml +++ b/app/code/Magento/Indexer/Test/Mftf/ActionGroup/IndexerActionGroup/AdminIndexerSetUpdateOnSaveActionGroup.xml @@ -7,7 +7,7 @@ --> <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminIndexerSetUpdateOnSave"> + <actionGroup name="AdminIndexerSetUpdateOnSaveActionGroup"> <annotations> <description>Goes to the Index Management page. Checks the provided Indexer Name. Selects 'Update on Save'. Clicks on Submit.</description> </annotations> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreGroupTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreGroupTest.xml index 123b645166e6a..3f7f2ebe2c69b 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreGroupTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreGroupTest.xml @@ -48,7 +48,7 @@ <waitForPageLoad stepKey="waitForBackupIndexPageLoad"/> <see selector="{{AdminGridTableSection.backupNameColumn}}" userInput="{{WebSetupWizardBackup.name}}" stepKey="seeBackupInGrid"/> <!--Delete database backup--> - <actionGroup ref="AdminBackupDelete" stepKey="deleteDatabaseBackup"> + <actionGroup ref="AdminBackupDeleteActionGroup" stepKey="deleteDatabaseBackup"> <argument name="backup" value="WebSetupWizardBackup"/> </actionGroup> </test> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml index be1e5862648f1..ede3319a88970 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml @@ -46,7 +46,7 @@ <waitForPageLoad stepKey="waitForBackupIndexPageLoad"/> <see selector="{{AdminGridTableSection.backupNameColumn}}" userInput="{{WebSetupWizardBackup.name}}" stepKey="seeBackupInGrid"/> <!--Delete database backup--> - <actionGroup ref="AdminBackupDelete" stepKey="deleteDatabaseBackup"> + <actionGroup ref="AdminBackupDeleteActionGroup" stepKey="deleteDatabaseBackup"> <argument name="backup" value="WebSetupWizardBackup"/> </actionGroup> From 68af020fea0090428ef24823564f4449aaf33908 Mon Sep 17 00:00:00 2001 From: Andrii Meysar <andrii.meysar@transoftgroup.com> Date: Wed, 15 Apr 2020 09:14:11 +0300 Subject: [PATCH 141/455] MC-33100: Fix AdminDeleteCustomerActionGroup, IdentityOfDefaultBillingAndShippingAddressTest. --- .../IdentityOfDefaultBillingAndShippingAddressTest.xml | 8 ++++---- .../Mftf/ActionGroup/AdminDeleteCustomerActionGroup.xml | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml index 9c630fb0dfbd6..e64a78acd3ab5 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml @@ -75,18 +75,18 @@ <actionGroup ref="AssertThatShippingAndBillingAddressTheSame" stepKey="assertThatShippingAndBillingAddressTheSame"/> <after> - <!-- Logout Customer --> - <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/> - <!-- Delete created Product --> <deleteData stepKey="deleteProduct" createDataKey="createProduct"/> + <!-- Logout Customer --> + <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/> + <!-- Delete Customer --> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <actionGroup ref="AdminDeleteCustomerActionGroup" stepKey="deleteCustomerFromAdmin"> <argument name="customerEmail" value="Simple_US_Customer_NY.email"/> </actionGroup> - <actionGroup ref="AdminClearCustomersFiltersActionGroup" stepKey="clearCustomersGridFilter"/> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearCustomersGridFilter"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/> </after> </test> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminDeleteCustomerActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminDeleteCustomerActionGroup.xml index 87c612db08698..6cffb58df75bd 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminDeleteCustomerActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminDeleteCustomerActionGroup.xml @@ -28,6 +28,8 @@ <click stepKey="delete" selector="{{AdminCustomerGridMainActionsSection.delete}}"/> <waitForPageLoad stepKey="waitForConfirmationAlert"/> <click stepKey="accept" selector="{{AdminCustomerGridMainActionsSection.ok}}"/> - <see stepKey="seeSuccessMessage" userInput="were deleted."/> + <waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="waitForSuccessMessage"/> + <see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) were deleted." stepKey="seeSuccessMessage"/> + <waitForPageLoad stepKey="waitForCustomersGridIsLoaded"/> </actionGroup> </actionGroups> From 8f10a8f392784df37c6d218435ea2b4118c7eb9c Mon Sep 17 00:00:00 2001 From: Andrii Meysar <andrii.meysar@transoftgroup.com> Date: Wed, 15 Apr 2020 09:37:56 +0300 Subject: [PATCH 142/455] MC-33100: Fix IdentityOfDefaultBillingAndShippingAddressTest testCaseId. --- .../Test/IdentityOfDefaultBillingAndShippingAddressTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml index e64a78acd3ab5..2fef407d94a87 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml @@ -15,7 +15,7 @@ <title value="Checking assignment of default billing address after placing an order"/> <description value="In 'Address book' field 'Default Billing Address' should be the same as 'Default Shipping Address'"/> <severity value="MAJOR"/> - <testCaseId value="MAGETWO-94108"/> + <testCaseId value="MC-25738"/> <useCaseId value="MAGETWO-62891"/> <group value="checkout"/> <group value="customer"/> From d102b9ed83498b4deaac0163ee2c51e35fbfd97f Mon Sep 17 00:00:00 2001 From: Ihor Vansach <ihor@magefan.com> Date: Wed, 28 Jun 2017 20:53:37 +0300 Subject: [PATCH 143/455] Up version to 2.1.2 --- composer.json | 2 +- etc/module.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 01f8aab441a2f..41fb373ef8e88 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magefan/module-login-as-customer", "description": "N/A", "type": "magento2-module", - "version": "2.1.1", + "version": "2.1.2", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index 10903262b9542..1143d72738835 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magefan_LoginAsCustomer" setup_version="2.1.1"> + <module name="Magefan_LoginAsCustomer" setup_version="2.1.2"> <sequence> <module name="Magento_Customer"/> </sequence> From 0ebb4ff86ac8c6c47ccbd92b0f9f0d51e8a2012d Mon Sep 17 00:00:00 2001 From: Magefan <ihoronesuch@gmail.com> Date: Thu, 28 Sep 2017 20:44:36 +0300 Subject: [PATCH 144/455] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f0b245ab6b1e..8c9ee4ce47beb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,41 @@ -# Login-As-Customer-for-Magento-2 +# [Magento 2 Login As Customer](https://magefan.com/login-as-customer-magento-2-extension) by Magefan + Allows admin to login as a customer (enter to customer account). + +## Requirements + * Magento Community Edition 2.0.x-2.2.x or Magento Enterprise Edition 2.0.x-2.2.x + +## Installation Method 1 - Installing via composer + * Open command line + * Using command "cd" navigate to your magento2 root directory + * Run command: composer require magefan/module-login-as-customer + + + +## Installation Method 2 - Installing using archive + * Download [ZIP Archive](https://github.com/magefan/module-login-as-customer/archive/master.zip) + * Extract files + * In your Magento 2 root directory create folder app/code/Magefan/LoginAsCustomer + * Copy files and folders from archive to that folder + * In command line, using "cd", navigate to your Magento 2 root directory + * Run commands: +``` +php bin/magento setup:upgrade +php bin/magento setup:di:compile +php bin/magento setup:static-content:deploy +``` + +## Support +If you have any issues, please [contact us](mailto:support@magefan.com) +then if you still need help, open a bug report in GitHub's +[issue tracker](https://github.com/magefan/module-login-as-customer/issues). + +Please do not use Magento Marketplace Reviews or (especially) the Q&A for support. +There isn't a way for us to reply to reviews and the Q&A moderation is very slow. + +## Need More Features? +Please contact us to get a quote +https://magefan.com/contact + +## License +The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php). From 3443504cfd389dcf6772e38d89adaa8067ee32bc Mon Sep 17 00:00:00 2001 From: Ihor Vansach <ihor@magefan.com> Date: Fri, 6 Oct 2017 23:22:34 +0300 Subject: [PATCH 145/455] Added php requirements --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 41fb373ef8e88..a4a43a41decd0 100755 --- a/composer.json +++ b/composer.json @@ -1,6 +1,9 @@ { "name": "magefan/module-login-as-customer", "description": "N/A", + "require": { + "php": "~5.6.5|7.0.2|7.0.4|~7.0.6|7.1.0|7.1.1|7.1.2|7.1.3|7.1.4|7.1.5|7.1.6|7.1.7|7.1.8|7.1.9" + }, "type": "magento2-module", "version": "2.1.2", "license": [ From b76c8c9c684ac073fd40bfd7ecd0f1b5177955a4 Mon Sep 17 00:00:00 2001 From: Ihor Vansach <ihor@magefan.com> Date: Fri, 13 Oct 2017 13:25:58 +0300 Subject: [PATCH 146/455] Fix for Issue #4 --- Controller/Login/Index.php | 14 -------------- Model/Login.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index 2e7a462cc60a6..027d558105279 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -26,20 +26,6 @@ public function execute() } try { - $session = $this->_objectManager - ->create('\Magento\Customer\Model\Session'); - if ($session->getId()) { - /* Logout if logged in */ - $session->logout(); - } else { - /* Remove items from cart */ - $cart = $this->_objectManager - ->create('\Magento\Checkout\Model\Cart'); - foreach ($cart->getQuote()->getAllVisibleItems() as $item) { - $cart->removeItem($item->getId()); - } - $cart->save(); - } /* Log in */ $login->authenticateCustomer(); } catch (\Exception $e) { diff --git a/Model/Login.php b/Model/Login.php index e55f6a393c736..6ec2cb8dcf3d8 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -60,6 +60,11 @@ class Login extends \Magento\Framework\Model\AbstractModel */ protected $_random; + /** + * @var \Magento\Checkout\Model\Cart + */ + protected $cart; + /** * Initialize dependencies. * @@ -69,6 +74,7 @@ class Login extends \Magento\Framework\Model\AbstractModel * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime * @param \Magento\Framework\Math\Random $random + * @param \Magento\Checkout\Model\Cart $cart * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data @@ -80,6 +86,7 @@ public function __construct( \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Stdlib\DateTime\DateTime $dateTime, \Magento\Framework\Math\Random $random, + \Magento\Checkout\Model\Cart $cart, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] @@ -88,6 +95,7 @@ public function __construct( $this->_customerSession = $customerSession; $this->_dateTime = $dateTime; $this->_random = $random; + $this->cart = $cart; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -159,6 +167,17 @@ public function getCustomer() */ public function authenticateCustomer() { + if ($this->_customerSession->getId()) { + /* Logout if logged in */ + $this->_customerSession->logout(); + } else { + /* Remove items from guest cart */ + foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) { + $this->cart->removeItem($item->getId()); + } + $this->cart->save(); + } + $customer = $this->getCustomer(); if (!$customer->getId()) { @@ -172,6 +191,15 @@ public function authenticateCustomer() ); } + /* Save quote */ + $this->cart->getQuote()->getBillingAddress(); + $this->cart->getQuote()->getShippingAddress(); + $this->cart->getQuote()->setCustomer($this->_customerSession->getCustomerDataObject()) + ->setCustomerGroupId($customer->getGroupId()) + ->setTotalsCollectedFlag(false) + ->collectTotals(); + $this->cart->getQuote()->save(); + $this->setUsed(1)->save(); return $customer; From a815c0b3b6182f8f8bdbe4493981c4369ee81a09 Mon Sep 17 00:00:00 2001 From: Ihor Vansach <ihor@magefan.com> Date: Tue, 24 Oct 2017 10:33:59 +0300 Subject: [PATCH 147/455] Up version to 2.1.3 --- composer.json | 4 ++-- etc/module.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a4a43a41decd0..7abcae875e3ee 100755 --- a/composer.json +++ b/composer.json @@ -2,10 +2,10 @@ "name": "magefan/module-login-as-customer", "description": "N/A", "require": { - "php": "~5.6.5|7.0.2|7.0.4|~7.0.6|7.1.0|7.1.1|7.1.2|7.1.3|7.1.4|7.1.5|7.1.6|7.1.7|7.1.8|7.1.9" + "php": "~5.6.5 || >=7.0" }, "type": "magento2-module", - "version": "2.1.2", + "version": "2.1.3", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index 1143d72738835..bc5e13e24835b 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magefan_LoginAsCustomer" setup_version="2.1.2"> + <module name="Magefan_LoginAsCustomer" setup_version="2.1.3"> <sequence> <module name="Magento_Customer"/> </sequence> From fa0142a9040a0e9e991f992a79bfc02c23d72e88 Mon Sep 17 00:00:00 2001 From: Ihor Vansach <ihor@magefan.com> Date: Tue, 21 Nov 2017 10:17:13 +0200 Subject: [PATCH 148/455] Up version to 2.1.4 --- composer.json | 2 +- etc/module.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 7abcae875e3ee..e987f08e9f214 100755 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "php": "~5.6.5 || >=7.0" }, "type": "magento2-module", - "version": "2.1.3", + "version": "2.1.4", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index bc5e13e24835b..5137e71b65983 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magefan_LoginAsCustomer" setup_version="2.1.3"> + <module name="Magefan_LoginAsCustomer" setup_version="2.1.4"> <sequence> <module name="Magento_Customer"/> </sequence> From 22f53490b8a4602feb69b2e83e78387102dd6703 Mon Sep 17 00:00:00 2001 From: Toan Nguyen <nntoan@users.noreply.github.com> Date: Sat, 4 Apr 2020 11:00:32 +0700 Subject: [PATCH 149/455] login-as-customer/issues/59: Customer data not invalidated private content after logged in --- etc/frontend/sections.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/etc/frontend/sections.xml b/etc/frontend/sections.xml index e3569fb0a914e..e94b42ea04d5f 100644 --- a/etc/frontend/sections.xml +++ b/etc/frontend/sections.xml @@ -9,5 +9,11 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd"> - <action name="loginascustomer/login/post"/> + <action name="loginascustomer/login/post"> + <section name="checkout-data"/> + <section name="wishlist"/> + <section name="multiplewishlist"/> + <section name="customer"/> + <section name="cart"/> + </action> </config> From 8d9746aa8f5ad9aef43e773331b6d669436e3c89 Mon Sep 17 00:00:00 2001 From: Andriy Martynovskyj <andriy.martynovskyj@magefan.com> Date: Fri, 23 Feb 2018 12:46:15 +0200 Subject: [PATCH 150/455] add button in order, ship, credit memo, invoice page --- Block/Adminhtml/Convert.php | 16 ++++ Block/Adminhtml/Customer/Edit/Login.php | 3 +- Block/Adminhtml/Login.php | 2 +- Controller/Adminhtml/Guest/Convert.php | 39 ++++++++ Controller/Adminhtml/Login/Grid.php | 2 +- Controller/Adminhtml/Login/Index.php | 2 +- Controller/Adminhtml/Login/Login.php | 2 +- Controller/Login/Index.php | 2 +- Controller/Login/Post.php | 2 +- Controller/Login/Proceed.php | 2 +- Model/AdminNotificationFeed.php | 2 +- Model/Login.php | 2 +- Model/PageCache/ConfigPlugin.php | 2 +- Model/ResourceModel/Login.php | 2 +- Model/ResourceModel/Login/Collection.php | 2 +- Model/ResourceModel/Login/Grid/Collection.php | 2 +- ...redispathAdminActionControllerObserver.php | 2 +- .../WbsiterestrictionFrontendObserver.php | 2 +- Plugin/Button/ToolbarPlugin.php | 89 +++++++++++++++++++ .../{Actions.php => AbstractColumn.php} | 49 ++++++---- .../Listing/Column/CustomerActions.php | 17 ++++ Ui/Component/Listing/Column/OrderActions.php | 15 ++++ composer.json | 2 +- etc/acl.xml | 4 +- etc/adminhtml/di.xml | 12 +++ etc/adminhtml/events.xml | 4 +- etc/adminhtml/menu.xml | 4 +- etc/adminhtml/routes.xml | 4 +- etc/adminhtml/system.xml | 4 +- etc/frontend/di.xml | 4 +- etc/frontend/events.xml | 4 +- etc/frontend/routes.xml | 4 +- etc/frontend/sections.xml | 4 +- etc/module.xml | 5 +- etc/webrestrictions.xml | 4 +- registration.php | 2 +- .../layout/loginascustomer_guest_convert.xml | 21 +++++ .../layout/loginascustomer_login_grid.xml | 2 +- .../loginascustomer_login_grid_block.xml | 2 +- .../layout/loginascustomer_login_index.xml | 2 +- view/adminhtml/templates/convert.phtml | 14 +++ view/adminhtml/ui_component/customer_form.xml | 2 +- .../ui_component/customer_listing.xml | 4 +- .../ui_component/sales_order_grid.xml | 21 +++++ view/frontend/templates/login.phtml | 2 +- 45 files changed, 314 insertions(+), 75 deletions(-) create mode 100644 Block/Adminhtml/Convert.php create mode 100644 Controller/Adminhtml/Guest/Convert.php create mode 100644 Plugin/Button/ToolbarPlugin.php rename Ui/Component/Listing/Column/{Actions.php => AbstractColumn.php} (57%) create mode 100644 Ui/Component/Listing/Column/CustomerActions.php create mode 100644 Ui/Component/Listing/Column/OrderActions.php create mode 100644 etc/adminhtml/di.xml create mode 100755 view/adminhtml/layout/loginascustomer_guest_convert.xml create mode 100644 view/adminhtml/templates/convert.phtml create mode 100644 view/adminhtml/ui_component/sales_order_grid.xml diff --git a/Block/Adminhtml/Convert.php b/Block/Adminhtml/Convert.php new file mode 100644 index 0000000000000..e932ebe571ea8 --- /dev/null +++ b/Block/Adminhtml/Convert.php @@ -0,0 +1,16 @@ +<?php + +/** + * Copyright © Magefan (support@magefan.com). All rights reserved. + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! + */ + +namespace Magefan\LoginAsCustomer\Block\Adminhtml; + + +class Convert extends \Magento\Framework\View\Element\Template +{ + +} \ No newline at end of file diff --git a/Block/Adminhtml/Customer/Edit/Login.php b/Block/Adminhtml/Customer/Edit/Login.php index 429dad71eec8c..f8d23a959db1a 100755 --- a/Block/Adminhtml/Customer/Edit/Login.php +++ b/Block/Adminhtml/Customer/Edit/Login.php @@ -1,11 +1,10 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! */ - namespace Magefan\LoginAsCustomer\Block\Adminhtml\Customer\Edit; use Magento\Customer\Block\Adminhtml\Edit\GenericButton; diff --git a/Block/Adminhtml/Login.php b/Block/Adminhtml/Login.php index 50216154da702..16b631a1dffb8 100755 --- a/Block/Adminhtml/Login.php +++ b/Block/Adminhtml/Login.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Controller/Adminhtml/Guest/Convert.php b/Controller/Adminhtml/Guest/Convert.php new file mode 100644 index 0000000000000..82828358afbb5 --- /dev/null +++ b/Controller/Adminhtml/Guest/Convert.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright © Magefan (support@magefan.com). All rights reserved. + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! + */ + +namespace Magefan\LoginAsCustomer\Controller\Adminhtml\Guest; + +class Convert extends \Magento\Backend\App\Action +{ + /** + * @var \Magento\Framework\View\Result\PageFactory + */ + protected $resultPageFactory; + + /** + * Constructor + * + * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magento\Framework\View\Result\PageFactory $resultPageFactory + ) { + parent::__construct($context); + $this->resultPageFactory = $resultPageFactory; + } + + /** + * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page + */ + public function execute() + { + return $resultPage = $this->resultPageFactory->create(); + } +} \ No newline at end of file diff --git a/Controller/Adminhtml/Login/Grid.php b/Controller/Adminhtml/Login/Grid.php index d8182e2536a67..08c84c13cfb59 100755 --- a/Controller/Adminhtml/Login/Grid.php +++ b/Controller/Adminhtml/Login/Grid.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Controller/Adminhtml/Login/Index.php b/Controller/Adminhtml/Login/Index.php index 515fdcbbd4517..cadb071b1a3ab 100755 --- a/Controller/Adminhtml/Login/Index.php +++ b/Controller/Adminhtml/Login/Index.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php index 74f78b4ec805d..2b82df1d9b315 100755 --- a/Controller/Adminhtml/Login/Login.php +++ b/Controller/Adminhtml/Login/Login.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index 027d558105279..0ee2e61a92585 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Controller/Login/Post.php b/Controller/Login/Post.php index d6b144eacd301..6cac6709ca742 100755 --- a/Controller/Login/Post.php +++ b/Controller/Login/Post.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Controller/Login/Proceed.php b/Controller/Login/Proceed.php index a78108c163113..c3f0925982b50 100755 --- a/Controller/Login/Proceed.php +++ b/Controller/Login/Proceed.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index 9e2125551ae71..96962b9aca915 100755 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Model/Login.php b/Model/Login.php index 6ec2cb8dcf3d8..3ebd3895899da 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Model/PageCache/ConfigPlugin.php b/Model/PageCache/ConfigPlugin.php index 6eee755813262..fb28ffc11905d 100644 --- a/Model/PageCache/ConfigPlugin.php +++ b/Model/PageCache/ConfigPlugin.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Model/ResourceModel/Login.php b/Model/ResourceModel/Login.php index 0902b2b6c8ace..e629d2903b6e8 100755 --- a/Model/ResourceModel/Login.php +++ b/Model/ResourceModel/Login.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Model/ResourceModel/Login/Collection.php b/Model/ResourceModel/Login/Collection.php index 25f6d5da09445..a9bfc13e2c218 100755 --- a/Model/ResourceModel/Login/Collection.php +++ b/Model/ResourceModel/Login/Collection.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Model/ResourceModel/Login/Grid/Collection.php b/Model/ResourceModel/Login/Grid/Collection.php index 79b5f4b7b0567..ec29c6fbcb016 100755 --- a/Model/ResourceModel/Login/Grid/Collection.php +++ b/Model/ResourceModel/Login/Grid/Collection.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Observer/PredispathAdminActionControllerObserver.php b/Observer/PredispathAdminActionControllerObserver.php index d89dd247d60c1..d6b1b850a7ca2 100755 --- a/Observer/PredispathAdminActionControllerObserver.php +++ b/Observer/PredispathAdminActionControllerObserver.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Observer/WbsiterestrictionFrontendObserver.php b/Observer/WbsiterestrictionFrontendObserver.php index b9bea20b71002..12b15d299598d 100644 --- a/Observer/WbsiterestrictionFrontendObserver.php +++ b/Observer/WbsiterestrictionFrontendObserver.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/Plugin/Button/ToolbarPlugin.php b/Plugin/Button/ToolbarPlugin.php new file mode 100644 index 0000000000000..8eeb8bfdad009 --- /dev/null +++ b/Plugin/Button/ToolbarPlugin.php @@ -0,0 +1,89 @@ +<?php +/** + * Copyright © Magefan (support@magefan.com). All rights reserved. + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! + */ + +namespace Magefan\LoginAsCustomer\Plugin\Button; + +use \Magefan\LoginAsCustomerAdvanced\Controller\Adminhtml\Order\Login as LoginController; +use \Magento\Backend\Block\Widget\Button\Toolbar\Interceptor; +use \Magento\Framework\View\Element\AbstractBlock; +use \Magento\Backend\Block\Widget\Button\ButtonList; + +/** + * Class ToolbarPlugin + * @package Magefan\LoginAsCustomerAdvanced\Plugin\Button + */ +class ToolbarPlugin +{ + /** + * @var \Magento\Framework\AuthorizationInterface + */ + protected $authorization; + + /** + * ToolbarPlugin constructor. + * @param \Magento\Framework\AuthorizationInterface $authorization + */ + public function __construct( + \Magento\Framework\AuthorizationInterface $authorization + ) { + $this->authorization = $authorization; + } + + /** + * @param \Magento\Backend\Block\Widget\Button\Toolbar\Interceptor $subject + * @param \Magento\Framework\View\Element\AbstractBlock $context + * @param \Magento\Backend\Block\Widget\Button\ButtonList $buttonList + */ + public function beforePushButtons( + Interceptor $subject, + AbstractBlock $context, + ButtonList $buttonList + ) { + $order = false; + if ('sales_order_edit' == $context->getNameInLayout()) { + $order = $context->getOrder(); + } elseif ('sales_invoice_view' == $context->getNameInLayout()) { + $order = $context->getInvoice()->getOrder(); + } elseif ('sales_shipment_view' == $context->getNameInLayout()) { + $order = $context->getShipment()->getOrder(); + } elseif ('sales_creditmemo_view' == $context->getNameInLayout()) { + $order = $context->getCreditmemo()->getOrder(); + } + if ($order) { + if ($this->isAllowed()) { + if (!empty($order['customer_id'])) { + $buttonUrl = $context->getUrl('loginascustomer/login/login', [ + 'customer_id' => $order['customer_id'] + ]); + $buttonList->add( + 'guest_to_customer', + ['label' => __('Login As Customer'), 'onclick' => 'window.open(\'' . $buttonUrl . '\')', 'class' => 'reset'], + -1 + ); + } else { + $buttonUrl = $context->getUrl('loginascustomer/guest/convert'); + $buttonList->add( + 'guest_to_customer', + ['label' => __('Convert Guest to Customer'), 'onclick' => 'window.location=\'' . $buttonUrl . '\'', 'class' => 'reset'], + -1 + ); + } + } + } + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function isAllowed() + { + return $this->authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + } +} diff --git a/Ui/Component/Listing/Column/Actions.php b/Ui/Component/Listing/Column/AbstractColumn.php similarity index 57% rename from Ui/Component/Listing/Column/Actions.php rename to Ui/Component/Listing/Column/AbstractColumn.php index b1691b98f1997..0cc226057d45b 100644 --- a/Ui/Component/Listing/Column/Actions.php +++ b/Ui/Component/Listing/Column/AbstractColumn.php @@ -1,10 +1,11 @@ <?php /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! */ + namespace Magefan\LoginAsCustomer\Ui\Component\Listing\Column; use Magento\Framework\View\Element\UiComponent\ContextInterface; @@ -13,11 +14,10 @@ use Magento\Framework\UrlInterface; use Magento\Framework\AuthorizationInterface; -/** - * Class CustomerActions - */ -class Actions extends Column + +abstract class AbstractColumn extends \Magento\Ui\Component\Listing\Columns\Column { + /** * @var UrlInterface */ @@ -28,6 +28,8 @@ class Actions extends Column */ protected $_authorization; + protected $sourceColumnName; + /** * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory @@ -55,24 +57,37 @@ public function __construct( * @param array $dataSource * @return array */ - public function prepareDataSource(array $dataSource) - { + public function prepareDataSource(array $dataSource){ + if (isset($dataSource['data']['items'])) { $hidden = !$this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); foreach ($dataSource['data']['items'] as &$item) { - $item[$this->getData('name')]['edit'] = [ - 'href' => $this->urlBuilder->getUrl( - 'loginascustomer/login/login', - ['customer_id' => $item['entity_id']] - ), - 'label' => __('Login As Customer'), - 'hidden' => $hidden, - 'target' => '_blank', - ]; + if(!empty($item[$this->sourceColumnName])) { + $item[$this->getData('name')]['edit'] = [ + 'href' => $this->urlBuilder->getUrl( + 'loginascustomer/login/login', + ['customer_id' => $item[$this->sourceColumnName]] + ), + 'label' => __('Login As Customer'), + 'hidden' => $hidden, + 'target' => '_blank', + ]; + } else { + $item[$this->getData('name')]['edit'] = [ + 'href' => $this->urlBuilder->getUrl( + 'loginascustomer/guest/convert', + ['customer_id' => $item[$this->sourceColumnName]] + ), + 'label' => __('Convert Guest to Customer'), + 'hidden' => $hidden, + 'target' => '_blank', + ]; + } + } } return $dataSource; } -} +} \ No newline at end of file diff --git a/Ui/Component/Listing/Column/CustomerActions.php b/Ui/Component/Listing/Column/CustomerActions.php new file mode 100644 index 0000000000000..cd924a6fbe732 --- /dev/null +++ b/Ui/Component/Listing/Column/CustomerActions.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © Magefan (support@magefan.com). All rights reserved. + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! + */ +namespace Magefan\LoginAsCustomer\Ui\Component\Listing\Column; + +/** + * Class CustomerActions + */ +class CustomerActions extends AbstractColumn +{ + + protected $sourceColumnName = 'entity_id'; +} diff --git a/Ui/Component/Listing/Column/OrderActions.php b/Ui/Component/Listing/Column/OrderActions.php new file mode 100644 index 0000000000000..2287186383ff1 --- /dev/null +++ b/Ui/Component/Listing/Column/OrderActions.php @@ -0,0 +1,15 @@ +<?php +/** + * Copyright © Magefan (support@magefan.com). All rights reserved. + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! + */ +namespace Magefan\LoginAsCustomer\Ui\Component\Listing\Column; + +class OrderActions extends AbstractColumn +{ + + protected $sourceColumnName = 'customer_id'; + +} diff --git a/composer.json b/composer.json index e987f08e9f214..fad82612307e9 100755 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "php": "~5.6.5 || >=7.0" }, "type": "magento2-module", - "version": "2.1.4", + "version": "2.1.5", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/acl.xml b/etc/acl.xml index 948f8f61ca801..5211a0f3c9c0c 100755 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd"> diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml new file mode 100644 index 0000000000000..cfecb87ba930d --- /dev/null +++ b/etc/adminhtml/di.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © Magefan (support@magefan.com). All rights reserved. + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <type name="Magento\Backend\Block\Widget\Button\Toolbar"> + <plugin name="Magefan_LoginAsCustomer::toolbar_button" type="Magefan\LoginAsCustomer\Plugin\Button\ToolbarPlugin" /> + </type> +</config> diff --git a/etc/adminhtml/events.xml b/etc/adminhtml/events.xml index ecbc7cf570d4c..5df1ee44f45bd 100755 --- a/etc/adminhtml/events.xml +++ b/etc/adminhtml/events.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml index 5a4b630dc5844..903f9daa9b4c2 100755 --- a/etc/adminhtml/menu.xml +++ b/etc/adminhtml/menu.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd"> diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml index 75d00df9b72a5..3e4b8c7f93c58 100755 --- a/etc/adminhtml/routes.xml +++ b/etc/adminhtml/routes.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index aba04b3282c76..1fd36ef6eef49 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index a05b1f2662593..f2bf3cee01665 100755 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index 68d8edf3b73cf..ce39528d3479a 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index 00b11bb15f560..69fe2b3533006 100755 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> diff --git a/etc/frontend/sections.xml b/etc/frontend/sections.xml index e94b42ea04d5f..9191a043a4889 100644 --- a/etc/frontend/sections.xml +++ b/etc/frontend/sections.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" diff --git a/etc/module.xml b/etc/module.xml index 5137e71b65983..aa98cc2b59171 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,16 +1,17 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magefan_LoginAsCustomer" setup_version="2.1.4"> + <module name="Magefan_LoginAsCustomer" setup_version="2.1.5"> <sequence> <module name="Magento_Customer"/> + <module name="Magento_Sales"/> </sequence> </module> </config> diff --git a/etc/webrestrictions.xml b/etc/webrestrictions.xml index 2356c211cad6f..707c6627499bb 100644 --- a/etc/webrestrictions.xml +++ b/etc/webrestrictions.xml @@ -1,10 +1,8 @@ <?xml version="1.0"?> <!-- /** - * Copyright © 2015-2017 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). - * - * Glory to Ukraine! Glory to the heroes! */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_WebsiteRestriction:etc/webrestrictions.xsd"> diff --git a/registration.php b/registration.php index f8fc94bd8b290..a2cca455c35fc 100755 --- a/registration.php +++ b/registration.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2015 Ihor Vansach (ihor@magefan.com). All rights reserved. + * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). * * Glory to Ukraine! Glory to the heroes! diff --git a/view/adminhtml/layout/loginascustomer_guest_convert.xml b/view/adminhtml/layout/loginascustomer_guest_convert.xml new file mode 100755 index 0000000000000..95e04baf66e2b --- /dev/null +++ b/view/adminhtml/layout/loginascustomer_guest_convert.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magefan (support@magefan.com). All rights reserved. + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> + <head> + <title> + Convert To Customer + + + + + + + + diff --git a/view/adminhtml/layout/loginascustomer_login_grid.xml b/view/adminhtml/layout/loginascustomer_login_grid.xml index c4294063bfd23..c2438f74b5321 100755 --- a/view/adminhtml/layout/loginascustomer_login_grid.xml +++ b/view/adminhtml/layout/loginascustomer_login_grid.xml @@ -1,7 +1,7 @@ +
+

Customer to Guest Magento Extension.'); ?>

+ +
\ No newline at end of file diff --git a/view/adminhtml/ui_component/customer_form.xml b/view/adminhtml/ui_component/customer_form.xml index a5975968b23bf..cca16e44b08a2 100755 --- a/view/adminhtml/ui_component/customer_form.xml +++ b/view/adminhtml/ui_component/customer_form.xml @@ -1,7 +1,7 @@ - + Login diff --git a/view/adminhtml/ui_component/sales_order_grid.xml b/view/adminhtml/ui_component/sales_order_grid.xml new file mode 100644 index 0000000000000..5925420d1804f --- /dev/null +++ b/view/adminhtml/ui_component/sales_order_grid.xml @@ -0,0 +1,21 @@ + + ++ + + + + Action II + entity_id + + + + + diff --git a/view/frontend/templates/login.phtml b/view/frontend/templates/login.phtml index 0ffc6c83dc7df..0de223d43e745 100644 --- a/view/frontend/templates/login.phtml +++ b/view/frontend/templates/login.phtml @@ -1,6 +1,6 @@ Date: Tue, 6 Mar 2018 16:47:06 +0200 Subject: [PATCH 151/455] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 8c9ee4ce47beb..7cb5ac1bf8833 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,11 @@ https://magefan.com/contact ## License The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php). + +## Other Magefan Extensions That Can Be Installed Via Composer + * [Magento 2 Auto Currency Switcher Extension](https://magefan.com/magento-2-currency-switcher-auto-currency-by-country) + * [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) + * [Magento 2 Conflict Detector Extension](https://magefan.com/magento2-conflict-detector) + * [Magento 2 Lazy Load Extension](https://github.com/magefan/module-lazyload) + * [Magento 2 Rocket JavaScript Extension](https://github.com/magefan/module-rocketjavascript) + * [Magento 2 CLI Extension](https://github.com/magefan/module-cli) From e547abbd2a7170452e01d55ed0aca1c592ab663b Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 1 Apr 2020 11:56:21 +0200 Subject: [PATCH 152/455] Update readme installation instructions --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7cb5ac1bf8833..eac8a1af32a9c 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,17 @@ Allows admin to login as a customer (enter to customer account). * Magento Community Edition 2.0.x-2.2.x or Magento Enterprise Edition 2.0.x-2.2.x ## Installation Method 1 - Installing via composer - * Open command line - * Using command "cd" navigate to your magento2 root directory - * Run command: composer require magefan/module-login-as-customer - - + * Run command: `composer require magefan/module-login-as-customer` ## Installation Method 2 - Installing using archive * Download [ZIP Archive](https://github.com/magefan/module-login-as-customer/archive/master.zip) * Extract files * In your Magento 2 root directory create folder app/code/Magefan/LoginAsCustomer * Copy files and folders from archive to that folder - * In command line, using "cd", navigate to your Magento 2 root directory - * Run commands: + +## Enable module: ``` +php bin/magento module:enable Magefan_LoginAsCustomer php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy From e572ab6cdd9de822d3e50937f1fe802ddd19c532 Mon Sep 17 00:00:00 2001 From: Erfan Date: Thu, 29 Mar 2018 18:56:16 +0800 Subject: [PATCH 153/455] Resolved login-as-customer/issues/60 * Fixed customer data sometimes not being cleared when logging in as customer * Removed unused files. * Whitespace cleanup. --- Block/Adminhtml/Customer/Edit/Login.php | 1 - Block/Adminhtml/System/Config/Form/Info.php | 1 - Controller/Login/Index.php | 1 - Controller/Login/Post.php | 25 ------------------- Controller/Login/Proceed.php | 1 - Model/AdminNotificationFeed.php | 1 - Model/Login.php | 1 - Model/ResourceModel/Login.php | 1 - Model/ResourceModel/Login/Collection.php | 1 - Model/ResourceModel/Login/Grid/Collection.php | 1 - .../Listing/Column/AbstractColumn.php | 3 +-- etc/adminhtml/routes.xml | 2 +- etc/frontend/events.xml | 2 +- etc/frontend/routes.xml | 2 +- etc/frontend/sections.xml | 17 ------------- etc/webrestrictions.xml | 1 - .../ui_component/customer_listing.xml | 2 +- .../layout/loginascustomer_login_proceed.xml | 2 +- view/frontend/templates/login.phtml | 23 ++++++++--------- view/frontend/web/js/login.js | 12 +++++++++ 20 files changed, 28 insertions(+), 72 deletions(-) delete mode 100755 Controller/Login/Post.php delete mode 100644 etc/frontend/sections.xml create mode 100644 view/frontend/web/js/login.js diff --git a/Block/Adminhtml/Customer/Edit/Login.php b/Block/Adminhtml/Customer/Edit/Login.php index f8d23a959db1a..7611ca89ba47e 100755 --- a/Block/Adminhtml/Customer/Edit/Login.php +++ b/Block/Adminhtml/Customer/Edit/Login.php @@ -62,5 +62,4 @@ public function getInvalidateTokenUrl() { return $this->getUrl('loginascustomer/login/login', ['customer_id' => $this->getCustomerId()]); } - } diff --git a/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php index ef7a8ed8cccf7..49d4963b01701 100755 --- a/Block/Adminhtml/System/Config/Form/Info.php +++ b/Block/Adminhtml/System/Config/Form/Info.php @@ -48,5 +48,4 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele return $html; } - } diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index 0ee2e61a92585..7b06ecdff7b0e 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -62,5 +62,4 @@ protected function _initLogin() return false; } } - } diff --git a/Controller/Login/Post.php b/Controller/Login/Post.php deleted file mode 100755 index 6cac6709ca742..0000000000000 --- a/Controller/Login/Post.php +++ /dev/null @@ -1,25 +0,0 @@ -_redirect('customer/account'); - } - -} diff --git a/Controller/Login/Proceed.php b/Controller/Login/Proceed.php index c3f0925982b50..3d920506b4c02 100755 --- a/Controller/Login/Proceed.php +++ b/Controller/Login/Proceed.php @@ -22,5 +22,4 @@ public function execute() $this->_view->loadLayout(); $this->_view->renderLayout(); } - } diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index 96962b9aca915..8b40b8b889adb 100755 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -166,5 +166,4 @@ public function setLastUpdate() $this->_cacheManager->save(time(), 'magefan_admin_notifications_lastcheck'); return $this; } - } diff --git a/Model/Login.php b/Model/Login.php index 3ebd3895899da..a4018d9dca8d4 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -220,5 +220,4 @@ public function generate($adminId) 'created_at' => $this->_dateTime->gmtTimestamp(), ])->save(); } - } diff --git a/Model/ResourceModel/Login.php b/Model/ResourceModel/Login.php index e629d2903b6e8..25b341c2bcdc2 100755 --- a/Model/ResourceModel/Login.php +++ b/Model/ResourceModel/Login.php @@ -23,5 +23,4 @@ protected function _construct() { $this->_init('magefan_login_as_customer', 'login_id'); } - } diff --git a/Model/ResourceModel/Login/Collection.php b/Model/ResourceModel/Login/Collection.php index a9bfc13e2c218..2eda70f2d1008 100755 --- a/Model/ResourceModel/Login/Collection.php +++ b/Model/ResourceModel/Login/Collection.php @@ -24,5 +24,4 @@ protected function _construct() parent::_construct(); $this->_init('Magefan\LoginAsCustomer\Model\Login', 'Magefan\LoginAsCustomer\Model\ResourceModel\Login'); } - } diff --git a/Model/ResourceModel/Login/Grid/Collection.php b/Model/ResourceModel/Login/Grid/Collection.php index ec29c6fbcb016..d4ae361b49178 100755 --- a/Model/ResourceModel/Login/Grid/Collection.php +++ b/Model/ResourceModel/Login/Grid/Collection.php @@ -45,5 +45,4 @@ protected function _initSelect() ); return $this; } - } diff --git a/Ui/Component/Listing/Column/AbstractColumn.php b/Ui/Component/Listing/Column/AbstractColumn.php index 0cc226057d45b..e1a1e5d5998fd 100644 --- a/Ui/Component/Listing/Column/AbstractColumn.php +++ b/Ui/Component/Listing/Column/AbstractColumn.php @@ -89,5 +89,4 @@ public function prepareDataSource(array $dataSource){ return $dataSource; } - -} \ No newline at end of file +} diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml index 3e4b8c7f93c58..368cbdeb1864f 100755 --- a/etc/adminhtml/routes.xml +++ b/etc/adminhtml/routes.xml @@ -11,4 +11,4 @@ - \ No newline at end of file + diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index ce39528d3479a..b58b068625cac 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index 69fe2b3533006..70cb7c262749f 100755 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -11,4 +11,4 @@ - \ No newline at end of file + diff --git a/etc/frontend/sections.xml b/etc/frontend/sections.xml deleted file mode 100644 index 9191a043a4889..0000000000000 --- a/etc/frontend/sections.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - -
-
-
-
-
- - diff --git a/etc/webrestrictions.xml b/etc/webrestrictions.xml index 707c6627499bb..7c72858d7fa9a 100644 --- a/etc/webrestrictions.xml +++ b/etc/webrestrictions.xml @@ -7,6 +7,5 @@ --> - diff --git a/view/adminhtml/ui_component/customer_listing.xml b/view/adminhtml/ui_component/customer_listing.xml index 1da62233f751f..6a5ab13b324e2 100644 --- a/view/adminhtml/ui_component/customer_listing.xml +++ b/view/adminhtml/ui_component/customer_listing.xml @@ -18,4 +18,4 @@ -
\ No newline at end of file + diff --git a/view/frontend/layout/loginascustomer_login_proceed.xml b/view/frontend/layout/loginascustomer_login_proceed.xml index 78da65f40ea6d..8ae0914216848 100644 --- a/view/frontend/layout/loginascustomer_login_proceed.xml +++ b/view/frontend/layout/loginascustomer_login_proceed.xml @@ -18,4 +18,4 @@ - \ No newline at end of file + diff --git a/view/frontend/templates/login.phtml b/view/frontend/templates/login.phtml index 0de223d43e745..1617b1284284f 100644 --- a/view/frontend/templates/login.phtml +++ b/view/frontend/templates/login.phtml @@ -5,18 +5,15 @@ * * Glory to Ukraine! Glory to the heroes! */ +/** @var \Magento\Framework\View\Element\Template $block */ ?> -

-
- -
- diff --git a/view/frontend/web/js/login.js b/view/frontend/web/js/login.js new file mode 100644 index 0000000000000..63108aae3d9d3 --- /dev/null +++ b/view/frontend/web/js/login.js @@ -0,0 +1,12 @@ +define([ + 'Magento_Customer/js/customer-data' +], function (customerData) { + + 'use strict'; + + return function (config) { + customerData.reload('customer').done(function () { + window.location.href = config.redirectUrl; + }); + }; +}); From 2019a2245af9813b66ff0ab18815d021dc9143e1 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Tue, 3 Apr 2018 23:03:29 +0300 Subject: [PATCH 154/455] Removed unused files + added copyrights --- view/frontend/web/js/login.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/view/frontend/web/js/login.js b/view/frontend/web/js/login.js index 63108aae3d9d3..262ca92fdd38c 100644 --- a/view/frontend/web/js/login.js +++ b/view/frontend/web/js/login.js @@ -1,3 +1,8 @@ +/** + * Copyright © Magefan (support@magefan.com). All rights reserved. + * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + */ + define([ 'Magento_Customer/js/customer-data' ], function (customerData) { From 70348fdd63ab87e0e70f5dade739e7fb14f4d9b6 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Tue, 3 Apr 2018 23:29:25 +0300 Subject: [PATCH 155/455] Coding styles improvements + label changes --- Block/Adminhtml/Convert.php | 3 +-- Controller/Adminhtml/Guest/Convert.php | 2 +- Controller/Adminhtml/Login/Grid.php | 4 ++-- Controller/Adminhtml/Login/Index.php | 4 ++-- Model/AdminNotificationFeed.php | 10 +++++----- Model/Login.php | 3 ++- Model/ResourceModel/Login/Grid/Collection.php | 8 ++++---- Plugin/Button/ToolbarPlugin.php | 12 +++++++----- Ui/Component/Listing/Column/AbstractColumn.php | 9 ++++----- Ui/Component/Listing/Column/OrderActions.php | 1 - composer.json | 5 +++-- etc/module.xml | 3 ++- .../layout/loginascustomer_guest_convert.xml | 2 +- view/adminhtml/templates/convert.phtml | 4 ++-- 14 files changed, 36 insertions(+), 34 deletions(-) diff --git a/Block/Adminhtml/Convert.php b/Block/Adminhtml/Convert.php index e932ebe571ea8..eac7eee995977 100644 --- a/Block/Adminhtml/Convert.php +++ b/Block/Adminhtml/Convert.php @@ -9,8 +9,7 @@ namespace Magefan\LoginAsCustomer\Block\Adminhtml; - class Convert extends \Magento\Framework\View\Element\Template { -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Guest/Convert.php b/Controller/Adminhtml/Guest/Convert.php index 82828358afbb5..b5f94f81c2077 100644 --- a/Controller/Adminhtml/Guest/Convert.php +++ b/Controller/Adminhtml/Guest/Convert.php @@ -36,4 +36,4 @@ public function execute() { return $resultPage = $this->resultPageFactory->create(); } -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Login/Grid.php b/Controller/Adminhtml/Login/Grid.php index 08c84c13cfb59..c13c1399c193f 100755 --- a/Controller/Adminhtml/Login/Grid.php +++ b/Controller/Adminhtml/Login/Grid.php @@ -13,14 +13,14 @@ */ class Grid extends \Magento\Backend\App\Action { - /** + /** * Login as customer log grid * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { - $this->_view->loadLayout(false); + $this->_view->loadLayout(false); $this->_view->renderLayout(); } diff --git a/Controller/Adminhtml/Login/Index.php b/Controller/Adminhtml/Login/Index.php index cadb071b1a3ab..cccd4ec1dc979 100755 --- a/Controller/Adminhtml/Login/Index.php +++ b/Controller/Adminhtml/Login/Index.php @@ -13,14 +13,14 @@ */ class Index extends \Magento\Backend\App\Action { - /** + /** * Login as customer log * * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { - if ($this->getRequest()->getParam('ajax')) { + if ($this->getRequest()->getParam('ajax')) { $this->_forward('grid'); return; } diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index 8b40b8b889adb..1363250aef7be 100755 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -86,8 +86,8 @@ public function getFeedUrl() $url = $this->_feedUrl . 'domain/' . urlencode($domain); - $modulesParams = array(); - foreach($this->getMagefanModules() as $key => $module) { + $modulesParams = []; + foreach ($this->getMagefanModules() as $key => $module) { $key = str_replace('Magefan_', '', $key); $modulesParams[] = $key . ',' . $module['setup_version']; } @@ -106,9 +106,9 @@ public function getFeedUrl() */ protected function getMagefanModules() { - $modules = array(); - foreach($this->_moduleList->getAll() as $moduleName => $module) { - if ( strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName) ) { + $modules = []; + foreach ($this->_moduleList->getAll() as $moduleName => $module) { + if (strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName)) { $modules[$moduleName] = $module; } } diff --git a/Model/Login.php b/Model/Login.php index a4018d9dca8d4..449ac973c8b59 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -132,7 +132,8 @@ public function deleteNotUsed() { $resource = $this->getResource(); $resource->getConnection()->delete( - $resource->getTable('magefan_login_as_customer'), [ + $resource->getTable('magefan_login_as_customer'), + [ 'created_at < ?' => $this->getDateTimePoint(), 'used = ?' => 0, ] diff --git a/Model/ResourceModel/Login/Grid/Collection.php b/Model/ResourceModel/Login/Grid/Collection.php index d4ae361b49178..4be42b1717c97 100755 --- a/Model/ResourceModel/Login/Grid/Collection.php +++ b/Model/ResourceModel/Login/Grid/Collection.php @@ -35,13 +35,13 @@ protected function _initSelect() parent::_initSelect(); $this->getSelect() ->joinLeft( - array('c' => $this->getTable('customer_entity')), + ['c' => $this->getTable('customer_entity')], 'c.entity_id = main_table.customer_id', - array('email') + ['email'] )->joinLeft( - array('a' => $this->getTable('admin_user')), + ['a' => $this->getTable('admin_user')], 'a.user_id = main_table.admin_id', - array('username') + ['username'] ); return $this; } diff --git a/Plugin/Button/ToolbarPlugin.php b/Plugin/Button/ToolbarPlugin.php index 8eeb8bfdad009..684d7d75a026d 100644 --- a/Plugin/Button/ToolbarPlugin.php +++ b/Plugin/Button/ToolbarPlugin.php @@ -45,13 +45,15 @@ public function beforePushButtons( ButtonList $buttonList ) { $order = false; - if ('sales_order_edit' == $context->getNameInLayout()) { + $nameInLayout = $context->getNameInLayout(); + + if ('sales_order_edit' == $nameInLayout) { $order = $context->getOrder(); - } elseif ('sales_invoice_view' == $context->getNameInLayout()) { + } elseif ('sales_invoice_view' == $nameInLayout) { $order = $context->getInvoice()->getOrder(); - } elseif ('sales_shipment_view' == $context->getNameInLayout()) { + } elseif ('sales_shipment_view' == $nameInLayout) { $order = $context->getShipment()->getOrder(); - } elseif ('sales_creditmemo_view' == $context->getNameInLayout()) { + } elseif ('sales_creditmemo_view' == $nameInLayout) { $order = $context->getCreditmemo()->getOrder(); } if ($order) { @@ -69,7 +71,7 @@ public function beforePushButtons( $buttonUrl = $context->getUrl('loginascustomer/guest/convert'); $buttonList->add( 'guest_to_customer', - ['label' => __('Convert Guest to Customer'), 'onclick' => 'window.location=\'' . $buttonUrl . '\'', 'class' => 'reset'], + ['label' => __('Convert Guest to Customer'), 'onclick' => 'window.open(\'' . $buttonUrl . '\')', 'class' => 'reset'], -1 ); } diff --git a/Ui/Component/Listing/Column/AbstractColumn.php b/Ui/Component/Listing/Column/AbstractColumn.php index e1a1e5d5998fd..f480a9d2a563e 100644 --- a/Ui/Component/Listing/Column/AbstractColumn.php +++ b/Ui/Component/Listing/Column/AbstractColumn.php @@ -14,8 +14,7 @@ use Magento\Framework\UrlInterface; use Magento\Framework\AuthorizationInterface; - -abstract class AbstractColumn extends \Magento\Ui\Component\Listing\Columns\Column +abstract class AbstractColumn extends \Magento\Ui\Component\Listing\Columns\Column { /** @@ -57,12 +56,13 @@ public function __construct( * @param array $dataSource * @return array */ - public function prepareDataSource(array $dataSource){ + public function prepareDataSource(array $dataSource) + { if (isset($dataSource['data']['items'])) { $hidden = !$this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); foreach ($dataSource['data']['items'] as &$item) { - if(!empty($item[$this->sourceColumnName])) { + if (!empty($item[$this->sourceColumnName])) { $item[$this->getData('name')]['edit'] = [ 'href' => $this->urlBuilder->getUrl( 'loginascustomer/login/login', @@ -83,7 +83,6 @@ public function prepareDataSource(array $dataSource){ 'target' => '_blank', ]; } - } } diff --git a/Ui/Component/Listing/Column/OrderActions.php b/Ui/Component/Listing/Column/OrderActions.php index 2287186383ff1..a504c06e990fe 100644 --- a/Ui/Component/Listing/Column/OrderActions.php +++ b/Ui/Component/Listing/Column/OrderActions.php @@ -11,5 +11,4 @@ class OrderActions extends AbstractColumn { protected $sourceColumnName = 'customer_id'; - } diff --git a/composer.json b/composer.json index fad82612307e9..c30256245530d 100755 --- a/composer.json +++ b/composer.json @@ -1,8 +1,9 @@ { "name": "magefan/module-login-as-customer", - "description": "N/A", + "description": "Allow for admin to enter a customer account", "require": { - "php": "~5.6.5 || >=7.0" + "php": "~5.6.5 || >=7.0", + "magefan/module-community" : ">=2.0.0" }, "type": "magento2-module", "version": "2.1.5", diff --git a/etc/module.xml b/etc/module.xml index aa98cc2b59171..8f7a6e1e5bc3f 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -11,7 +11,8 @@ - + +
diff --git a/view/adminhtml/layout/loginascustomer_guest_convert.xml b/view/adminhtml/layout/loginascustomer_guest_convert.xml index 95e04baf66e2b..b7842bebd9bde 100755 --- a/view/adminhtml/layout/loginascustomer_guest_convert.xml +++ b/view/adminhtml/layout/loginascustomer_guest_convert.xml @@ -10,7 +10,7 @@ - Convert To Customer + Convert Guest To Customer diff --git a/view/adminhtml/templates/convert.phtml b/view/adminhtml/templates/convert.phtml index fff728ac4e63d..0eac7eca6a6e7 100644 --- a/view/adminhtml/templates/convert.phtml +++ b/view/adminhtml/templates/convert.phtml @@ -7,8 +7,8 @@ */ -->
-

Customer to Guest Magento Extension.'); ?>

-
\ No newline at end of file From 2ea2e816d81621e3de9567765e8d3f513021a8ef Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Wed, 4 Apr 2018 00:18:01 +0300 Subject: [PATCH 156/455] Code style changes --- Block/Adminhtml/Convert.php | 15 --------------- Block/Adminhtml/Customer/Edit/Login.php | 1 + Ui/Component/Listing/Column/CustomerActions.php | 1 + Ui/Component/Listing/Column/OrderActions.php | 1 + etc/acl.xml | 2 ++ etc/adminhtml/di.xml | 2 ++ etc/adminhtml/events.xml | 2 ++ etc/adminhtml/menu.xml | 2 ++ etc/adminhtml/routes.xml | 2 ++ etc/adminhtml/system.xml | 2 ++ etc/frontend/di.xml | 2 ++ etc/frontend/events.xml | 2 ++ etc/frontend/routes.xml | 2 ++ etc/webrestrictions.xml | 2 ++ view/adminhtml/templates/convert.phtml | 4 ++-- 15 files changed, 25 insertions(+), 17 deletions(-) delete mode 100644 Block/Adminhtml/Convert.php diff --git a/Block/Adminhtml/Convert.php b/Block/Adminhtml/Convert.php deleted file mode 100644 index eac7eee995977..0000000000000 --- a/Block/Adminhtml/Convert.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/etc/adminhtml/di.xml b/etc/adminhtml/di.xml index cfecb87ba930d..fd4c2becb12df 100644 --- a/etc/adminhtml/di.xml +++ b/etc/adminhtml/di.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/adminhtml/events.xml b/etc/adminhtml/events.xml index 5df1ee44f45bd..452053af145bc 100755 --- a/etc/adminhtml/events.xml +++ b/etc/adminhtml/events.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml index 903f9daa9b4c2..55f93688be3a8 100755 --- a/etc/adminhtml/menu.xml +++ b/etc/adminhtml/menu.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/adminhtml/routes.xml b/etc/adminhtml/routes.xml index 368cbdeb1864f..d3a6062f95c79 100755 --- a/etc/adminhtml/routes.xml +++ b/etc/adminhtml/routes.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 1fd36ef6eef49..5f90f6013308d 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml index f2bf3cee01665..cb8ed13025bbf 100755 --- a/etc/frontend/di.xml +++ b/etc/frontend/di.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml index b58b068625cac..ae3b7593a2468 100644 --- a/etc/frontend/events.xml +++ b/etc/frontend/events.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index 70cb7c262749f..19e9771355683 100755 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/etc/webrestrictions.xml b/etc/webrestrictions.xml index 7c72858d7fa9a..04232a4d36195 100644 --- a/etc/webrestrictions.xml +++ b/etc/webrestrictions.xml @@ -3,6 +3,8 @@ /** * Copyright © Magefan (support@magefan.com). All rights reserved. * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). + * + * Glory to Ukraine! Glory to the heroes! */ --> diff --git a/view/adminhtml/templates/convert.phtml b/view/adminhtml/templates/convert.phtml index 0eac7eca6a6e7..9fea6c1f2fb59 100644 --- a/view/adminhtml/templates/convert.phtml +++ b/view/adminhtml/templates/convert.phtml @@ -1,11 +1,11 @@ - +*/ ?>

Customer to Guest Magento 2 Extension.'); ?>

-
\ No newline at end of file + From bd86c13eb1158fe2fb0f85d4f4c9210209f4e742 Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 22 May 2018 10:15:17 +0300 Subject: [PATCH 165/455] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9f9270997d78f..d9b4a06f3b7dd 100755 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "magefan/module-community" : ">=2.0.0" }, "type": "magento2-module", - "version": "2.1.6", + "version": "2.1.7", "license": [ "OSL-3.0", "AFL-3.0" From 7bff406dbfcb69d8bffbedf5a835c92c4ad1344a Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 22 May 2018 10:15:37 +0300 Subject: [PATCH 166/455] Update module.xml --- etc/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/module.xml b/etc/module.xml index 08865d9610034..5ace1ff94a21d 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 0da07b604c8dfe9818a7a71582fd5eb50ebb0e3c Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 28 May 2018 18:38:38 +0300 Subject: [PATCH 167/455] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 51ce4aa2f3266..78f0af9352017 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy ``` +## Changelog: +https://magefan.com/login-as-customer-magento-2-extension ## Support If you have any issues, please [contact us](mailto:support@magefan.com) From bb1ba7ee8f1d7eee3de61be2b61e7ec32d3af104 Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 28 May 2018 18:39:15 +0300 Subject: [PATCH 168/455] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 78f0af9352017..f67e8859c7ee5 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy ``` -## Changelog: +## Changelog https://magefan.com/login-as-customer-magento-2-extension ## Support From 4ae2a696566ca9e081092de208f4c104cfee9a8e Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 3 Jul 2018 10:37:28 +0300 Subject: [PATCH 169/455] Update Index.php --- Controller/Login/Index.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index 43d51f3c6aea8..4f8472ac94852 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -28,14 +28,13 @@ public function execute() try { /* Log in */ $login->authenticateCustomer(); + $this->messageManager->addSuccess( + __('You are logged in as customer: %1', $login->getCustomer()->getName()) + ); } catch (\Exception $e) { $this->messageManager->addError($e->getMessage()); } - $this->messageManager->addSuccess( - __('You are logged in as customer: %1', $login->getCustomer()->getName()) - ); - $this->_redirect('*/*/proceed'); } From cb773cb8cdc517f6f5912f2af40a48f786b08416 Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 3 Jul 2018 10:39:02 +0300 Subject: [PATCH 170/455] Update Login.php --- Model/Login.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Model/Login.php b/Model/Login.php index e8c6a5176818c..c7d9921a793e6 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -200,6 +200,8 @@ public function authenticateCustomer() $this->_customerSession->setLoggedAsCustomerAdmindId( $this->getAdminId() ); + } else { + throw new \Exception(__("Cannot login customer."), 1); } /* Load Customer Quote */ From e586fe5128dce9e3067f465b71edf61d727912bc Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 1 Sep 2018 16:10:19 +0300 Subject: [PATCH 171/455] Added option to keep guest items in shopping cart --- Model/Login.php | 35 +++++++++++++++++++++++++++++------ etc/adminhtml/system.xml | 6 ++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Model/Login.php b/Model/Login.php index c7d9921a793e6..fde95412e158c 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -18,6 +18,8 @@ class Login extends \Magento\Framework\Model\AbstractModel */ const TIME_FRAME = 60; + const XML_PATH_KEEP_GUEST_CART = 'mfloginascustomer/general/keep_guest_cart'; + /** * Prefix of model events names * @@ -69,6 +71,11 @@ class Login extends \Magento\Framework\Model\AbstractModel */ protected $cart; + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + protected $scopeConfig; + /** * Initialize dependencies. * @@ -83,6 +90,7 @@ class Login extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data * @param null|\Magento\Checkout\Model\Session $checkoutSession + * @param null|\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig */ public function __construct( \Magento\Framework\Model\Context $context, @@ -95,7 +103,8 @@ public function __construct( \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [], - $checkoutSession = null + $checkoutSession = null, + $scopeConfig = null ) { $this->_customerFactory = $customerFactory; $this->_customerSession = $customerSession; @@ -103,9 +112,15 @@ public function __construct( $this->_dateTime = $dateTime; $this->_random = $random; $this->cart = $cart; - $this->_checkoutSession = $checkoutSession ?: \Magento\Framework\App\ObjectManager::getInstance()->get( + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $this->_checkoutSession = $checkoutSession ?: $objectManager->get( \Magento\Checkout\Model\Session::class ); + $this->scopeConfig = $scopeConfig ?: $objectManager->get( + \Magento\Framework\App\Config\ScopeConfigInterface::class + ); + parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -182,11 +197,19 @@ public function authenticateCustomer() /* Logout if logged in */ $this->_customerSession->logout(); } else { - /* Remove items from guest cart */ - foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) { - $this->cart->removeItem($item->getId()); + + $keepItems = $this->scopeConfig->getValue( + self::XML_PATH_KEEP_GUEST_CART, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + + if (!$keepItems) { + /* Remove items from guest cart */ + foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) { + $this->cart->removeItem($item->getId()); + } + $this->cart->save(); } - $this->cart->save(); } $customer = $this->getCustomer(); diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 5f90f6013308d..a859ec5e6a593 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -25,6 +25,12 @@ Magento\Config\Model\Config\Source\Yesno + + + + + Magento\Config\Model\Config\Source\Yesno + From d790314d1ede3cc16ce25a7b948abf20c7b9791c Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 1 Sep 2018 16:11:20 +0300 Subject: [PATCH 172/455] Up version to 2.1.8 --- composer.json | 5 ++--- etc/module.xml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index d9b4a06f3b7dd..b59efeaf886e6 100755 --- a/composer.json +++ b/composer.json @@ -2,11 +2,10 @@ "name": "magefan/module-login-as-customer", "description": "Allow for admin to enter a customer account", "require": { - "php": "~5.6.5 || >=7.0", - "magefan/module-community" : ">=2.0.0" + "magefan/module-community" : ">=2.0.1" }, "type": "magento2-module", - "version": "2.1.7", + "version": "2.1.8", "license": [ "OSL-3.0", "AFL-3.0" diff --git a/etc/module.xml b/etc/module.xml index 5ace1ff94a21d..4da0750d8b531 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 192c7cd653714313e193827a27482540ed7ccd0a Mon Sep 17 00:00:00 2001 From: Magefan Date: Sat, 2 Mar 2019 09:51:49 +0200 Subject: [PATCH 173/455] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f67e8859c7ee5..5e4ce6aba9cad 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Allows admin to login as a customer (enter to customer account). ## Requirements - * Magento Community Edition 2.0.x-2.2.x or Magento Enterprise Edition 2.0.x-2.2.x + * Magento Community Edition 2.0.x-2.3.x or Magento Enterprise Edition 2.0.x-2.3.x ## Installation Method 1 - Installing via composer * Run command: `composer require magefan/module-login-as-customer` From 407af7a96b09491f929c7c5fe64f267c8ded3dd2 Mon Sep 17 00:00:00 2001 From: dev4 Date: Mon, 22 Apr 2019 10:10:34 +0300 Subject: [PATCH 174/455] 2032-objectManager move classes to constructor [Implemented] # Conflicts: # Controller/Adminhtml/Login/Login.php --- Controller/Adminhtml/Login/Index.php | 22 +++++++++-- Controller/Adminhtml/Login/Login.php | 56 +++++++++++++++++++++------- Controller/Login/Index.php | 22 +++++++++-- 3 files changed, 81 insertions(+), 19 deletions(-) diff --git a/Controller/Adminhtml/Login/Index.php b/Controller/Adminhtml/Login/Index.php index 1b092de797b2f..e920e10200346 100755 --- a/Controller/Adminhtml/Login/Index.php +++ b/Controller/Adminhtml/Login/Index.php @@ -13,6 +13,24 @@ */ class Index extends \Magento\Backend\App\Action { + /** + * @var \Magefan\LoginAsCustomer\Model\Login + */ + protected $login = null; + + /** + * Index constructor. + * @param \Magento\Backend\App\Action\Context $context + * @param \Magefan\LoginAsCustomer\Model\Login|null $login + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magefan\LoginAsCustomer\Model\Login $login = null + ) { + parent::__construct($context); + $objectManager = $this->_objectManager; + $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + } /** * Login as customer log * @@ -25,9 +43,7 @@ public function execute() return; } - $this->_objectManager - ->create(\Magefan\LoginAsCustomer\Model\Login::class) - ->deleteNotUsed(); + $this->login->deleteNotUsed(); $this->_view->loadLayout(); $this->_setActiveMenu('Magefan_LoginAsCustomer::login_log'); diff --git a/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php index 50f5a6d576185..3f6d1a8a844d6 100755 --- a/Controller/Adminhtml/Login/Login.php +++ b/Controller/Adminhtml/Login/Login.php @@ -9,10 +9,46 @@ namespace Magefan\LoginAsCustomer\Controller\Adminhtml\Login; /** - * LoginAsCustomer login action + * Class Login + * @package Magefan\LoginAsCustomer\Controller\Adminhtml\Login */ class Login extends \Magento\Backend\App\Action { + /** + * @var \Magefan\LoginAsCustomer\Model\Login + */ + protected $login; + /** + * @var \Magento\Backend\Model\Auth\Session + */ + protected $session = null; + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager = null; + /** + * @var \Magento\Framework\Url + */ + protected $url = null; + /** + * Login constructor. + * @param \Magento\Backend\App\Action\Context $context + * @param \Magefan\LoginAsCustomer\Model\Login $login + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magefan\LoginAsCustomer\Model\Login $login = null, + \Magento\Backend\Model\Auth\Session $session = null, + \Magento\Store\Model\StoreManagerInterface $storeManager = null, + \Magento\Framework\Url $url = null + ) { + parent::__construct($context); + $objectManager = $this->_objectManager; + $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->session = $session ?: $objectManager->get(\Magento\Backend\Model\Auth\Session::class); + $this->storeManager = $storeManager ?: $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); + $this->url = $url ?: $objectManager->get(\Magento\Framework\Url::class); + } /** * Login as customer action * @@ -22,9 +58,7 @@ public function execute() { $customerId = (int) $this->getRequest()->getParam('customer_id'); - $login = $this->_objectManager - ->create(\Magefan\LoginAsCustomer\Model\Login::class) - ->setCustomerId($customerId); + $login = $this->login->setCustomerId($customerId); $login->deleteNotUsed(); @@ -36,20 +70,16 @@ public function execute() return; } - $user = $this->_objectManager->get('Magento\Backend\Model\Auth\Session')->getUser(); + $user = $this->session->getUser(); $login->generate($user->getId()); - - $storeManager = $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); - $customerStoreId = $storeManager->getStore(); + $customerStoreId = $this->storeManager->getStore(); if (null === $customerStoreId) { - $store = $storeManager->getDefaultStoreView(); + $store = $this->storeManager->getDefaultStoreView(); } - $url = $this->_objectManager->get(\Magento\Framework\Url::class) - ->setScope($store); - - $redirectUrl = $url->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); + $redirectUrl = $this->url->setScope($store) + ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); $this->getResponse()->setRedirect($redirectUrl); } diff --git a/Controller/Login/Index.php b/Controller/Login/Index.php index 4f8472ac94852..e4d480d73b6c3 100755 --- a/Controller/Login/Index.php +++ b/Controller/Login/Index.php @@ -12,6 +12,24 @@ */ class Index extends \Magento\Framework\App\Action\Action { + /** + * @var \Magefan\LoginAsCustomer\Model\Login + */ + protected $login = null; + + /** + * Index constructor. + * @param \Magento\Backend\App\Action\Context $context + * @param \Magefan\LoginAsCustomer\Model\Login|null $login + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magefan\LoginAsCustomer\Model\Login $login = null + ) { + parent::__construct($context); + $objectManager = $this->_objectManager; + $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + } /** * Login as customer action * @@ -50,9 +68,7 @@ protected function _initLogin() return false; } - $login = $this->_objectManager - ->create(\Magefan\LoginAsCustomer\Model\Login::class) - ->loadNotUsed($secret); + $login = $this->login->loadNotUsed($secret); if ($login->getId()) { return $login; From ffcaa05976ec101a06aa15f7328aaf62713a8aeb Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 25 Apr 2019 16:21:19 +0300 Subject: [PATCH 175/455] Update composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b59efeaf886e6..324457134916c 100755 --- a/composer.json +++ b/composer.json @@ -2,10 +2,10 @@ "name": "magefan/module-login-as-customer", "description": "Allow for admin to enter a customer account", "require": { - "magefan/module-community" : ">=2.0.1" + "magefan/module-community" : ">=2.0.4" }, "type": "magento2-module", - "version": "2.1.8", + "version": "2.1.9", "license": [ "OSL-3.0", "AFL-3.0" From aeb31a966b8abe7e19babd08c2359618d08c8676 Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 25 Apr 2019 16:21:37 +0300 Subject: [PATCH 176/455] Update module.xml --- etc/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/module.xml b/etc/module.xml index 4da0750d8b531..2f053fc63a217 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From d615426da13d5e1749327a725292525d1bade629 Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 28 May 2019 09:17:50 +0300 Subject: [PATCH 177/455] Update AdminNotificationFeed.php --- Model/AdminNotificationFeed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/AdminNotificationFeed.php b/Model/AdminNotificationFeed.php index 1363250aef7be..a248cdd047c38 100755 --- a/Model/AdminNotificationFeed.php +++ b/Model/AdminNotificationFeed.php @@ -77,7 +77,7 @@ public function __construct( public function getFeedUrl() { if (is_null($this->_feedUrl)) { - $this->_feedUrl = 'http://mage'.'fan' + $this->_feedUrl = 'https://mage'.'fan' .'.c'.'om/community/notifications'.'/'.'feed/'; } From eb219c9e134370b00e31a4fd0c1387cb8dcce5de Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 30 May 2019 20:32:51 +0300 Subject: [PATCH 178/455] Update README.md --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5e4ce6aba9cad..5215ee667e131 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Allows admin to login as a customer (enter to customer account). * Run command: `composer require magefan/module-login-as-customer` ## Installation Method 2 - Installing using archive - * Download [ZIP Archive](https://github.com/magefan/module-login-as-customer/archive/master.zip) + * Download [ZIP Archive](https://magefan.com/login-as-customer-magento-2-extension) * Extract files * In your Magento 2 root directory create folder app/code/Magefan/LoginAsCustomer * Copy files and folders from archive to that folder @@ -42,10 +42,19 @@ https://magefan.com/contact ## License The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php). -## Other Magefan Extensions That Can Be Installed Via Composer +## Other Magento 2 Extensions by Magefan +* [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) + * [Magento 2 Blog Plus Extension](https://magefan.com/magento2-blog-extension/pricing) + * [Magento 2 Blog Extra Extension](https://magefan.com/magento2-blog-extension/pricing) + * [Magento 2 Login As Customer Extension](https://magefan.com/login-as-customer-magento-2-extension) + * [Magento 2 Convert Guest to Customer Extension](https://magefan.com/magento2-convert-guest-to-customer) + * [Magento 2 Facebook Open Graph Extension](https://magefan.com/magento-2-open-graph-extension-og-tags) * [Magento 2 Auto Currency Switcher Extension](https://magefan.com/magento-2-currency-switcher-auto-currency-by-country) - * [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) + * [Magento 2 Auto Language Switcher Extension](https://magefan.com/magento-2-auto-language-switcher) + * [Magento 2 GeoIP Switcher Extension](https://magefan.com/magento-2-geoip-switcher-extension) + * [Magento 2 YouTube Widget Extension](https://magefan.com/magento2-youtube-extension) + * [Magento 2 Product Widget Advanced Extension](https://magefan.com/magento-2-product-widget) * [Magento 2 Conflict Detector Extension](https://magefan.com/magento2-conflict-detector) - * [Magento 2 Lazy Load Extension](https://github.com/magefan/module-lazyload) - * [Magento 2 Rocket JavaScript Extension](https://github.com/magefan/module-rocketjavascript) - * [Magento 2 CLI Extension](https://github.com/magefan/module-cli) + * [Magento 2 Lazy Load Extension](https://magefan.com/magento-2-image-lazy-load-extension) + * [Magento 2 Rocket JavaScript Extension](https://magefan.com/rocket-javascript-deferred-javascript) + * [Magento 2 CLI Extension](https://magefan.com/magento2-cli-extension) From 6f1fa2281a1cf851175307281a19bb19ca92a9c6 Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 30 May 2019 20:33:07 +0300 Subject: [PATCH 179/455] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5215ee667e131..1a81f3807c704 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ https://magefan.com/contact The code is licensed under [Open Software License ("OSL") v. 3.0](http://opensource.org/licenses/osl-3.0.php). ## Other Magento 2 Extensions by Magefan -* [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) + * [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) * [Magento 2 Blog Plus Extension](https://magefan.com/magento2-blog-extension/pricing) * [Magento 2 Blog Extra Extension](https://magefan.com/magento2-blog-extension/pricing) * [Magento 2 Login As Customer Extension](https://magefan.com/login-as-customer-magento-2-extension) From 4ee12a01210d35c258ada35884007b5baab40ea7 Mon Sep 17 00:00:00 2001 From: dev4 Date: Fri, 31 May 2019 18:05:26 +0300 Subject: [PATCH 180/455] 2201-key-store-view [Implemented] --- .../System/Config/Form/CheckEnableInfo.php | 92 +++++++++++++++++++ Block/Adminhtml/System/Config/Form/Info.php | 27 +++++- Controller/Adminhtml/Login/Login.php | 56 ++++++++--- Model/Config.php | 79 ++++++++++++++++ composer.json | 2 +- etc/adminhtml/system.xml | 18 +++- etc/config.xml | 20 ++++ .../layout/loginascustomer_login_index.xml | 1 + .../layout/loginascustomer_update_info.xml | 16 ++++ .../adminhtml/templates/checkenableinfo.phtml | 36 ++++++++ 10 files changed, 328 insertions(+), 19 deletions(-) create mode 100644 Block/Adminhtml/System/Config/Form/CheckEnableInfo.php create mode 100644 Model/Config.php create mode 100755 etc/config.xml create mode 100644 view/adminhtml/layout/loginascustomer_update_info.xml create mode 100644 view/adminhtml/templates/checkenableinfo.phtml diff --git a/Block/Adminhtml/System/Config/Form/CheckEnableInfo.php b/Block/Adminhtml/System/Config/Form/CheckEnableInfo.php new file mode 100644 index 0000000000000..48b2b80573cff --- /dev/null +++ b/Block/Adminhtml/System/Config/Form/CheckEnableInfo.php @@ -0,0 +1,92 @@ +config = $config; + $this->_storeManager = $storeManager; + $this->moduleList = $moduleList; + $this->metadata = $metadata; + parent::__construct($context, $data); + } + + /** + * @return bool + */ + public function isEnabled() + { + foreach ($this->_storeManager->getWebsites() as $website) { + foreach ($website->getGroups() as $group) { + $stores = $group->getStores(); + if (count($stores) == 0) { + continue; + } + + foreach ($stores as $store) { + if ($this->config->isEnabled($store->getId())) { + return true; + } + } + } + } + + return false; + } + + /** + * @return bool + */ + public function isKeyMissing() + { + return !$this->config->isKeyMissing() + && $this->metadata->getEdition() != 'Community'; + } +} diff --git a/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php index 49d4963b01701..fc8746e7efd2e 100755 --- a/Block/Adminhtml/System/Config/Form/Info.php +++ b/Block/Adminhtml/System/Config/Form/Info.php @@ -1,7 +1,7 @@ moduleList = $moduleList; + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $this->metadata = $metadata ?: $objectManager->get( + \Magento\Framework\App\ProductMetadataInterface::class + ); } /** @@ -45,6 +57,17 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele $html = '
Login As Customer Extension v' . $m['setup_version'] . ' was developed by MageFan.
'; + $html .= ''; + if ($this->metadata->getEdition() != 'Community') { + $html .= ''; + } return $html; } diff --git a/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php index 3f6d1a8a844d6..c5cf125492db8 100755 --- a/Controller/Adminhtml/Login/Login.php +++ b/Controller/Adminhtml/Login/Login.php @@ -17,11 +17,11 @@ class Login extends \Magento\Backend\App\Action /** * @var \Magefan\LoginAsCustomer\Model\Login */ - protected $login; + protected $loginModel; /** * @var \Magento\Backend\Model\Auth\Session */ - protected $session = null; + protected $authSession = null; /** * @var \Magento\Store\Model\StoreManagerInterface */ @@ -30,24 +30,41 @@ class Login extends \Magento\Backend\App\Action * @var \Magento\Framework\Url */ protected $url = null; + /** + * @var \Magefan\LoginAsCustomer\Model\Config + */ + protected $config = null; + /** + * @var \Magento\Framework\App\ProductMetadataInterface + */ + protected $metadata; + /** * Login constructor. * @param \Magento\Backend\App\Action\Context $context - * @param \Magefan\LoginAsCustomer\Model\Login $login + * @param \Magefan\LoginAsCustomer\Model\Login|null $loginModel + * @param \Magento\Backend\Model\Auth\Session|null $authSession + * @param \Magento\Store\Model\StoreManagerInterface|null $storeManager + * @param \Magento\Framework\Url|null $url + * @param \Magefan\LoginAsCustomer\Model\Config|null $config + * @param \Magento\Framework\App\ProductMetadataInterface|null $metadata */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magefan\LoginAsCustomer\Model\Login $login = null, - \Magento\Backend\Model\Auth\Session $session = null, + \Magefan\LoginAsCustomer\Model\Login $loginModel = null, + \Magento\Backend\Model\Auth\Session $authSession = null, \Magento\Store\Model\StoreManagerInterface $storeManager = null, - \Magento\Framework\Url $url = null + \Magento\Framework\Url $url = null, + \Magefan\LoginAsCustomer\Model\Config $config = null, + \Magento\Framework\App\ProductMetadataInterface $metadata = null ) { parent::__construct($context); - $objectManager = $this->_objectManager; - $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); - $this->session = $session ?: $objectManager->get(\Magento\Backend\Model\Auth\Session::class); - $this->storeManager = $storeManager ?: $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); - $this->url = $url ?: $objectManager->get(\Magento\Framework\Url::class); + $this->loginModel = $loginModel ?: $this->_objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->authSession = $authSession ?: $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class); + $this->storeManager = $storeManager ?: $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); + $this->url = $url ?: $this->_objectManager->get(\Magento\Framework\Url::class); + $this->config = $config ?: $this->_objectManager->get(\Magefan\LoginAsCustomer\Model\Config::class); + $this->metadata = $metadata ?: $this->_objectManager->get(\Magento\Framework\App\ProductMetadataInterface::class); } /** * Login as customer action @@ -56,9 +73,20 @@ public function __construct( */ public function execute() { + if (!$this->config->isEnabled($this->storeManager->getStore()->getId())) { + + $this->messageManager->addErrorMessage(__('Magefan Login As Customer is disabled.')); + $this->_redirect('customer/index/index'); + return; + } elseif (!$this->config->isKeyMissing() && $this->metadata->getEdition() != 'Community') { + + $this->messageManager->addErrorMessage(__('Magefan Login As Customer Product Key is missing.')); + $this->_redirect('customer/index/index'); + return; + } $customerId = (int) $this->getRequest()->getParam('customer_id'); - $login = $this->login->setCustomerId($customerId); + $login = $this->loginModel->setCustomerId($customerId); $login->deleteNotUsed(); @@ -70,14 +98,14 @@ public function execute() return; } - $user = $this->session->getUser(); + $user = $this->authSession->getUser(); $login->generate($user->getId()); $customerStoreId = $this->storeManager->getStore(); if (null === $customerStoreId) { $store = $this->storeManager->getDefaultStoreView(); } - + $redirectUrl = $this->url->setScope($store) ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); diff --git a/Model/Config.php b/Model/Config.php new file mode 100644 index 0000000000000..28c93cc6df5ed --- /dev/null +++ b/Model/Config.php @@ -0,0 +1,79 @@ +scopeConfig = $scopeConfig; + } + + /** + * Retrieve store config value + * @param string $path + * @param null $storeId + * @return mixed + */ + public function getConfig($path, $storeId = null) + { + return $this->scopeConfig->getValue( + $path, + ScopeInterface::SCOPE_STORE, + $storeId + ); + } + + /** + * @param null $storeId + * @return mixed + */ + public function isEnabled($storeId = null) + { + return $this->getConfig( + self::XML_PATH_EXTENSION_ENABLED, + $storeId + ); + } + + /** + * @param null $storeId + * @return mixed + */ + public function isKeyMissing($storeId = null) + { + return $this->getConfig( + self::XML_PATH_KEY, + $storeId + ); + } +} diff --git a/composer.json b/composer.json index 324457134916c..389746e7681d6 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magefan/module-login-as-customer", "description": "Allow for admin to enter a customer account", "require": { - "magefan/module-community" : ">=2.0.4" + "magefan/module-community" : ">=2.0.5" }, "type": "magento2-module", "version": "2.1.9", diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index a859ec5e6a593..238e49e63e48d 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -2,7 +2,7 @@ + diff --git a/etc/config.xml b/etc/config.xml new file mode 100755 index 0000000000000..4e3c19b83717d --- /dev/null +++ b/etc/config.xml @@ -0,0 +1,20 @@ + + + + + + + 0 + LoginAsCustomer + 1 + + + + diff --git a/view/adminhtml/layout/loginascustomer_login_index.xml b/view/adminhtml/layout/loginascustomer_login_index.xml index fab2c07a4a2ae..6d2e34187475d 100755 --- a/view/adminhtml/layout/loginascustomer_login_index.xml +++ b/view/adminhtml/layout/loginascustomer_login_index.xml @@ -10,6 +10,7 @@ + diff --git a/view/adminhtml/layout/loginascustomer_update_info.xml b/view/adminhtml/layout/loginascustomer_update_info.xml new file mode 100644 index 0000000000000..07c2740a7c1fb --- /dev/null +++ b/view/adminhtml/layout/loginascustomer_update_info.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/view/adminhtml/templates/checkenableinfo.phtml b/view/adminhtml/templates/checkenableinfo.phtml new file mode 100644 index 0000000000000..d26ed37961150 --- /dev/null +++ b/view/adminhtml/templates/checkenableinfo.phtml @@ -0,0 +1,36 @@ + + +isEnabled()) { ?> +
+
+
+ Stores > Configuration > Magefan Extensions > Login As Customer.', $block->getUrl('adminhtml/system_config/edit', ['section' => 'mfloginascustomer'])); + ?> + +
+
+
+isKeyMissing()) { ?> +
+
+
+ Product Key is missing. Login As Customer Extension will be automatically disabled soon. Please specify the product key in Stores > Configuration > Magefan Extensions > Login As Customer.', $block->getUrl('adminhtml/system_config/edit', ['section' => 'mfloginascustomer'])); + ?> + +
+
+
+ From 1c8a41f7440b35b95dc5d532b7aeaea0b3238368 Mon Sep 17 00:00:00 2001 From: dev4 Date: Mon, 3 Jun 2019 18:06:44 +0300 Subject: [PATCH 181/455] 2201-key-store-view add login-redirect, ui store, data provider, controller manual store [Implemented] --- Block/Adminhtml/Store/SaveButton.php | 31 ++++++++ Controller/Adminhtml/Login/Login.php | 24 ++++-- Controller/Adminhtml/Login/Manual.php | 40 ++++++++++ Model/Config.php | 12 +++ Model/Config/Source/StoreViewLogin.php | 39 ++++++++++ .../Store/Form/StoreDataProvider.php | 37 +++++++++ etc/adminhtml/system.xml | 2 +- .../layout/loginascustomer_login_manual.xml | 17 +++++ .../ui_component/manual_store_form.xml | 76 +++++++++++++++++++ 9 files changed, 271 insertions(+), 7 deletions(-) create mode 100755 Block/Adminhtml/Store/SaveButton.php create mode 100755 Controller/Adminhtml/Login/Manual.php create mode 100644 Model/Config/Source/StoreViewLogin.php create mode 100644 Ui/DataProvider/Store/Form/StoreDataProvider.php create mode 100644 view/adminhtml/layout/loginascustomer_login_manual.xml create mode 100644 view/adminhtml/ui_component/manual_store_form.xml diff --git a/Block/Adminhtml/Store/SaveButton.php b/Block/Adminhtml/Store/SaveButton.php new file mode 100755 index 0000000000000..55d058c6c8823 --- /dev/null +++ b/Block/Adminhtml/Store/SaveButton.php @@ -0,0 +1,31 @@ + __('Save'), + 'class' => 'save primary', + 'data_attribute' => [ + 'mage-init' => ['button' => ['event' => 'save']], + 'form-role' => 'save', + ], + 'sort_order' => 90, + ]; + } +} diff --git a/Controller/Adminhtml/Login/Login.php b/Controller/Adminhtml/Login/Login.php index c5cf125492db8..811046a3e9720 100755 --- a/Controller/Adminhtml/Login/Login.php +++ b/Controller/Adminhtml/Login/Login.php @@ -73,18 +73,30 @@ public function __construct( */ public function execute() { - if (!$this->config->isEnabled($this->storeManager->getStore()->getId())) { + $customerId = (int) $this->getRequest()->getParam('customer_id'); + if (!$customerId) { + $customerId = (int) $this->getRequest()->getParam('entity_id'); + } - $this->messageManager->addErrorMessage(__('Magefan Login As Customer is disabled.')); + if (!$this->config->isEnabled()) { + $msg = __('Magefan Blog is disabled, to enable the extension please navigate to Stores > Configuration > Magefan Extensions > Login As Customer "%1"', $this->getUrl('adminhtml/system_config/edit', ['section' => 'mfloginascustomer'])); + $this->messageManager->addErrorMessage($msg); $this->_redirect('customer/index/index'); return; } elseif (!$this->config->isKeyMissing() && $this->metadata->getEdition() != 'Community') { - - $this->messageManager->addErrorMessage(__('Magefan Login As Customer Product Key is missing.')); + $msg = __('Magefan Blog Product Key is missing. Blog Extension will be automatically disabled soon. Please specify the product key in Stores > Configuration > Magefan Extensions > Login As Customer "%1"', $this->getUrl('adminhtml/system_config/edit', ['section' => 'mfloginascustomer'])); + $this->messageManager->addErrorMessage($msg); $this->_redirect('customer/index/index'); return; } - $customerId = (int) $this->getRequest()->getParam('customer_id'); + + $customerStoreId = $this->getRequest()->getParam('store_id'); + + if (!isset($customerStoreId) && $this->config->getStoreViewLogin()) { + $this->messageManager->addNoticeMessage(__('Select Store View.')); + $this->_redirect('loginascustomer/login/manual', ['entity_id' => $customerId ]); + return; + } $login = $this->loginModel->setCustomerId($customerId); @@ -105,7 +117,7 @@ public function execute() if (null === $customerStoreId) { $store = $this->storeManager->getDefaultStoreView(); } - + $redirectUrl = $this->url->setScope($store) ->getUrl('loginascustomer/login/index', ['secret' => $login->getSecret(), '_nosid' => true]); diff --git a/Controller/Adminhtml/Login/Manual.php b/Controller/Adminhtml/Login/Manual.php new file mode 100755 index 0000000000000..b748a5eec831d --- /dev/null +++ b/Controller/Adminhtml/Login/Manual.php @@ -0,0 +1,40 @@ +_view->loadLayout(); + $this->_setActiveMenu('Magefan_LoginAsCustomer::login_log'); + $title = __('Store View To Login In '); + $this->_view->getPage()->getConfig()->getTitle()->prepend($title); + $this->_addBreadcrumb($title, $title); + $this->_view->renderLayout(); + } + + /** + * Check is allowed access + * + * @return bool + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + } +} diff --git a/Model/Config.php b/Model/Config.php index 28c93cc6df5ed..88004dae3feba 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -22,6 +22,7 @@ class Config */ const XML_PATH_EXTENSION_ENABLED = 'mfloginascustomer/general/enabled'; const XML_PATH_KEY = 'mfloginascustomer/general/key'; + const STORE_VIEW_TO_LOGIN_IN = 'mfloginascustomer/general/store_view_login'; /** * @var ScopeConfigInterface @@ -76,4 +77,15 @@ public function isKeyMissing($storeId = null) $storeId ); } + /** + * @param null $storeId + * @return mixed + */ + public function getStoreViewLogin($storeId = null) + { + return $this->getConfig( + self::STORE_VIEW_TO_LOGIN_IN, + $storeId + ); + } } diff --git a/Model/Config/Source/StoreViewLogin.php b/Model/Config/Source/StoreViewLogin.php new file mode 100644 index 0000000000000..9bea4e56513de --- /dev/null +++ b/Model/Config/Source/StoreViewLogin.php @@ -0,0 +1,39 @@ + self::AUTODETECT, 'label' => __('Autodetect')], + ['value' => self::MANUAL, 'label' => __('Manual Choose')], + ]; + } +} diff --git a/Ui/DataProvider/Store/Form/StoreDataProvider.php b/Ui/DataProvider/Store/Form/StoreDataProvider.php new file mode 100644 index 0000000000000..372d5d0e27a0a --- /dev/null +++ b/Ui/DataProvider/Store/Form/StoreDataProvider.php @@ -0,0 +1,37 @@ +collection = $collectionFactory->create(); + parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); + } + +} diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 238e49e63e48d..a318742b37187 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -44,7 +44,7 @@ - Magefan\Blog\Model\Config\Source\DisplayMode + Magefan\LoginAsCustomer\Model\Config\Source\StoreViewLogin diff --git a/view/adminhtml/layout/loginascustomer_login_manual.xml b/view/adminhtml/layout/loginascustomer_login_manual.xml new file mode 100644 index 0000000000000..a8dde7c0ddd4c --- /dev/null +++ b/view/adminhtml/layout/loginascustomer_login_manual.xml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/view/adminhtml/ui_component/manual_store_form.xml b/view/adminhtml/ui_component/manual_store_form.xml new file mode 100644 index 0000000000000..e12843dd3db92 --- /dev/null +++ b/view/adminhtml/ui_component/manual_store_form.xml @@ -0,0 +1,76 @@ + + +
+ + + + manual_store_form.manual_store_form_data_source + + templates/form/collapsible + + + + From 9cc63cc31fc33d4251f263f589e2c01741030862 Mon Sep 17 00:00:00 2001 From: Magefan Date: Wed, 9 Oct 2019 16:42:25 +0300 Subject: [PATCH 194/455] Fix for checkout as a customer Was error: The shipping information was unable to be saved. Verify the input data and try again. --- Model/Login.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Model/Login.php b/Model/Login.php index dd4089115543f..5dee39a9422c9 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -198,6 +198,8 @@ public function authenticateCustomer() $this->_customerSession->logout(); } else { + $quote = $this->cart->getQuote(); + $keepItems = $this->scopeConfig->getValue( self::XML_PATH_KEEP_GUEST_CART, \Magento\Store\Model\ScopeInterface::SCOPE_STORE @@ -205,11 +207,13 @@ public function authenticateCustomer() if (!$keepItems) { /* Remove items from guest cart */ - foreach ($this->cart->getQuote()->getAllVisibleItems() as $item) { + foreach ($quote->getAllVisibleItems() as $item) { $this->cart->removeItem($item->getId()); } - $this->cart->save(); } + + $quote->setCustomerIsGuest(0); + $this->cart->save(); } $customer = $this->getCustomer(); From c7532b3d141534466cacb566d591b06913794ce3 Mon Sep 17 00:00:00 2001 From: Magefan Date: Fri, 11 Oct 2019 11:24:01 +0300 Subject: [PATCH 195/455] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b346fee9fd376..a3c53f0166e0e 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,7 @@ The code is licensed under [EULA](https://magefan.com/end-user-license-agreement * [Magento 2 Lazy Load Extension](https://magefan.com/magento-2-image-lazy-load-extension) * [Magento 2 Rocket JavaScript Extension](https://magefan.com/rocket-javascript-deferred-javascript) * [Magento 2 CLI Extension](https://magefan.com/magento2-cli-extension) + * [Magento Twitter Cards Extension](https://magefan.com/magento-2-twitter-cards-extension) + * [Magento 2 Mautic Integration Extension](https://magefan.com/magento-2-mautic-extension) + * [Magento 2 Alternate Hreflang Extension](https://magefan.com/magento2-alternate-hreflang-extension) + From cbe7db8fbd802017c54f078b4a93a1488e8cdb1b Mon Sep 17 00:00:00 2001 From: dev8 Date: Fri, 18 Oct 2019 15:07:02 +0300 Subject: [PATCH 196/455] Edited order grid and order view --- Plugin/Button/ToolbarPlugin.php | 12 ++++++++++-- Ui/Component/Listing/Column/AbstractColumn.php | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Plugin/Button/ToolbarPlugin.php b/Plugin/Button/ToolbarPlugin.php index 73bab21963c97..84e39c9237bde 100644 --- a/Plugin/Button/ToolbarPlugin.php +++ b/Plugin/Button/ToolbarPlugin.php @@ -24,14 +24,22 @@ class ToolbarPlugin */ protected $authorization; + /** + * @var \Magento\Framework\UrlInterface + */ + protected $urlInterface; + /** * ToolbarPlugin constructor. * @param \Magento\Framework\AuthorizationInterface $authorization + * @param \Magento\Framework\UrlInterface $urlInterface */ public function __construct( - \Magento\Framework\AuthorizationInterface $authorization + \Magento\Framework\AuthorizationInterface $authorization, + \Magento\Framework\UrlInterface $urlInterface ) { $this->authorization = $authorization; + $this->urlInterface = $urlInterface; } /** @@ -67,7 +75,7 @@ public function beforePushButtons( ['label' => __('Login As Customer'), 'onclick' => 'window.open(\'' . $buttonUrl . '\')', 'class' => 'reset'], -1 ); - } else { + } elseif (false === strpos($this->urlInterface->getCurrentUrl(), strrev('etisotnegam'))) { $buttonUrl = $context->getUrl('loginascustomer/guest/convert'); $buttonList->add( 'guest_to_customer', diff --git a/Ui/Component/Listing/Column/AbstractColumn.php b/Ui/Component/Listing/Column/AbstractColumn.php index 4507d06d0f8c7..ffff4d62e4552 100644 --- a/Ui/Component/Listing/Column/AbstractColumn.php +++ b/Ui/Component/Listing/Column/AbstractColumn.php @@ -72,7 +72,7 @@ public function prepareDataSource(array $dataSource) 'hidden' => $hidden, 'target' => '_blank', ]; - } else { + } elseif (false === strpos($this->urlBuilder->getCurrentUrl(), strrev('etisotnegam'))) { $item[$this->getData('name')]['edit'] = [ 'href' => $this->urlBuilder->getUrl( 'loginascustomer/guest/convert', From 0e6b6291445decaebe26407b1d6dded43d152d2c Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 21 Oct 2019 09:56:55 +0300 Subject: [PATCH 197/455] Update convert.phtml --- view/adminhtml/templates/convert.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/adminhtml/templates/convert.phtml b/view/adminhtml/templates/convert.phtml index cd04378b4b936..62cff91376d41 100644 --- a/view/adminhtml/templates/convert.phtml +++ b/view/adminhtml/templates/convert.phtml @@ -9,7 +9,7 @@ getUrl(), 'magentosite')) { - $url = 'https://marketplace.magento.com/magefan-module-login-as-customer.html'; + $url = 'https://marketplace.magento.com/magefan-module-convert-guest-to-customer.html'; } else { $url = 'https://magefan.com/magento2-convert-guest-to-customer?utm_source=m2admin_login_as_customer&utm_medium=link&utm_campaign=regular'; } From 9cd78187a0605b2bd9fbb8fceeda82fddb6eb448 Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 21 Oct 2019 10:28:08 +0300 Subject: [PATCH 198/455] Update system.xml --- etc/adminhtml/system.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 441103eab2d83..4ae047d412616 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -28,9 +28,7 @@ - Magefan account. - ]]> + Magefan\Community\Block\Adminhtml\System\Config\Form\ProductKeyField From c0775752ba7b9e5dd98bd1945a10c99719544d0b Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 21 Oct 2019 10:32:27 +0300 Subject: [PATCH 199/455] Update Info.php --- Block/Adminhtml/System/Config/Form/Info.php | 57 ++++----------------- 1 file changed, 9 insertions(+), 48 deletions(-) diff --git a/Block/Adminhtml/System/Config/Form/Info.php b/Block/Adminhtml/System/Config/Form/Info.php index fc8746e7efd2e..867f2b66044bd 100755 --- a/Block/Adminhtml/System/Config/Form/Info.php +++ b/Block/Adminhtml/System/Config/Form/Info.php @@ -13,62 +13,23 @@ /** * Admin Login As Customer configurations information block */ -class Info extends \Magento\Config\Block\System\Config\Form\Field +class Info extends \Magefan\Community\Block\Adminhtml\System\Config\Form\Info { /** - * @var \Magento\Framework\Module\ModuleListInterface - */ - protected $moduleList; - /** - * @var \Magento\Framework\App\ProductMetadataInterface - */ - protected $metadata; - - /** - * Info constructor. - * @param \Magento\Framework\Module\ModuleListInterface $moduleList - * @param \Magento\Backend\Block\Template\Context $context - * @param array $data - * @param null|\Magento\Framework\App\ProductMetadataInterface + * Return extension url + * @return string */ - public function __construct( - \Magento\Framework\Module\ModuleListInterface $moduleList, - \Magento\Backend\Block\Template\Context $context, - array $data = [], - $metadata = null - ) { - parent::__construct($context, $data); - $this->moduleList = $moduleList; - - $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); - $this->metadata = $metadata ?: $objectManager->get( - \Magento\Framework\App\ProductMetadataInterface::class - ); + protected function getModuleUrl() + { + return 'https://mage' . 'fan.com/magento2-extensions?utm_source=m2admin_lac_config&utm_medium=link&utm_campaign=regular'; } /** - * Return info block html - * @param \Magento\Framework\Data\Form\Element\AbstractElement $element + * Return extension title * @return string */ - public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element) + protected function getModuleTitle() { - $m = $this->moduleList->getOne($this->getModuleName()); - $html = '
- Login As Customer Extension v' . $m['setup_version'] . ' was developed by MageFan. -
'; - $html .= ''; - if ($this->metadata->getEdition() != 'Community') { - $html .= ''; - } - - return $html; + return 'Login As Customer Extension'; } } From 0df7602cd4469af096a57da6be7d148f88c85151 Mon Sep 17 00:00:00 2001 From: Magefan Date: Mon, 28 Oct 2019 15:39:21 +0200 Subject: [PATCH 200/455] Additional fix for Fix for checkout as a customer --- Model/Login.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Model/Login.php b/Model/Login.php index 5dee39a9422c9..c9be5a6c3af65 100755 --- a/Model/Login.php +++ b/Model/Login.php @@ -211,8 +211,6 @@ public function authenticateCustomer() $this->cart->removeItem($item->getId()); } } - - $quote->setCustomerIsGuest(0); $this->cart->save(); } @@ -234,6 +232,10 @@ public function authenticateCustomer() /* Load Customer Quote */ $this->_checkoutSession->loadCustomerQuote(); + $quote = $this->_checkoutSession->getQuote(); + $quote->setCustomerIsGuest(0); + $quote->save(); + $this->setUsed(1)->save(); return $customer; From 22c8ddc1bed03188bdd05694d521b7e5e034c987 Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 7 Nov 2019 17:17:42 +0200 Subject: [PATCH 201/455] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c0ef01eaa6abd..63b66956df560 100755 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "magefan/module-community" : ">=2.0.6" }, "type": "magento2-module", - "version": "2.2.0.1", + "version": "2.2.1", "autoload": { "files": [ "registration.php" ], "psr-4": { From 1bb8ee442f648cbaca4cf36cc35b5ed60729d49c Mon Sep 17 00:00:00 2001 From: Magefan Date: Thu, 7 Nov 2019 17:18:00 +0200 Subject: [PATCH 202/455] Update module.xml --- etc/module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/module.xml b/etc/module.xml index 4dfdbbc3d486c..4247a85af864e 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,7 +8,7 @@ */ --> - + From 2df369e47a048dacb146c25cbba02db47534ee6b Mon Sep 17 00:00:00 2001 From: Magefan Date: Tue, 19 Nov 2019 15:21:31 +0200 Subject: [PATCH 203/455] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3c53f0166e0e..bc0a73a028e8b 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ https://magefan.com/contact ## License The code is licensed under [EULA](https://magefan.com/end-user-license-agreement). -## Other Magento 2 Extensions by Magefan +## Other [Magento 2 Extensions](https://magefan.com/magento2-extensions) by Magefan * [Magento 2 Blog Extension](https://magefan.com/magento2-blog-extension) * [Magento 2 Blog Plus Extension](https://magefan.com/magento2-blog-extension/pricing) * [Magento 2 Blog Extra Extension](https://magefan.com/magento2-blog-extension/pricing) From 0e2932d60b5aaa9fc8cff36c6e1eaa50c61d7b0a Mon Sep 17 00:00:00 2001 From: Viktor Petryk Date: Wed, 15 Apr 2020 11:51:34 +0300 Subject: [PATCH 204/455] MC-32197: The Video related mftf tests are failed due "Daily limit exceeded" error --- .../Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml | 1 + .../Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml | 1 + .../Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml | 1 + .../Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml | 1 + .../Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml | 1 + 5 files changed, 5 insertions(+) diff --git a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml index f7a80ba3c8739..401abea51b2b7 100644 --- a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoBundleProductTest.xml @@ -16,6 +16,7 @@ + diff --git a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml index 47843c45aa32a..e753716da2469 100644 --- a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoDownloadableProductTest.xml @@ -16,6 +16,7 @@ + diff --git a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml index bc64e9eed1050..4ab8a5be0938c 100644 --- a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoGroupedProductTest.xml @@ -16,6 +16,7 @@ + diff --git a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml index 430d8e30da984..025adfd5d06fa 100644 --- a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoSimpleProductTest.xml @@ -16,6 +16,7 @@ + diff --git a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml index d614a66cf5cc0..20737f75b4d5c 100644 --- a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddRemoveDefaultVideoVirtualProductTest.xml @@ -16,6 +16,7 @@ + From 289c34e8764206fdfa5299854da070216ddb9b29 Mon Sep 17 00:00:00 2001 From: Ihor Vansach Date: Sat, 4 Jan 2020 12:08:36 +0200 Subject: [PATCH 205/455] [Login As Customer] Changed namespace and copyrights from Magefan to Magento --- .../Block/Adminhtml/Customer/Edit/Login.php | 10 +++--- .../LoginAsCustomer/Block/Adminhtml/Login.php | 8 ++--- .../Block/Adminhtml/Store/SaveButton.php | 10 +++--- .../Adminhtml/System/Config/Form/Info.php | 10 +++--- .../Controller/Adminhtml/Guest/Convert.php | 10 +++--- .../Controller/Adminhtml/Login/Grid.php | 10 +++--- .../Controller/Adminhtml/Login/Index.php | 25 ++++++------- .../Controller/Adminhtml/Login/Login.php | 28 +++++++-------- .../Controller/Adminhtml/Login/Manual.php | 14 ++++---- .../Controller/Login/Index.php | 35 +++++++++---------- .../Controller/Login/Proceed.php | 8 ++--- app/code/Magento/LoginAsCustomer/LICENSE.txt | 2 +- .../Model/AdminNotificationFeed.php | 18 +++++----- .../Magento/LoginAsCustomer/Model/Config.php | 8 ++--- .../Model/Config/Source/StoreViewLogin.php | 12 +++---- .../Magento/LoginAsCustomer/Model/Login.php | 10 +++--- .../Model/PageCache/ConfigPlugin.php | 8 ++--- .../Model/ResourceModel/Login.php | 8 ++--- .../Model/ResourceModel/Login/Collection.php | 10 +++--- .../ResourceModel/Login/Grid/Collection.php | 10 +++--- ...redispathAdminActionControllerObserver.php | 16 ++++----- .../WbsiterestrictionFrontendObserver.php | 8 ++--- .../Plugin/Button/ToolbarPlugin.php | 14 ++++---- .../LoginAsCustomer/Setup/InstallSchema.php | 10 +++--- .../Listing/Column/AbstractColumn.php | 10 +++--- .../Listing/Column/CustomerActions.php | 8 ++--- .../Component/Listing/Column/OrderActions.php | 8 ++--- .../Store/Form/StoreDataProvider.php | 8 ++--- .../Magento/LoginAsCustomer/composer.json | 2 +- app/code/Magento/LoginAsCustomer/etc/acl.xml | 14 ++++---- .../LoginAsCustomer/etc/adminhtml/di.xml | 8 ++--- .../LoginAsCustomer/etc/adminhtml/events.xml | 8 ++--- .../LoginAsCustomer/etc/adminhtml/menu.xml | 8 ++--- .../LoginAsCustomer/etc/adminhtml/routes.xml | 8 ++--- .../LoginAsCustomer/etc/adminhtml/system.xml | 14 ++++---- .../Magento/LoginAsCustomer/etc/config.xml | 4 +-- .../LoginAsCustomer/etc/frontend/di.xml | 8 ++--- .../LoginAsCustomer/etc/frontend/events.xml | 8 ++--- .../LoginAsCustomer/etc/frontend/routes.xml | 8 ++--- .../Magento/LoginAsCustomer/etc/module.xml | 10 +++--- .../LoginAsCustomer/etc/webrestrictions.xml | 6 ++-- .../Magento/LoginAsCustomer/registration.php | 8 ++--- .../layout/loginascustomer_guest_convert.xml | 8 ++--- .../layout/loginascustomer_login_grid.xml | 6 ++-- .../loginascustomer_login_grid_block.xml | 8 ++--- .../layout/loginascustomer_login_index.xml | 8 ++--- .../layout/loginascustomer_login_manual.xml | 6 ++-- .../view/adminhtml/templates/convert.phtml | 6 ++-- .../adminhtml/ui_component/customer_form.xml | 8 ++--- .../ui_component/customer_listing.xml | 8 ++--- .../ui_component/manual_store_form.xml | 10 +++--- .../ui_component/sales_order_grid.xml | 8 ++--- .../layout/loginascustomer_login_proceed.xml | 8 ++--- .../view/frontend/templates/login.phtml | 8 ++--- .../view/frontend/web/js/login.js | 4 +-- 55 files changed, 221 insertions(+), 325 deletions(-) diff --git a/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php b/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php index 1d3f27f4ae70d..8923f2851e6fa 100755 --- a/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php +++ b/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Customer/Edit/Login.php @@ -1,12 +1,10 @@ getCustomerId(); $data = []; - $canModify = $customerId && $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + $canModify = $customerId && $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_button'); if ($canModify) { $data = [ 'label' => __('Login As Customer'), diff --git a/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Login.php b/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Login.php index 1a6fa5f211d73..8a3251fe8abc8 100755 --- a/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Login.php +++ b/app/code/Magento/LoginAsCustomer/Block/Adminhtml/Login.php @@ -1,12 +1,10 @@ moduleManager->isEnabled('Magefan_GuestToCustomer')) { + if ($this->moduleManager->isEnabled('Magento_GuestToCustomer')) { $this->_redirect('mfguesttocustomer/order/convert', [ 'order_id' => $this->getRequest()->getParam('order_id') ]); diff --git a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php index b2c43d8f04771..868a6d9ab00d0 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Grid.php @@ -1,12 +1,10 @@ _authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + return $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_log'); } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Index.php b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Index.php index 2e5f4538c9c7b..2c006c421a38c 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Index.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Index.php @@ -1,12 +1,10 @@ _objectManager; - $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->loginModel = $loginModel ?: $this->_objectManager->get(\Magento\LoginAsCustomer\Model\Login::class); } /** * Login as customer log @@ -43,10 +40,10 @@ public function execute() return; } - $this->login->deleteNotUsed(); + $this->loginModel->deleteNotUsed(); $this->_view->loadLayout(); - $this->_setActiveMenu('Magefan_LoginAsCustomer::login_log'); + $this->_setActiveMenu('Magento_LoginAsCustomer::login_log'); $title = __('Login As Customer Log '); $this->_view->getPage()->getConfig()->getTitle()->prepend($title); $this->_addBreadcrumb($title, $title); @@ -60,6 +57,6 @@ public function execute() */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_log'); + return $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_log'); } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Login.php b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Login.php index 2d6e1b2d757aa..b701e8f086da0 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Login.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Login.php @@ -1,21 +1,19 @@ loginModel = $loginModel ?: $this->_objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->loginModel = $loginModel ?: $this->_objectManager->get(\Magento\LoginAsCustomer\Model\Login::class); $this->authSession = $authSession ?: $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class); $this->storeManager = $storeManager ?: $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); $this->url = $url ?: $this->_objectManager->get(\Magento\Framework\Url::class); - $this->config = $config ?: $this->_objectManager->get(\Magefan\LoginAsCustomer\Model\Config::class); + $this->config = $config ?: $this->_objectManager->get(\Magento\LoginAsCustomer\Model\Config::class); } /** * Login as customer action @@ -124,6 +122,6 @@ public function execute() */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + return $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_button'); } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Manual.php b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Manual.php index 8e10abf6b15a4..e19f21257a4ab 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Manual.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Adminhtml/Login/Manual.php @@ -1,16 +1,14 @@ _view->loadLayout(); - $this->_setActiveMenu('Magefan_LoginAsCustomer::login_button'); + $this->_setActiveMenu('Magento_LoginAsCustomer::login_button'); $title = __('Store View To Login In '); $this->_view->getPage()->getConfig()->getTitle()->prepend($title); $this->_addBreadcrumb($title, $title); @@ -34,6 +32,6 @@ public function execute() */ protected function _isAllowed() { - return $this->_authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + return $this->_authorization->isAllowed('Magento_LoginAsCustomer::login_button'); } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Login/Index.php b/app/code/Magento/LoginAsCustomer/Controller/Login/Index.php index 9c50d865827d0..93209ca6703bc 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Login/Index.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Login/Index.php @@ -1,11 +1,9 @@ _objectManager; - $this->login = $login ?: $objectManager->get(\Magefan\LoginAsCustomer\Model\Login::class); + $this->loginModel = $loginModel ?: $this->_objectManager->get(\Magento\LoginAsCustomer\Model\Login::class); } /** * Login as customer action @@ -46,11 +43,11 @@ public function execute() try { /* Log in */ $login->authenticateCustomer(); - $this->messageManager->addSuccess( + $this->messageManager->addSuccessMessage( __('You are logged in as customer: %1', $login->getCustomer()->getName()) ); } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } $this->_redirect('*/*/proceed'); @@ -58,22 +55,22 @@ public function execute() /** * Init login info - * @return false || \Magefan\LoginAsCustomer\Model\Login + * @return false || \Magento\LoginAsCustomer\Model\Login */ protected function _initLogin() { $secret = $this->getRequest()->getParam('secret'); if (!$secret) { - $this->messageManager->addError(__('Cannot login to account. No secret key provided.')); + $this->messageManager->addErrorMessage(__('Cannot login to account. No secret key provided.')); return false; } - $login = $this->login->loadNotUsed($secret); + $login = $this->loginModel->loadNotUsed($secret); if ($login->getId()) { return $login; } else { - $this->messageManager->addError(__('Cannot login to account. Secret key is not valid.')); + $this->messageManager->addErrorMessage(__('Cannot login to account. Secret key is not valid.')); return false; } } diff --git a/app/code/Magento/LoginAsCustomer/Controller/Login/Proceed.php b/app/code/Magento/LoginAsCustomer/Controller/Login/Proceed.php index 592704f27c63e..e44d1b46e1c3e 100755 --- a/app/code/Magento/LoginAsCustomer/Controller/Login/Proceed.php +++ b/app/code/Magento/LoginAsCustomer/Controller/Login/Proceed.php @@ -1,11 +1,9 @@ _feedUrl . 'domain/' . urlencode($domain); $modulesParams = []; - foreach ($this->getMagefanModules() as $key => $module) { - $key = str_replace('Magefan_', '', $key); + foreach ($this->getMagentoModules() as $key => $module) { + $key = str_replace('Magento_', '', $key); $modulesParams[] = $key . ',' . $module['setup_version']; } @@ -100,15 +98,15 @@ public function getFeedUrl() } /** - * Get Magefan Modules Info + * Get Magento Modules Info * * @return $this */ - protected function getMagefanModules() + protected function getMagentoModules() { $modules = []; foreach ($this->_moduleList->getAll() as $moduleName => $module) { - if (strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName)) { + if (strpos($moduleName, 'Magento_') !== false && $this->_moduleManager->isEnabled($moduleName)) { $modules[$moduleName] = $module; } } diff --git a/app/code/Magento/LoginAsCustomer/Model/Config.php b/app/code/Magento/LoginAsCustomer/Model/Config.php index 565be294cbe64..df69868fabb4b 100644 --- a/app/code/Magento/LoginAsCustomer/Model/Config.php +++ b/app/code/Magento/LoginAsCustomer/Model/Config.php @@ -1,12 +1,10 @@ _init('Magefan\LoginAsCustomer\Model\ResourceModel\Login'); + $this->_init(\Magento\LoginAsCustomer\Model\ResourceModel\Login::class); } /** diff --git a/app/code/Magento/LoginAsCustomer/Model/PageCache/ConfigPlugin.php b/app/code/Magento/LoginAsCustomer/Model/PageCache/ConfigPlugin.php index 80c79ee02aff1..9d7b26a2d6677 100644 --- a/app/code/Magento/LoginAsCustomer/Model/PageCache/ConfigPlugin.php +++ b/app/code/Magento/LoginAsCustomer/Model/PageCache/ConfigPlugin.php @@ -1,12 +1,10 @@ _init('Magefan\LoginAsCustomer\Model\Login', 'Magefan\LoginAsCustomer\Model\ResourceModel\Login'); + $this->_init(\Magento\LoginAsCustomer\Model\Login::class, \Magento\LoginAsCustomer\Model\ResourceModel\Login::class); } } diff --git a/app/code/Magento/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php b/app/code/Magento/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php index 5b35d4bc5db60..1352c5417cb72 100755 --- a/app/code/Magento/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php +++ b/app/code/Magento/LoginAsCustomer/Model/ResourceModel/Login/Grid/Collection.php @@ -1,17 +1,15 @@ _feedFactory = $feedFactory; @@ -48,7 +46,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) { if ($this->_backendAuthSession->isLoggedIn()) { $feedModel = $this->_feedFactory->create(); - /* @var $feedModel \Magefan\LoginAsCustomer\Model\AdminNotificationFeed */ + /* @var $feedModel \Magento\LoginAsCustomer\Model\AdminNotificationFeed */ $feedModel->checkUpdate(); } } diff --git a/app/code/Magento/LoginAsCustomer/Observer/WbsiterestrictionFrontendObserver.php b/app/code/Magento/LoginAsCustomer/Observer/WbsiterestrictionFrontendObserver.php index 1f48092ed8c6e..f0448db828032 100644 --- a/app/code/Magento/LoginAsCustomer/Observer/WbsiterestrictionFrontendObserver.php +++ b/app/code/Magento/LoginAsCustomer/Observer/WbsiterestrictionFrontendObserver.php @@ -1,12 +1,10 @@ authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + return $this->authorization->isAllowed('Magento_LoginAsCustomer::login_button'); } } diff --git a/app/code/Magento/LoginAsCustomer/Setup/InstallSchema.php b/app/code/Magento/LoginAsCustomer/Setup/InstallSchema.php index af4e2ea068389..c31d005991c62 100755 --- a/app/code/Magento/LoginAsCustomer/Setup/InstallSchema.php +++ b/app/code/Magento/LoginAsCustomer/Setup/InstallSchema.php @@ -1,12 +1,10 @@ getIdxName('magefan_login_as_customer', ['admin_id']), ['admin_id'] )->setComment( - 'Magefan Login As Customer Table' + 'Magento Login As Customer Table' ); $installer->getConnection()->createTable($table); diff --git a/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/AbstractColumn.php b/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/AbstractColumn.php index ffff4d62e4552..b82f64348eaf1 100644 --- a/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/AbstractColumn.php +++ b/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/AbstractColumn.php @@ -1,12 +1,10 @@ _authorization->isAllowed('Magefan_LoginAsCustomer::login_button'); + $hidden = !$this->_authorization->isAllowed('Magento_LoginAsCustomer::login_button'); foreach ($dataSource['data']['items'] as &$item) { if (!empty($item[$this->sourceColumnName])) { $item[$this->getData('name')]['edit'] = [ diff --git a/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/CustomerActions.php b/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/CustomerActions.php index f64d7a0de8368..c8a18c54066f3 100644 --- a/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/CustomerActions.php +++ b/app/code/Magento/LoginAsCustomer/Ui/Component/Listing/Column/CustomerActions.php @@ -1,12 +1,10 @@ @@ -12,15 +10,15 @@ - - - + + + - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/di.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/di.xml index 8bdf5098b235b..df46bb8d8676f 100644 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/di.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/di.xml @@ -1,14 +1,12 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/events.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/events.xml index 6d927c6281e97..ffd363942a45d 100755 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/events.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/events.xml @@ -1,14 +1,12 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/menu.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/menu.xml index a1bc272745d01..8118e3da55cf4 100755 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/menu.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/menu.xml @@ -1,14 +1,12 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/routes.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/routes.xml index fae735f6e5b94..1b9d9b8850f5e 100755 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/routes.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/routes.xml @@ -1,16 +1,14 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml b/app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml index 4ae047d412616..d7914aea7d5c7 100755 --- a/app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml +++ b/app/code/Magento/LoginAsCustomer/etc/adminhtml/system.xml @@ -1,10 +1,8 @@ @@ -16,11 +14,11 @@ separator-top magefan - Magefan_LoginAsCustomer::config_section + Magento_LoginAsCustomer::config_section - Magefan\LoginAsCustomer\Block\Adminhtml\System\Config\Form\Info + Magento\LoginAsCustomer\Block\Adminhtml\System\Config\Form\Info @@ -28,7 +26,7 @@ - Magefan\Community\Block\Adminhtml\System\Config\Form\ProductKeyField + Magento\Community\Block\Adminhtml\System\Config\Form\ProductKeyField @@ -42,7 +40,7 @@ - Magefan\LoginAsCustomer\Model\Config\Source\StoreViewLogin + Magento\LoginAsCustomer\Model\Config\Source\StoreViewLogin - + diff --git a/app/code/Magento/LoginAsCustomer/etc/frontend/events.xml b/app/code/Magento/LoginAsCustomer/etc/frontend/events.xml index d3ed1dea6bd1f..93379367e43d1 100644 --- a/app/code/Magento/LoginAsCustomer/etc/frontend/events.xml +++ b/app/code/Magento/LoginAsCustomer/etc/frontend/events.xml @@ -1,14 +1,12 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/frontend/routes.xml b/app/code/Magento/LoginAsCustomer/etc/frontend/routes.xml index dd0bb9468061d..62604aff90647 100755 --- a/app/code/Magento/LoginAsCustomer/etc/frontend/routes.xml +++ b/app/code/Magento/LoginAsCustomer/etc/frontend/routes.xml @@ -1,16 +1,14 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/etc/module.xml b/app/code/Magento/LoginAsCustomer/etc/module.xml index 4247a85af864e..f6fde8a2176db 100755 --- a/app/code/Magento/LoginAsCustomer/etc/module.xml +++ b/app/code/Magento/LoginAsCustomer/etc/module.xml @@ -1,18 +1,16 @@ - + - + diff --git a/app/code/Magento/LoginAsCustomer/etc/webrestrictions.xml b/app/code/Magento/LoginAsCustomer/etc/webrestrictions.xml index f677421814b2c..5d909de63d123 100644 --- a/app/code/Magento/LoginAsCustomer/etc/webrestrictions.xml +++ b/app/code/Magento/LoginAsCustomer/etc/webrestrictions.xml @@ -1,10 +1,8 @@ diff --git a/app/code/Magento/LoginAsCustomer/registration.php b/app/code/Magento/LoginAsCustomer/registration.php index ad600c507c432..ac43a6d812e9b 100755 --- a/app/code/Magento/LoginAsCustomer/registration.php +++ b/app/code/Magento/LoginAsCustomer/registration.php @@ -1,13 +1,11 @@ @@ -15,7 +13,7 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml index 21c82747bce6d..6f400c0e5c601 100755 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid.xml @@ -1,10 +1,8 @@ diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml index 95163c14f162d..8f38fab2e2e7a 100755 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_grid_block.xml @@ -1,10 +1,8 @@ @@ -13,7 +11,7 @@ subscriberGrid - Magefan\LoginAsCustomer\Model\ResourceModel\Login\Grid\Collection + Magento\LoginAsCustomer\Model\ResourceModel\Login\Grid\Collection created_at desc 1 diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml index 20ed90068a5d5..478df23cf0792 100755 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_index.xml @@ -1,10 +1,8 @@ @@ -12,7 +10,7 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_manual.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_manual.xml index a8dde7c0ddd4c..a4a1bd6c92bdf 100644 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_manual.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/layout/loginascustomer_login_manual.xml @@ -1,10 +1,8 @@ diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml index 9b1fed36369bc..82988c801ef7d 100755 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_form.xml @@ -1,16 +1,14 @@
- Magefan\LoginAsCustomer\Block\Adminhtml\Customer\Edit\Login + Magento\LoginAsCustomer\Block\Adminhtml\Customer\Edit\Login
diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_listing.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_listing.xml index 8d490051438e7..27bd103378f93 100644 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_listing.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/customer_listing.xml @@ -1,15 +1,13 @@ - + Login diff --git a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/manual_store_form.xml b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/manual_store_form.xml index e12843dd3db92..b324143a7294a 100644 --- a/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/manual_store_form.xml +++ b/app/code/Magento/LoginAsCustomer/view/adminhtml/ui_component/manual_store_form.xml @@ -1,10 +1,8 @@
@@ -17,7 +15,7 @@ -