diff --git a/.gitignore b/.gitignore index 7a2f12aac2541..90b240f3af0e9 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ atlassian* /var/* !/var/.htaccess +/vendor diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a4d7ccf5c67c..a00a72467d328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,58 @@ +0.1.0-alpha90 +============= + * Service layer implementation: + * Created the Admin Shopping Cart Service + * Created the Create Shopping Cart Items Service + * Created the Create Shopping Cart Shipping Address Service + * Created the Create Shopping Cart Billing Address Service + * Created the Service Layer for Orders + * Created CRUD service & APIs to manage options for configurable products + * Created CRUD service & APIs to manage options for bundle products + * Fixed bugs: + * Fixed an issue where adding a customer address with an invalid value of the custom address attribute caused a fatal error in SOAP + * Fixed an issue where the wrong FedEx rates were displayed + * Fixed an issue where the Bill Me Later option did not work in Payflow payment methods + * Fixed an issue where order comments were broken for orders placed with Authorize.net + * Fixed the naming of the My Account -> Recurring Payment page + * Fixed a UI elements issue in the disabled Magento_PayPalRecurringPayment and Magento_RecurringPayment modules + * Fixed an issue where it was impossible to save configuration of a configurable product when adding it to an order in the Admin panel + * Fixed an issue where the Select a store page was displayed during admin order creation when the Single Store mode was enabled + * Fixed an issue when an exception was thrown when attempting to open the Customer Account page if the Recently Viewed widget was configured for the store + * Updated the content of the Privacy Policy page + * Fixed an issue where it was possible to update a tax rate using the POST http method + * Fixed an issue where it was impossible to update Inventory Qty for a SKU using API + * Fixed a JavaScript syntax error on the Create New Customer page + * Fixed an issue where it was impossible to add new sample while creating a downloadable product + * Fixed a JavaScript which appeared when clicking the Add New Address button in the Address Book on the storefront + * Fixed an issue where it was possible to update Tax Rules using the PUT http method which is supposed to be used for create operation only + * Fixed an issue where it was possible to create a Tax Rule specifying a product tax class instead of a customer tax class and vice versa + * Fixed an issue with making websiteId a mandatory field when updating a customer using REST + * Fixed an issue where the default value was not applied after clicking the 'Use default' link for a product price field in the catalog in the Admin panel + * Fixed an issue where the price update mass action could not be performed + * Fixed a JS error in the cross-sells product settings in the Admin panel + * Added the following functional tests: + * Mass Delete Backend Customer + * Moderate Product Review + * Framework improvements: + * Added the ability to access admin functionality using admin user login for mobile + * Refactored and unified Access Control List (ACL) to make it more consistent + * Created a Cookie Manager (a cookie management class) + * Changes in functional tests: + * Enabled the CustomerMetadataService tests for SOAP + * Themes update: + * Fixed issues in the Blank theme + * Implemented improvements for the Blank theme, core templates and Storefront UI Library + * Modularity: + * Created the Notification library component and made it possible to disable the AdminNotification module + * Made it possible to disable the SendToFriend module + * Created an optional ConfigurableImportExport module to remove dependency between the CatalogImportExport and ConfigurableProduct modules + * Created an optional GroupedImportExport module to remove dependency between the CatalogImportExport and GroupedProduct modules + * Introduce search library: + * Created a Search request configuration + * Created a Query object structure from the XML declaration + * Composer Integration: + * Added support for using 3rd-party components as Composer packages + 0.1.0-alpha89 ============= * Fixed bugs: diff --git a/README.md b/README.md index fe79310ea4cca..2b7d837ea1746 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,4 @@ All Submissions you make to Magento, an eBay Inc. company (“Magento”) throug 1. You grant Magento a perpetual, worldwide, non-exclusive, no charge, royalty free, irrevocable license under your applicable copyrights and patents to reproduce, prepare derivative works of, display, publically perform, sublicense and distribute any feedback, ideas, code, or other information (“Submission”) you submit through GitHub. 2. Your Submission is an original work of authorship and you are the owner or are legally entitled to grant the license stated above. +3. You agree to the X.commerce Agreement found here: https://www.x.com/developers/x.commerce/x.commerce-user-agreement. diff --git a/app/autoload.php b/app/autoload.php index f2ab699eefe54..073340091ce7a 100644 --- a/app/autoload.php +++ b/app/autoload.php @@ -23,5 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +$vendorDir = require __DIR__ . '/etc/vendor_path.php'; +$vendorAutoload = __DIR__ . '/../' . $vendorDir . '/autoload.php'; +if (file_exists($vendorAutoload)) { + require_once $vendorAutoload; +} require_once __DIR__ . '/../lib/internal/Magento/Framework/Autoload/IncludePath.php'; spl_autoload_register([new \Magento\Framework\Autoload\IncludePath(), 'load']); diff --git a/app/bootstrap.php b/app/bootstrap.php index f9b998c6bce1a..31abb9bdfa5c7 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -30,9 +30,9 @@ umask(0); /* PHP version validation */ -if (version_compare(phpversion(), '5.4.0', '<') === true) { +if (version_compare(phpversion(), '5.4.11', '<') === true) { if (PHP_SAPI == 'cli') { - echo 'Magento supports PHP 5.4.0 or newer. Please read http://www.magento.com/install.'; + echo 'Magento supports PHP 5.4.11 or newer. Please read http://www.magento.com/install.'; } else { echo << @@ -40,7 +40,7 @@

Whoops, it looks like you have an invalid PHP version.

-

Magento supports PHP 5.4.0 or newer. +

Magento supports PHP 5.4.11 or newer. Find out how to install Magento using PHP-CGI as a work-around.

@@ -60,7 +60,6 @@ * Require necessary files */ require_once BP . '/app/functions.php'; - require_once __DIR__ . '/autoload.php'; (new \Magento\Framework\Autoload\IncludePath())->addIncludePath(array(BP . '/app/code', BP . '/lib/internal')); $classMapPath = BP . '/var/classmap.ser'; diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php index e227a878d8c22..a3be2bc9ccef4 100644 --- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php +++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php @@ -25,6 +25,8 @@ */ namespace Magento\AdminNotification\Block\Grid\Renderer; +use \Magento\Framework\Notification\MessageInterface; + class Severity extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** @@ -58,21 +60,21 @@ public function render(\Magento\Framework\Object $row) $value = ''; switch ($row->getData($this->getColumn()->getIndex())) { - case \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL: + case MessageInterface::SEVERITY_CRITICAL: $class = 'critical'; - $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL); + $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_CRITICAL); break; - case \Magento\AdminNotification\Model\Inbox::SEVERITY_MAJOR: + case MessageInterface::SEVERITY_MAJOR: $class = 'major'; - $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_MAJOR); + $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_MAJOR); break; - case \Magento\AdminNotification\Model\Inbox::SEVERITY_MINOR: + case MessageInterface::SEVERITY_MINOR: $class = 'minor'; - $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_MINOR); + $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_MINOR); break; - case \Magento\AdminNotification\Model\Inbox::SEVERITY_NOTICE: + case MessageInterface::SEVERITY_NOTICE: $class = 'notice'; - $value = $this->_notice->getSeverities(\Magento\AdminNotification\Model\Inbox::SEVERITY_NOTICE); + $value = $this->_notice->getSeverities(MessageInterface::SEVERITY_NOTICE); break; } return '' . $value . ''; diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php index 19695d3a9e4b5..9af0a88bfcc20 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages.php @@ -70,14 +70,14 @@ protected function _toHtml() /** * Retrieve message list * - * @return \Magento\AdminNotification\Model\System\MessageInterface[] + * @return \Magento\Framework\Notification\MessageInterface[] */ public function getLastCritical() { $items = array_values($this->_messages->getItems()); if (isset( $items[0] - ) && $items[0]->getSeverity() == \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL + ) && $items[0]->getSeverity() == \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL ) { return $items[0]; } @@ -92,7 +92,7 @@ public function getLastCritical() public function getCriticalCount() { return $this->_messages->getCountBySeverity( - \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL ); } @@ -104,7 +104,7 @@ public function getCriticalCount() public function getMajorCount() { return $this->_messages->getCountBySeverity( - \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR + \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR ); } diff --git a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php index fbc13f1755268..e5e88769696bd 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages/UnreadMessagePopup.php @@ -17,13 +17,13 @@ * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. - * + * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace Magento\AdminNotification\Block\System\Messages; -use Magento\AdminNotification\Model\System\MessageInterface; +use Magento\Framework\Notification\MessageInterface; class UnreadMessagePopup extends \Magento\Backend\Block\Template { diff --git a/app/code/Magento/AdminNotification/Model/Inbox.php b/app/code/Magento/AdminNotification/Model/Inbox.php index 7e762b79a6e08..e620d1472a61a 100644 --- a/app/code/Magento/AdminNotification/Model/Inbox.php +++ b/app/code/Magento/AdminNotification/Model/Inbox.php @@ -23,6 +23,9 @@ */ namespace Magento\AdminNotification\Model; +use \Magento\Framework\Notification\MessageInterface; +use \Magento\Framework\Notification\NotifierInterface; + /** * AdminNotification Inbox model * @@ -45,16 +48,8 @@ * * @author Magento Core Team */ -class Inbox extends \Magento\Framework\Model\AbstractModel +class Inbox extends \Magento\Framework\Model\AbstractModel implements NotifierInterface { - const SEVERITY_CRITICAL = 1; - - const SEVERITY_MAJOR = 2; - - const SEVERITY_MINOR = 3; - - const SEVERITY_NOTICE = 4; - /** * @return void */ @@ -72,10 +67,10 @@ protected function _construct() public function getSeverities($severity = null) { $severities = array( - self::SEVERITY_CRITICAL => __('critical'), - self::SEVERITY_MAJOR => __('major'), - self::SEVERITY_MINOR => __('minor'), - self::SEVERITY_NOTICE => __('notice') + MessageInterface::SEVERITY_CRITICAL => __('critical'), + MessageInterface::SEVERITY_MAJOR => __('major'), + MessageInterface::SEVERITY_MINOR => __('minor'), + MessageInterface::SEVERITY_NOTICE => __('notice') ); if (!is_null($severity)) { @@ -118,7 +113,8 @@ public function getNoticeStatus() */ public function parse(array $data) { - return $this->getResource()->parse($this, $data); + $this->getResource()->parse($this, $data); + return $this; } /** @@ -167,7 +163,7 @@ public function add($severity, $title, $description, $url = '', $isInternal = tr */ public function addCritical($title, $description, $url = '', $isInternal = true) { - $this->add(self::SEVERITY_CRITICAL, $title, $description, $url, $isInternal); + $this->add(MessageInterface::SEVERITY_CRITICAL, $title, $description, $url, $isInternal); return $this; } @@ -182,7 +178,7 @@ public function addCritical($title, $description, $url = '', $isInternal = true) */ public function addMajor($title, $description, $url = '', $isInternal = true) { - $this->add(self::SEVERITY_MAJOR, $title, $description, $url, $isInternal); + $this->add(MessageInterface::SEVERITY_MAJOR, $title, $description, $url, $isInternal); return $this; } @@ -197,7 +193,7 @@ public function addMajor($title, $description, $url = '', $isInternal = true) */ public function addMinor($title, $description, $url = '', $isInternal = true) { - $this->add(self::SEVERITY_MINOR, $title, $description, $url, $isInternal); + $this->add(MessageInterface::SEVERITY_MINOR, $title, $description, $url, $isInternal); return $this; } @@ -212,7 +208,7 @@ public function addMinor($title, $description, $url = '', $isInternal = true) */ public function addNotice($title, $description, $url = '', $isInternal = true) { - $this->add(self::SEVERITY_NOTICE, $title, $description, $url, $isInternal); + $this->add(MessageInterface::SEVERITY_NOTICE, $title, $description, $url, $isInternal); return $this; } } diff --git a/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php b/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php index 870c60a0c1a08..48086ca6ec037 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php +++ b/app/code/Magento/AdminNotification/Model/Resource/Inbox/Collection/Critical.php @@ -54,7 +54,7 @@ protected function _initSelect() array('neq' => 1) )->addFieldToFilter( 'severity', - \Magento\AdminNotification\Model\Inbox::SEVERITY_CRITICAL + \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL )->setPageSize( 1 ); diff --git a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php index 8e44afd3851e1..bea61d7a1c425 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php +++ b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection.php @@ -17,7 +17,7 @@ * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. - * + * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,7 +28,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac /** * System message list * - * @var \Magento\AdminNotification\Model\System\MessageList + * @var \Magento\Framework\Notification\MessageList */ protected $_messageList; @@ -44,7 +44,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac * @param \Magento\Framework\Logger $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\AdminNotification\Model\System\MessageList $messageList + * @param \Magento\Framework\Notification\MessageList $messageList * @param mixed $connection * @param \Magento\Framework\Model\Resource\Db\AbstractDb $resource */ @@ -53,7 +53,7 @@ public function __construct( \Magento\Framework\Logger $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\AdminNotification\Model\System\MessageList $messageList, + \Magento\Framework\Notification\MessageList $messageList, $connection = null, \Magento\Framework\Model\Resource\Db\AbstractDb $resource = null ) { diff --git a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php index c848602c9de06..444e85dfa2e70 100644 --- a/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php +++ b/app/code/Magento/AdminNotification/Model/Resource/System/Message/Collection/Synchronized.php @@ -17,7 +17,7 @@ * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. - * + * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,7 +28,7 @@ class Synchronized extends \Magento\AdminNotification\Model\Resource\System\Mess /** * Unread message list * - * @var \Magento\AdminNotification\Model\System\MessageInterface[] + * @var \Magento\Framework\Notification\MessageInterface[] */ protected $_unreadMessages = array(); @@ -74,7 +74,7 @@ public function _afterLoad() /** * Retrieve list of unread messages * - * @return \Magento\AdminNotification\Model\System\MessageInterface[] + * @return \Magento\Framework\Notification\MessageInterface[] */ public function getUnread() { diff --git a/app/code/Magento/AdminNotification/Model/System/Message.php b/app/code/Magento/AdminNotification/Model/System/Message.php index d4588cf27e11a..4701404784803 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message.php +++ b/app/code/Magento/AdminNotification/Model/System/Message.php @@ -17,13 +17,13 @@ * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. - * + * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace Magento\AdminNotification\Model\System; -class Message extends \Magento\Framework\Model\AbstractModel implements \Magento\AdminNotification\Model\System\MessageInterface +class Message extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\Notification\MessageInterface { /** * @return void diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php index 2ede00eb20d10..92cc992a3b3a9 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\System\Message; -class Baseurl implements \Magento\AdminNotification\Model\System\MessageInterface +class Baseurl implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Framework\UrlInterface diff --git a/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php b/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php index a7f57b85e2123..75154b6ad9c51 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/CacheOutdated.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\System\Message; -class CacheOutdated implements \Magento\AdminNotification\Model\System\MessageInterface +class CacheOutdated implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Framework\UrlInterface @@ -124,6 +124,6 @@ public function getLink() */ public function getSeverity() { - return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL; + return \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL; } } diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php b/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php index 5e1c628a00dcd..515b60a1229b5 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Media/AbstractSynchronization.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\System\Message\Media; -abstract class AbstractSynchronization implements \Magento\AdminNotification\Model\System\MessageInterface +abstract class AbstractSynchronization implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Core\Model\File\Storage\Flag @@ -94,6 +94,6 @@ public function isDisplayed() */ public function getSeverity() { - return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR; + return \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR; } } diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Security.php b/app/code/Magento/AdminNotification/Model/System/Message/Security.php index 6a67afb6d0ff6..be4632352156b 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Security.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Security.php @@ -23,7 +23,7 @@ */ namespace Magento\AdminNotification\Model\System\Message; -class Security implements \Magento\AdminNotification\Model\System\MessageInterface +class Security implements \Magento\Framework\Notification\MessageInterface { /** * Cache key for saving verification result @@ -160,6 +160,6 @@ public function getText() */ public function getSeverity() { - return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_CRITICAL; + return \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL; } } diff --git a/app/code/Magento/AdminNotification/composer.json b/app/code/Magento/AdminNotification/composer.json index d6f84501f5473..ebd21d9c35d9d 100644 --- a/app/code/Magento/AdminNotification/composer.json +++ b/app/code/Magento/AdminNotification/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-admin-notification", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/AdminNotification/etc/adminhtml/acl.xml b/app/code/Magento/AdminNotification/etc/acl.xml similarity index 95% rename from app/code/Magento/AdminNotification/etc/adminhtml/acl.xml rename to app/code/Magento/AdminNotification/etc/acl.xml index 86839ec9013db..46059d5147d92 100644 --- a/app/code/Magento/AdminNotification/etc/adminhtml/acl.xml +++ b/app/code/Magento/AdminNotification/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/AdminNotification/etc/adminhtml/di.xml b/app/code/Magento/AdminNotification/etc/adminhtml/di.xml index 3c16d79e9a5ea..9c8ba85f63df1 100644 --- a/app/code/Magento/AdminNotification/etc/adminhtml/di.xml +++ b/app/code/Magento/AdminNotification/etc/adminhtml/di.xml @@ -24,13 +24,12 @@ */ --> - + Magento\AdminNotification\Model\System\Message\Baseurl Magento\AdminNotification\Model\System\Message\Security Magento\AdminNotification\Model\System\Message\CacheOutdated - Magento\AdminNotification\Model\System\Message\Survey Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error Magento\AdminNotification\Model\System\Message\Media\Synchronization\Success diff --git a/app/code/Magento/AdminNotification/etc/di.xml b/app/code/Magento/AdminNotification/etc/di.xml new file mode 100644 index 0000000000000..a6372146ba8fd --- /dev/null +++ b/app/code/Magento/AdminNotification/etc/di.xml @@ -0,0 +1,34 @@ + + + + + + + Magento\AdminNotification\Model\Inbox + + + + diff --git a/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js b/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js index 710f9b6561af6..b5710b6b02861 100644 --- a/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js +++ b/app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js @@ -55,18 +55,6 @@ define([ }); $(document).ready(function(){ - $('body').on('surveyYes surveyNo', function(e, data) { - if (e.type == 'surveyYes') { - var win = window.open(data.surveyUrl, '', 'width=900,height=600,resizable=1,scrollbars=1'); - win.focus(); - } - $.ajax({ - url: data.surveyAction, - type: 'post', - data: {decision: data.decision} - }) - }); - $('#system_messages .message-system-short .error').on('click', function() { $('#message-system-all').systemMessageDialog('open', 1); }); @@ -75,4 +63,4 @@ define([ }); }); -}); \ No newline at end of file +}); diff --git a/app/code/Magento/Authorization/Model/Acl/AclRetriever.php b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php new file mode 100644 index 0000000000000..2e131fb3e149b --- /dev/null +++ b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php @@ -0,0 +1,165 @@ +logger = $logger; + $this->rulesCollectionFactory = $rulesCollectionFactory; + $this->aclBuilder = $aclBuilder; + $this->roleCollectionFactory = $roleCollectionFactory; + } + + /** + * Get a list of available resources using user details + * + * @param string $userType + * @param int $userId + * @return string[] + * @throws AuthorizationException + * @throws LocalizedException + */ + public function getAllowedResourcesByUser($userType, $userId) + { + if ($userType == UserContextInterface::USER_TYPE_GUEST) { + return [self::PERMISSION_ANONYMOUS]; + } elseif ($userType == UserContextInterface::USER_TYPE_CUSTOMER) { + return [self::PERMISSION_SELF]; + } + try { + $role = $this->_getUserRole($userType, $userId); + if (!$role) { + throw new AuthorizationException('The role associated with the specified user cannot be found.'); + } + $allowedResources = $this->getAllowedResourcesByRole($role->getId()); + } catch (AuthorizationException $e) { + throw $e; + } catch (\Exception $e) { + $this->logger->logException($e); + throw new LocalizedException( + 'Error happened while getting a list of allowed resources. Check exception log for details.' + ); + } + return $allowedResources; + } + + /** + * Get a list of available resource using user role id + * + * @param string $roleId + * @return string[] + */ + public function getAllowedResourcesByRole($roleId) + { + $allowedResources = []; + $rulesCollection = $this->rulesCollectionFactory->create(); + $rulesCollection->getByRoles($roleId)->load(); + $acl = $this->aclBuilder->getAcl(); + /** @var \Magento\Authorization\Model\Rules $ruleItem */ + foreach ($rulesCollection->getItems() as $ruleItem) { + $resourceId = $ruleItem->getResourceId(); + if ($acl->has($resourceId) && $acl->isAllowed($roleId, $resourceId)) { + $allowedResources[] = $resourceId; + } + } + return $allowedResources; + } + + /** + * Identify user role from user identifier. + * + * @param string $userType + * @param int $userId + * @return \Magento\Authorization\Model\Role|bool False if no role associated with provided user was found. + * @throws \LogicException + */ + protected function _getUserRole($userType, $userId) + { + if (!$this->_canRoleBeCreatedForUserType($userType)) { + throw new \LogicException( + "The role with user type '{$userType}' does not exist and cannot be created" + ); + } + $roleCollection = $this->roleCollectionFactory->create(); + /** @var Role $role */ + $role = $roleCollection->setUserFilter($userId, $userType)->getFirstItem(); + return $role->getId() ? $role : false; + } + + /** + * Check if the role can be associated with user having provided user type. + * + * Roles can be created for integrations and admin users only. + * + * @param int $userType + * @return bool + */ + protected function _canRoleBeCreatedForUserType($userType) + { + return ($userType == UserContextInterface::USER_TYPE_INTEGRATION) + || ($userType == UserContextInterface::USER_TYPE_ADMIN); + } +} diff --git a/app/code/Magento/User/Model/Acl/Loader/Role.php b/app/code/Magento/Authorization/Model/Acl/Loader/Role.php similarity index 79% rename from app/code/Magento/User/Model/Acl/Loader/Role.php rename to app/code/Magento/Authorization/Model/Acl/Loader/Role.php index 4054deab32508..dc82131a87f36 100644 --- a/app/code/Magento/User/Model/Acl/Loader/Role.php +++ b/app/code/Magento/Authorization/Model/Acl/Loader/Role.php @@ -21,10 +21,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Acl\Loader; +namespace Magento\Authorization\Model\Acl\Loader; -use Magento\User\Model\Acl\Role\Group as RoleGroup; -use Magento\User\Model\Acl\Role\User as RoleUser; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\User as RoleUser; class Role implements \Magento\Framework\Acl\LoaderInterface { @@ -34,23 +34,23 @@ class Role implements \Magento\Framework\Acl\LoaderInterface protected $_resource; /** - * @var \Magento\User\Model\Acl\Role\GroupFactory + * @var \Magento\Authorization\Model\Acl\Role\GroupFactory */ protected $_groupFactory; /** - * @var \Magento\User\Model\Acl\Role\UserFactory + * @var \Magento\Authorization\Model\Acl\Role\UserFactory */ protected $_roleFactory; /** - * @param \Magento\User\Model\Acl\Role\GroupFactory $groupFactory - * @param \Magento\User\Model\Acl\Role\UserFactory $roleFactory + * @param \Magento\Authorization\Model\Acl\Role\GroupFactory $groupFactory + * @param \Magento\Authorization\Model\Acl\Role\UserFactory $roleFactory * @param \Magento\Framework\App\Resource $resource */ public function __construct( - \Magento\User\Model\Acl\Role\GroupFactory $groupFactory, - \Magento\User\Model\Acl\Role\UserFactory $roleFactory, + \Magento\Authorization\Model\Acl\Role\GroupFactory $groupFactory, + \Magento\Authorization\Model\Acl\Role\UserFactory $roleFactory, \Magento\Framework\App\Resource $resource ) { $this->_resource = $resource; @@ -66,7 +66,7 @@ public function __construct( */ public function populateAcl(\Magento\Framework\Acl $acl) { - $roleTableName = $this->_resource->getTableName('admin_role'); + $roleTableName = $this->_resource->getTableName('authorization_role'); $adapter = $this->_resource->getConnection('core_read'); $select = $adapter->select()->from($roleTableName)->order('tree_level'); diff --git a/app/code/Magento/User/Model/Acl/Loader/Rule.php b/app/code/Magento/Authorization/Model/Acl/Loader/Rule.php similarity index 95% rename from app/code/Magento/User/Model/Acl/Loader/Rule.php rename to app/code/Magento/Authorization/Model/Acl/Loader/Rule.php index 25230c259ff89..8a2953d65d1f2 100644 --- a/app/code/Magento/User/Model/Acl/Loader/Rule.php +++ b/app/code/Magento/Authorization/Model/Acl/Loader/Rule.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Acl\Loader; +namespace Magento\Authorization\Model\Acl\Loader; class Rule implements \Magento\Framework\Acl\LoaderInterface { @@ -53,7 +53,7 @@ public function __construct( */ public function populateAcl(\Magento\Framework\Acl $acl) { - $ruleTable = $this->_resource->getTableName("admin_rule"); + $ruleTable = $this->_resource->getTableName("authorization_rule"); $adapter = $this->_resource->getConnection('core_read'); diff --git a/app/code/Magento/User/Model/Acl/Role/Generic.php b/app/code/Magento/Authorization/Model/Acl/Role/Generic.php similarity index 93% rename from app/code/Magento/User/Model/Acl/Role/Generic.php rename to app/code/Magento/Authorization/Model/Acl/Role/Generic.php index 80a8b3f6cdee3..3b39cf76eaacd 100644 --- a/app/code/Magento/User/Model/Acl/Role/Generic.php +++ b/app/code/Magento/Authorization/Model/Acl/Role/Generic.php @@ -21,10 +21,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Acl\Role; +namespace Magento\Authorization\Model\Acl\Role; /** - * User acl role + * Generic acl role */ class Generic extends \Zend_Acl_Role { diff --git a/app/code/Magento/User/Model/Acl/Role/Group.php b/app/code/Magento/Authorization/Model/Acl/Role/Group.php similarity index 90% rename from app/code/Magento/User/Model/Acl/Role/Group.php rename to app/code/Magento/Authorization/Model/Acl/Role/Group.php index 08b5df2068844..7c2346d4f59d3 100644 --- a/app/code/Magento/User/Model/Acl/Role/Group.php +++ b/app/code/Magento/Authorization/Model/Acl/Role/Group.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Acl\Role; +namespace Magento\Authorization\Model\Acl\Role; /** * Acl Group model */ -class Group extends \Magento\User\Model\Acl\Role\Generic +class Group extends \Magento\Authorization\Model\Acl\Role\Generic { /** * All the group roles are prepended by G diff --git a/app/code/Magento/User/Model/Acl/Role/User.php b/app/code/Magento/Authorization/Model/Acl/Role/User.php similarity index 90% rename from app/code/Magento/User/Model/Acl/Role/User.php rename to app/code/Magento/Authorization/Model/Acl/Role/User.php index 4d37e7ca89adb..69383609782c7 100644 --- a/app/code/Magento/User/Model/Acl/Role/User.php +++ b/app/code/Magento/Authorization/Model/Acl/Role/User.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Acl\Role; +namespace Magento\Authorization\Model\Acl\Role; /** * User acl role */ -class User extends \Magento\User\Model\Acl\Role\Generic +class User extends \Magento\Authorization\Model\Acl\Role\Generic { /** * All the user roles are prepended by U diff --git a/app/code/Magento/Authorization/Model/CompositeUserContext.php b/app/code/Magento/Authorization/Model/CompositeUserContext.php new file mode 100644 index 0000000000000..5707ac12a3252 --- /dev/null +++ b/app/code/Magento/Authorization/Model/CompositeUserContext.php @@ -0,0 +1,129 @@ +add($userContext['type']); + } + } + + /** + * Add user context. + * + * @param UserContextInterface $userContext + * @return CompositeUserContext + */ + protected function add(UserContextInterface $userContext) + { + $this->userContexts[] = $userContext; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getUserId() + { + return $this->getUserContext() ? $this->getUserContext()->getUserId() : null; + } + + /** + * {@inheritdoc} + */ + public function getUserType() + { + return $this->getUserContext() ? $this->getUserContext()->getUserType() : null; + } + + /** + * Retrieve user context + * + * @return UserContextInterface|bool False if none of the registered user contexts can identify user type + */ + protected function getUserContext() + { + if (is_null($this->chosenUserContext)) { + /** @var UserContextInterface $userContext */ + foreach ($this->userContexts as $userContext) { + if ($userContext->getUserType() && !is_null($userContext->getUserId())) { + $this->chosenUserContext = $userContext; + break; + } + } + if (is_null($this->chosenUserContext)) { + $this->chosenUserContext = false; + } + } + return $this->chosenUserContext; + } + + /** + * Compare contexts sortOrder + * + * @param array $contextDataFirst + * @param array $contextDataSecond + * @return int + */ + protected function compareContextsSortOrder($contextDataFirst, $contextDataSecond) + { + if ((int)$contextDataFirst['sortOrder'] == (int)$contextDataSecond['sortOrder']) { + return 0; + } + + if ((int)$contextDataFirst['sortOrder'] < (int)$contextDataSecond['sortOrder']) { + return -1; + } else { + return 1; + } + } +} diff --git a/app/code/Magento/User/Model/Resource/Permissions/Collection.php b/app/code/Magento/Authorization/Model/Resource/Permissions/Collection.php similarity index 88% rename from app/code/Magento/User/Model/Resource/Permissions/Collection.php rename to app/code/Magento/Authorization/Model/Resource/Permissions/Collection.php index 2ca9f8d6506b4..4fca3cee80e13 100644 --- a/app/code/Magento/User/Model/Resource/Permissions/Collection.php +++ b/app/code/Magento/Authorization/Model/Resource/Permissions/Collection.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Resource\Permissions; +namespace Magento\Authorization\Model\Resource\Permissions; /** * Admin permissions collection @@ -37,6 +37,6 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac */ protected function _construct() { - $this->_init('Magento\User\Model\Rules', 'Magento\User\Model\Resource\Rules'); + $this->_init('Magento\Authorization\Model\Rules', 'Magento\Authorization\Model\Resource\Rules'); } } diff --git a/app/code/Magento/User/Model/Resource/Role.php b/app/code/Magento/Authorization/Model/Resource/Role.php similarity index 76% rename from app/code/Magento/User/Model/Resource/Role.php rename to app/code/Magento/Authorization/Model/Resource/Role.php index ea45c024f84d9..e79cf181e42bc 100644 --- a/app/code/Magento/User/Model/Resource/Role.php +++ b/app/code/Magento/Authorization/Model/Resource/Role.php @@ -21,22 +21,15 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Resource; +namespace Magento\Authorization\Model\Resource; -use Magento\User\Model\Acl\Role\User as RoleUser; +use Magento\Authorization\Model\Acl\Role\User as RoleUser; /** * Admin role resource model */ class Role extends \Magento\Framework\Model\Resource\Db\AbstractDb { - /** - * Users table - * - * @var string - */ - protected $_usersTable; - /** * Rule table * @@ -78,10 +71,8 @@ public function __construct( */ protected function _construct() { - $this->_init('admin_role', 'role_id'); - - $this->_usersTable = $this->getTable('admin_user'); - $this->_ruleTable = $this->getTable('admin_rule'); + $this->_init('authorization_role', 'role_id'); + $this->_ruleTable = $this->getTable('authorization_rule'); } /** @@ -139,7 +130,6 @@ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $role) */ protected function _afterSave(\Magento\Framework\Model\AbstractModel $role) { - $this->_updateRoleUsersAcl($role); $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(\Magento\Backend\Block\Menu::CACHE_TAGS)); return $this; } @@ -164,47 +154,21 @@ protected function _afterDelete(\Magento\Framework\Model\AbstractModel $role) /** * Get role users * - * @param \Magento\User\Model\Role $role + * @param \Magento\Authorization\Model\Role $role * @return array */ - public function getRoleUsers(\Magento\User\Model\Role $role) + public function getRoleUsers(\Magento\Authorization\Model\Role $role) { $read = $this->_getReadAdapter(); $binds = array('role_id' => $role->getId(), 'role_type' => RoleUser::ROLE_TYPE); - $select = $read->select()->from( - $this->getMainTable(), - array('user_id') - )->where( - 'parent_id = :role_id' - )->where( - 'role_type = :role_type' - )->where( - 'user_id > 0' - ); + $select = $read->select() + ->from($this->getMainTable(), array('user_id')) + ->where('parent_id = :role_id') + ->where('role_type = :role_type') + ->where('user_id > 0'); return $read->fetchCol($select, $binds); } - - /** - * Update role users ACL - * - * @param \Magento\User\Model\Role $role - * @return bool - */ - private function _updateRoleUsersAcl(\Magento\User\Model\Role $role) - { - $write = $this->_getWriteAdapter(); - $users = $this->getRoleUsers($role); - $rowsCount = 0; - - if (sizeof($users) > 0) { - $bind = array('reload_acl_flag' => 1); - $where = array('user_id IN(?)' => $users); - $rowsCount = $write->update($this->_usersTable, $bind, $where); - } - - return $rowsCount > 0; - } } diff --git a/app/code/Magento/User/Model/Resource/Role/Collection.php b/app/code/Magento/Authorization/Model/Resource/Role/Collection.php similarity index 89% rename from app/code/Magento/User/Model/Resource/Role/Collection.php rename to app/code/Magento/Authorization/Model/Resource/Role/Collection.php index 3cce8f1b699cc..98e25949f8a51 100644 --- a/app/code/Magento/User/Model/Resource/Role/Collection.php +++ b/app/code/Magento/Authorization/Model/Resource/Role/Collection.php @@ -21,9 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Resource\Role; +namespace Magento\Authorization\Model\Resource\Role; -use Magento\User\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; /** * Admin role collection @@ -37,7 +37,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac */ protected function _construct() { - $this->_init('Magento\User\Model\Role', 'Magento\User\Model\Resource\Role'); + $this->_init('Magento\Authorization\Model\Role', 'Magento\Authorization\Model\Resource\Role'); } /** diff --git a/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php b/app/code/Magento/Authorization/Model/Resource/Role/Grid/Collection.php similarity index 85% rename from app/code/Magento/User/Model/Resource/Role/Grid/Collection.php rename to app/code/Magento/Authorization/Model/Resource/Role/Grid/Collection.php index a111d9b1d60a9..9355017b41d60 100644 --- a/app/code/Magento/User/Model/Resource/Role/Grid/Collection.php +++ b/app/code/Magento/Authorization/Model/Resource/Role/Grid/Collection.php @@ -21,14 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Resource\Role\Grid; +namespace Magento\Authorization\Model\Resource\Role\Grid; -use Magento\User\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; /** * Admin role data grid collection */ -class Collection extends \Magento\User\Model\Resource\Role\Collection +class Collection extends \Magento\Authorization\Model\Resource\Role\Collection { /** * Prepare select for load diff --git a/app/code/Magento/User/Model/Resource/Rules.php b/app/code/Magento/Authorization/Model/Resource/Rules.php similarity index 95% rename from app/code/Magento/User/Model/Resource/Rules.php rename to app/code/Magento/Authorization/Model/Resource/Rules.php index 1a82b9a498289..478eff8864c77 100644 --- a/app/code/Magento/User/Model/Resource/Rules.php +++ b/app/code/Magento/Authorization/Model/Resource/Rules.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Resource; +namespace Magento\Authorization\Model\Resource; /** * Admin rule resource model @@ -80,17 +80,17 @@ public function __construct( */ protected function _construct() { - $this->_init('admin_rule', 'rule_id'); + $this->_init('authorization_rule', 'rule_id'); } /** * Save ACL resources * - * @param \Magento\User\Model\Rules $rule + * @param \Magento\Authorization\Model\Rules $rule * @return void * @throws \Magento\Framework\Model\Exception */ - public function saveRel(\Magento\User\Model\Rules $rule) + public function saveRel(\Magento\Authorization\Model\Rules $rule) { try { $adapter = $this->_getWriteAdapter(); diff --git a/app/code/Magento/User/Model/Resource/Rules/Collection.php b/app/code/Magento/Authorization/Model/Resource/Rules/Collection.php similarity index 91% rename from app/code/Magento/User/Model/Resource/Rules/Collection.php rename to app/code/Magento/Authorization/Model/Resource/Rules/Collection.php index 8814282b44043..a07788825876b 100644 --- a/app/code/Magento/User/Model/Resource/Rules/Collection.php +++ b/app/code/Magento/Authorization/Model/Resource/Rules/Collection.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Resource\Rules; +namespace Magento\Authorization\Model\Resource\Rules; /** * Rules collection @@ -37,7 +37,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac */ protected function _construct() { - $this->_init('Magento\User\Model\Rules', 'Magento\User\Model\Resource\Rules'); + $this->_init('Magento\Authorization\Model\Rules', 'Magento\Authorization\Model\Resource\Rules'); } /** diff --git a/app/code/Magento/User/Model/Resource/Setup.php b/app/code/Magento/Authorization/Model/Resource/Setup.php similarity index 69% rename from app/code/Magento/User/Model/Resource/Setup.php rename to app/code/Magento/Authorization/Model/Resource/Setup.php index da215bd1e5866..e66ee4ec3dd32 100644 --- a/app/code/Magento/User/Model/Resource/Setup.php +++ b/app/code/Magento/Authorization/Model/Resource/Setup.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model\Resource; +namespace Magento\Authorization\Model\Resource; /** * Resource Setup Model @@ -34,49 +34,49 @@ class Setup extends \Magento\Framework\Module\Setup /** * Role model factory * - * @var \Magento\User\Model\RoleFactory + * @var \Magento\Authorization\Model\RoleFactory */ protected $_roleCollectionFactory; /** - * Factory for user rules model + * Factory for rules model * - * @var \Magento\User\Model\RulesFactory + * @var \Magento\Authorization\Model\RulesFactory */ protected $_rulesCollectionFactory; /** * Role model factory * - * @var \Magento\User\Model\RoleFactory + * @var \Magento\Authorization\Model\RoleFactory */ protected $_roleFactory; /** * Rules model factory * - * @var \Magento\User\Model\RulesFactory + * @var \Magento\Authorization\Model\RulesFactory */ protected $_rulesFactory; /** * @param \Magento\Framework\Module\Setup\Context $context * @param string $resourceName - * @param \Magento\User\Model\Resource\Role\CollectionFactory $roleCollectionFactory - * @param \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory - * @param \Magento\User\Model\RoleFactory $roleFactory - * @param \Magento\User\Model\RulesFactory $rulesFactory + * @param \Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory + * @param \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory + * @param \Magento\Authorization\Model\RoleFactory $roleFactory + * @param \Magento\Authorization\Model\RulesFactory $rulesFactory * @param string $moduleName * @param string $connectionName */ public function __construct( \Magento\Framework\Module\Setup\Context $context, $resourceName, - \Magento\User\Model\Resource\Role\CollectionFactory $roleCollectionFactory, - \Magento\User\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory, - \Magento\User\Model\RoleFactory $roleFactory, - \Magento\User\Model\RulesFactory $rulesFactory, - $moduleName = 'Magento_User', + \Magento\Authorization\Model\Resource\Role\CollectionFactory $roleCollectionFactory, + \Magento\Authorization\Model\Resource\Rules\CollectionFactory $rulesCollectionFactory, + \Magento\Authorization\Model\RoleFactory $roleFactory, + \Magento\Authorization\Model\RulesFactory $rulesFactory, + $moduleName = 'Magento_Authorization', $connectionName = \Magento\Framework\Module\Updater\SetupInterface::DEFAULT_SETUP_CONNECTION ) { $this->_roleCollectionFactory = $roleCollectionFactory; @@ -89,7 +89,7 @@ public function __construct( /** * Creates role collection * - * @return \Magento\User\Model\Resource\Role\Collection + * @return \Magento\Authorization\Model\Resource\Role\Collection */ public function createRoleCollection() { @@ -99,7 +99,7 @@ public function createRoleCollection() /** * Creates rules collection * - * @return \Magento\User\Model\Resource\Rules\Collection + * @return \Magento\Authorization\Model\Resource\Rules\Collection */ public function createRulesCollection() { @@ -109,7 +109,7 @@ public function createRulesCollection() /** * Creates role model * - * @return \Magento\User\Model\Role + * @return \Magento\Authorization\Model\Role */ public function createRole() { @@ -119,7 +119,7 @@ public function createRole() /** * Creates rules model * - * @return \Magento\User\Model\Rules + * @return \Magento\Authorization\Model\Rules */ public function createRules() { diff --git a/app/code/Magento/User/Model/Role.php b/app/code/Magento/Authorization/Model/Role.php similarity index 58% rename from app/code/Magento/User/Model/Role.php rename to app/code/Magento/Authorization/Model/Role.php index ae3bc63f6346a..68d9f92763122 100644 --- a/app/code/Magento/User/Model/Role.php +++ b/app/code/Magento/Authorization/Model/Role.php @@ -21,57 +21,49 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model; +namespace Magento\Authorization\Model; /** * Admin Role Model * - * @method \Magento\User\Model\Resource\Role _getResource() - * @method \Magento\User\Model\Resource\Role getResource() + * @method \Magento\Authorization\Model\Resource\Role _getResource() + * @method \Magento\Authorization\Model\Resource\Role getResource() * @method int getParentId() - * @method \Magento\User\Model\Role setParentId(int $value) + * @method \Magento\Authorization\Model\Role setParentId(int $value) * @method int getTreeLevel() - * @method \Magento\User\Model\Role setTreeLevel(int $value) + * @method \Magento\Authorization\Model\Role setTreeLevel(int $value) * @method int getSortOrder() - * @method \Magento\User\Model\Role setSortOrder(int $value) + * @method \Magento\Authorization\Model\Role setSortOrder(int $value) * @method string getRoleType() - * @method \Magento\User\Model\Role setRoleType(string $value) + * @method \Magento\Authorization\Model\Role setRoleType(string $value) * @method int getUserId() - * @method \Magento\User\Model\Role setUserId(int $value) + * @method \Magento\Authorization\Model\Role setUserId(int $value) * @method string getUserType() - * @method \Magento\User\Model\Role setUserType(string $value) + * @method \Magento\Authorization\Model\Role setUserType(string $value) * @method string getRoleName() - * @method \Magento\User\Model\Role setRoleName(string $value) + * @method \Magento\Authorization\Model\Role setRoleName(string $value) */ class Role extends \Magento\Framework\Model\AbstractModel { /** * @var string */ - protected $_eventPrefix = 'admin_roles'; - - /** - * @var \Magento\User\Model\Resource\Role\User\CollectionFactory - */ - protected $_userRolesFactory; + protected $_eventPrefix = 'authorization_roles'; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param Resource\Role\User\CollectionFactory $userRolesFactory - * @param Resource\Role $resource - * @param Resource\Role\Collection $resourceCollection + * @param \Magento\Authorization\Model\Resource\Role $resource + * @param \Magento\Authorization\Model\Resource\Role\Collection $resourceCollection * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\User\Model\Resource\Role\User\CollectionFactory $userRolesFactory, - \Magento\User\Model\Resource\Role $resource, - \Magento\User\Model\Resource\Role\Collection $resourceCollection, + \Magento\Authorization\Model\Resource\Role $resource, + \Magento\Authorization\Model\Resource\Role\Collection $resourceCollection, array $data = array() ) { - $this->_userRolesFactory = $userRolesFactory; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -81,7 +73,7 @@ public function __construct( public function __sleep() { $properties = parent::__sleep(); - return array_diff($properties, array('_userRolesFactory', '_resource', '_resourceCollection')); + return array_diff($properties, array('_resource', '_resourceCollection')); } /** @@ -91,9 +83,8 @@ public function __wakeup() { parent::__wakeup(); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); - $this->_userRolesFactory = $objectManager->get('Magento\User\Model\Resource\Role\User\CollectionFactory'); - $this->_resource = $objectManager->get('Magento\User\Model\Resource\Role'); - $this->_resourceCollection = $objectManager->get('Magento\User\Model\Resource\Role\Collection'); + $this->_resource = $objectManager->get('Magento\Authorization\Model\Resource\Role'); + $this->_resourceCollection = $objectManager->get('Magento\Authorization\Model\Resource\Role\Collection'); } /** @@ -103,7 +94,7 @@ public function __wakeup() */ protected function _construct() { - $this->_init('Magento\User\Model\Resource\Role'); + $this->_init('Magento\Authorization\Model\Resource\Role'); } /** @@ -117,16 +108,6 @@ public function update() return $this; } - /** - * Retrieve users collection - * - * @return \Magento\User\Model\Resource\Role\User\Collection - */ - public function getUsersCollection() - { - return $this->_userRolesFactory->create(); - } - /** * Return users for role * diff --git a/app/code/Magento/User/Model/Rules.php b/app/code/Magento/Authorization/Model/Rules.php similarity index 68% rename from app/code/Magento/User/Model/Rules.php rename to app/code/Magento/Authorization/Model/Rules.php index abfa69254f888..8418ffaa3ff64 100644 --- a/app/code/Magento/User/Model/Rules.php +++ b/app/code/Magento/Authorization/Model/Rules.php @@ -21,23 +21,24 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\User\Model; + +namespace Magento\Authorization\Model; /** * Admin Rules Model * - * @method \Magento\User\Model\Resource\Rules _getResource() - * @method \Magento\User\Model\Resource\Rules getResource() + * @method \Magento\Authorization\Model\Resource\Rules _getResource() + * @method \Magento\Authorization\Model\Resource\Rules getResource() * @method int getRoleId() - * @method \Magento\User\Model\Rules setRoleId(int $value) + * @method \Magento\Authorization\Model\Rules setRoleId(int $value) * @method string getResourceId() - * @method \Magento\User\Model\Rules setResourceId(string $value) + * @method \Magento\Authorization\Model\Rules setResourceId(string $value) * @method string getPrivileges() - * @method \Magento\User\Model\Rules setPrivileges(string $value) + * @method \Magento\Authorization\Model\Rules setPrivileges(string $value) * @method int getAssertId() - * @method \Magento\User\Model\Rules setAssertId(int $value) + * @method \Magento\Authorization\Model\Rules setAssertId(int $value) * @method string getPermission() - * @method \Magento\User\Model\Rules setPermission(string $value) + * @method \Magento\Authorization\Model\Rules setPermission(string $value) */ class Rules extends \Magento\Framework\Model\AbstractModel { @@ -46,15 +47,15 @@ class Rules extends \Magento\Framework\Model\AbstractModel * * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param Resource\Rules $resource - * @param Resource\Permissions\Collection $resourceCollection + * @param \Magento\Authorization\Model\Resource\Rules $resource + * @param \Magento\Authorization\Model\Resource\Permissions\Collection $resourceCollection * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\User\Model\Resource\Rules $resource, - \Magento\User\Model\Resource\Permissions\Collection $resourceCollection, + \Magento\Authorization\Model\Resource\Rules $resource, + \Magento\Authorization\Model\Resource\Permissions\Collection $resourceCollection, array $data = array() ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -67,7 +68,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\User\Model\Resource\Rules'); + $this->_init('Magento\Authorization\Model\Resource\Rules'); } /** diff --git a/app/code/Magento/Authz/Model/UserLocatorInterface.php b/app/code/Magento/Authorization/Model/UserContextInterface.php similarity index 76% rename from app/code/Magento/Authz/Model/UserLocatorInterface.php rename to app/code/Magento/Authorization/Model/UserContextInterface.php index 361e62e09cebd..948eb755390f2 100644 --- a/app/code/Magento/Authz/Model/UserLocatorInterface.php +++ b/app/code/Magento/Authorization/Model/UserContextInterface.php @@ -21,24 +21,34 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Authz\Model; + +namespace Magento\Authorization\Model; /** * Interface for current user identification. */ -interface UserLocatorInterface +interface UserContextInterface { + /**#@+ + * User type + */ + const USER_TYPE_INTEGRATION = 1; + const USER_TYPE_ADMIN = 2; + const USER_TYPE_CUSTOMER = 3; + const USER_TYPE_GUEST = 4; + /**#@-*/ + /** * Identify current user ID. * - * @return int + * @return int|null */ public function getUserId(); /** - * Retrieve current user type (Admin, Customer, Guest, Integration). + * Retrieve current user type. * - * @return string + * @return int|null */ public function getUserType(); } diff --git a/app/code/Magento/Authorization/composer.json b/app/code/Magento/Authorization/composer.json new file mode 100644 index 0000000000000..a00c08d4b68de --- /dev/null +++ b/app/code/Magento/Authorization/composer.json @@ -0,0 +1,20 @@ +{ + "name": "magento/module-authorization", + "description": "Authorization module provides access to Magento ACL functionality.", + "require": { + "php": "~5.4.11|~5.5.0", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", + "magento/magento-composer-installer": "*" + }, + "type": "magento2-module", + "version": "0.1.0-alpha90", + "extra": { + "map": [ + [ + "*", + "Magento/Authorization" + ] + ] + } +} diff --git a/app/code/Magento/User/data/user_setup/data-install-1.6.0.0.php b/app/code/Magento/Authorization/data/authorization_setup/data-install-1.0.0.0.php similarity index 69% rename from app/code/Magento/User/data/user_setup/data-install-1.6.0.0.php rename to app/code/Magento/Authorization/data/authorization_setup/data-install-1.0.0.0.php index 013d4117f470f..483a6ee18fca6 100644 --- a/app/code/Magento/User/data/user_setup/data-install-1.6.0.0.php +++ b/app/code/Magento/Authorization/data/authorization_setup/data-install-1.0.0.0.php @@ -21,30 +21,22 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -use Magento\User\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\Acl\Role\Group as RoleGroup; +use Magento\Authorization\Model\UserContextInterface; /** * Save administrators group role and rules */ -/** @var \Magento\User\Model\Resource\Setup $this */ +/** @var \Magento\Authorization\Model\Resource\Setup $this */ -$roleCollection = $this->createRoleCollection()->addFieldToFilter( - 'parent_id', - 0 -)->addFieldToFilter( - 'tree_level', - 1 -)->addFieldToFilter( - 'role_type', - RoleGroup::ROLE_TYPE -)->addFieldToFilter( - 'user_id', - 0 -)->addFieldToFilter( - 'role_name', - 'Administrators' -); +$roleCollection = $this->createRoleCollection() + ->addFieldToFilter('parent_id', 0) + ->addFieldToFilter('tree_level', 1) + ->addFieldToFilter('role_type', RoleGroup::ROLE_TYPE) + ->addFieldToFilter('user_id', 0) + ->addFieldToFilter('user_type', UserContextInterface::USER_TYPE_ADMIN) + ->addFieldToFilter('role_name', 'Administrators'); if ($roleCollection->count() == 0) { $admGroupRole = $this->createRole()->setData( @@ -54,6 +46,7 @@ 'sort_order' => 1, 'role_type' => RoleGroup::ROLE_TYPE, 'user_id' => 0, + 'user_type' => UserContextInterface::USER_TYPE_ADMIN, 'role_name' => 'Administrators' ) )->save(); @@ -64,13 +57,9 @@ } } -$rulesCollection = $this->createRulesCollection()->addFieldToFilter( - 'role_id', - $admGroupRole->getId() -)->addFieldToFilter( - 'resource_id', - 'all' -); +$rulesCollection = $this->createRulesCollection() + ->addFieldToFilter('role_id', $admGroupRole->getId()) + ->addFieldToFilter('resource_id', 'all'); if ($rulesCollection->count() == 0) { $this->createRules()->setData( @@ -82,7 +71,7 @@ ) )->save(); } else { - /** @var \Magento\User\Model\Rules $rule */ + /** @var \Magento\Authorization\Model\Rules $rule */ foreach ($rulesCollection as $rule) { $rule->setData('resource_id', 'Magento_Adminhtml::all')->save(); } diff --git a/app/code/Magento/Authorization/etc/di.xml b/app/code/Magento/Authorization/etc/di.xml new file mode 100644 index 0000000000000..afd3f40acd4f9 --- /dev/null +++ b/app/code/Magento/Authorization/etc/di.xml @@ -0,0 +1,47 @@ + + + + + + + Magento\Framework\Acl\RootResource\Proxy + Magento\Framework\Acl\Cache\Proxy + + + + + + Magento\Authorization\Model\Resource\Setup + + + + + + Magento\Authorization\Model\Acl\Loader\Rule + Magento\Authorization\Model\Acl\Loader\Role + + + diff --git a/app/code/Magento/Authz/etc/di.xml b/app/code/Magento/Authorization/etc/module.xml similarity index 80% rename from app/code/Magento/Authz/etc/di.xml rename to app/code/Magento/Authorization/etc/module.xml index 324792fc21e25..4224828dc06f4 100644 --- a/app/code/Magento/Authz/etc/di.xml +++ b/app/code/Magento/Authorization/etc/module.xml @@ -23,7 +23,10 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - - - + + + + + + diff --git a/app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.php b/app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.php new file mode 100644 index 0000000000000..eb6661c9dc29a --- /dev/null +++ b/app/code/Magento/Authorization/sql/authorization_setup/install-1.0.0.0.php @@ -0,0 +1,171 @@ +startSetup(); + +if ($installer->getConnection()->isTableExists($installer->getTable('admin_role'))) { + /** + * Rename existing 'admin_role' table into 'authorization_role' (to avoid forcing Magento re-installation) + * TODO: This conditional logic can be removed some time after pull request is delivered to the mainline + */ + $installer->getConnection()->renameTable( + $installer->getTable('admin_role'), + $installer->getTable('authorization_role') + ); + +} else if (!$installer->getConnection()->isTableExists($installer->getTable('authorization_role'))) { + /** + * Create table 'authorization_role' + */ + $table = $installer->getConnection()->newTable( + $installer->getTable('authorization_role') + )->addColumn( + 'role_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Role ID' + )->addColumn( + 'parent_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Parent Role ID' + )->addColumn( + 'tree_level', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Role Tree Level' + )->addColumn( + 'sort_order', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Role Sort Order' + )->addColumn( + 'role_type', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 1, + array('nullable' => false, 'default' => '0'), + 'Role Type' + )->addColumn( + 'user_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'User ID' + )->addColumn( + 'user_type', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 16, + array('nullable' => true, 'default' => null), + 'User Type' + )->addColumn( + 'role_name', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 50, + array('nullable' => true, 'default' => null), + 'Role Name' + )->addIndex( + $installer->getIdxName('authorization_role', array('parent_id', 'sort_order')), + array('parent_id', 'sort_order') + )->addIndex( + $installer->getIdxName('authorization_role', array('tree_level')), + array('tree_level') + )->setComment( + 'Admin Role Table' + ); + $installer->getConnection()->createTable($table); +} + +if ($installer->getConnection()->isTableExists($installer->getTable('admin_rule'))) { + /** + * Rename existing 'admin_rule' table into 'authorization_rule' (to avoid forcing Magento re-installation) + * TODO: This conditional logic can be removed some time after pull request is delivered to the mainline + */ + $installer->getConnection()->renameTable( + $installer->getTable('admin_rule'), + $installer->getTable('authorization_rule') + ); + +} else if (!$installer->getConnection()->isTableExists($installer->getTable('authorization_rule'))) { + /** + * Create table 'authorization_rule' + */ + $table = $installer->getConnection()->newTable( + $installer->getTable('authorization_rule') + )->addColumn( + 'rule_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Rule ID' + )->addColumn( + 'role_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Role ID' + )->addColumn( + 'resource_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + array('nullable' => true, 'default' => null), + 'Resource ID' + )->addColumn( + 'privileges', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 20, + array('nullable' => true), + 'Privileges' + )->addColumn( + 'permission', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 10, + array(), + 'Permission' + )->addIndex( + $installer->getIdxName('authorization_rule', array('resource_id', 'role_id')), + array('resource_id', 'role_id') + )->addIndex( + $installer->getIdxName('authorization_rule', array('role_id', 'resource_id')), + array('role_id', 'resource_id') + )->addForeignKey( + $installer->getFkName('authorization_rule', 'role_id', 'authorization_role', 'role_id'), + 'role_id', + $installer->getTable('authorization_role'), + 'role_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE + )->setComment( + 'Admin Rule Table' + ); + $installer->getConnection()->createTable($table); +} + +$installer->endSetup(); diff --git a/app/code/Magento/Authorizenet/Helper/Data.php b/app/code/Magento/Authorizenet/Helper/Data.php index 8bcfa32014dec..0398481a245a2 100644 --- a/app/code/Magento/Authorizenet/Helper/Data.php +++ b/app/code/Magento/Authorizenet/Helper/Data.php @@ -197,39 +197,10 @@ public function convertMessagesToMessage($messages) * @param \Magento\Framework\Object $card * @param bool|float $amount * @param bool|string $exception + * @param bool|string $additionalMessage * @return bool|string */ public function getTransactionMessage( - $payment, - $requestType, - $lastTransactionId, - $card, - $amount = false, - $exception = false - ) { - return $this->getExtendedTransactionMessage( - $payment, - $requestType, - $lastTransactionId, - $card, - $amount, - $exception - ); - } - - /** - * Return message for gateway transaction request - * - * @param \Magento\Payment\Model\Info $payment - * @param string $requestType - * @param string $lastTransactionId - * @param \Magento\Framework\Object $card - * @param bool|float $amount - * @param bool|string $exception - * @param bool|string $additionalMessage - * @return bool|mixed - */ - public function getExtendedTransactionMessage( $payment, $requestType, $lastTransactionId, @@ -238,40 +209,27 @@ public function getExtendedTransactionMessage( $exception = false, $additionalMessage = false ) { + $message[] = __('Credit Card: xxxx-%1', $card->getCcLast4()); + if ($amount) { + $message[] = __('amount %1', $this->_formatPrice($payment, $amount)); + } $operation = $this->_getOperation($requestType); - if (!$operation) { return false; - } - - if ($amount) { - $amount = __('amount %1', $this->_formatPrice($payment, $amount)); - } - - if ($exception) { - $result = __('failed'); } else { - $result = __('successful'); + $message[] = $operation; } - - $card = __('Credit Card: xxxx-%1', $card->getCcLast4()); - - $pattern = '%s %s %s - %s.'; - $texts = array($card, $amount, $operation, $result); - + $message[] = ($exception) ? '- ' . __('failed.') : '- ' . __('successful.'); if (!is_null($lastTransactionId)) { - $pattern .= ' %s.'; - $texts[] = __('Authorize.Net Transaction ID %1', $lastTransactionId); + $message[] = __('Authorize.Net Transaction ID %1.', $lastTransactionId); } - if ($additionalMessage) { - $pattern .= ' %s.'; - $texts[] = $additionalMessage; + $message[] = $additionalMessage; } - $pattern .= ' %s'; - $texts[] = $exception; - - return call_user_func_array('__', array_merge(array($pattern), $texts)); + if ($exception) { + $message[] = $exception; + } + return implode(' ', $message); } /** diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet.php b/app/code/Magento/Authorizenet/Model/Authorizenet.php index cf5b2a3bf553d..df8c1202f6eb2 100644 --- a/app/code/Magento/Authorizenet/Model/Authorizenet.php +++ b/app/code/Magento/Authorizenet/Model/Authorizenet.php @@ -1054,14 +1054,14 @@ protected function _voidCardTransaction($payment, $card) 'parent_transaction_id' => $authTransactionId ), array(), - $this->_authorizenetData->getExtendedTransactionMessage( + $this->_authorizenetData->getTransactionMessage( $payment, self::REQUEST_TYPE_VOID, null, $card, false, false, - __('Parent Authorize.Net transaction (ID %1) expired', $realAuthTransactionId) + __('Parent Authorize.Net transaction (ID %1) expired.', $realAuthTransactionId) ) ); } diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index ef24c34cdb2df..9d3f76530f6b2 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -23,6 +23,8 @@ */ namespace Magento\Authorizenet\Model; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; + /** * Authorize.net DirectPost payment method model. */ @@ -90,6 +92,11 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet */ protected $_helper; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Payment\Helper\Data $paymentData @@ -110,6 +117,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet * @param \Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory * @param \Magento\Authorizenet\Model\Directpost\Response $response * @param \Magento\Authorizenet\Helper\HelperInterface $helper + * @param OrderSender $orderSender * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -134,6 +142,7 @@ public function __construct( \Magento\Authorizenet\Model\Directpost\RequestFactory $directRequestFactory, \Magento\Authorizenet\Model\Directpost\Response $response, \Magento\Authorizenet\Helper\HelperInterface $helper, + OrderSender $orderSender, array $data = array() ) { parent::__construct( @@ -158,6 +167,7 @@ public function __construct( $this->_requestFactory = $directRequestFactory; $this->_response = $response; $this->_helper = $helper; + $this->orderSender = $orderSender; } /** @@ -705,7 +715,7 @@ protected function _authOrder(\Magento\Sales\Model\Order $order) try { if (!$response->hasOrderSendConfirmation() || $response->getOrderSendConfirmation()) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } $this->_quoteFactory->create()->load($order->getQuoteId())->setIsActive(false)->save(); diff --git a/app/code/Magento/Authorizenet/composer.json b/app/code/Magento/Authorizenet/composer.json index 83732fee6399d..6b8835ccde63b 100644 --- a/app/code/Magento/Authorizenet/composer.json +++ b/app/code/Magento/Authorizenet/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-authorizenet", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-centinel": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-centinel": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Authz/Model/UserIdentifier.php b/app/code/Magento/Authz/Model/UserIdentifier.php deleted file mode 100644 index 999a7f259c84f..0000000000000 --- a/app/code/Magento/Authz/Model/UserIdentifier.php +++ /dev/null @@ -1,135 +0,0 @@ -getUserType(); - $userId = isset($userId) ? $userId : $userLocator->getUserId(); - if ($userType == self::USER_TYPE_GUEST && $userId) { - throw new \LogicException('Guest user must not have user ID set.'); - } - $this->_setUserId($userId); - $this->_setUserType($userType); - } - - /** - * Get user ID. Null is possible when user type is 'guest'. - * - * @return int - */ - public function getUserId() - { - return $this->_userId; - } - - /** - * Retrieve user type (admin, customer, guest, web API integration). - * - * @return string - */ - public function getUserType() - { - return $this->_userType; - } - - /** - * Set user ID. - * - * @param int $userId - * @return $this - * @throws \LogicException - */ - protected function _setUserId($userId) - { - $userId = is_numeric($userId) ? (int)$userId : $userId; - if (!is_integer($userId) || $userId < 0) { - throw new \LogicException("Invalid user ID: '{$userId}'."); - } - $this->_userId = $userId; - return $this; - } - - /** - * Set user type. - * - * @param string $userType - * @return $this - * @throws \LogicException - */ - protected function _setUserType($userType) - { - $availableTypes = array( - self::USER_TYPE_GUEST, - self::USER_TYPE_CUSTOMER, - self::USER_TYPE_ADMIN, - self::USER_TYPE_INTEGRATION - ); - if (!in_array($userType, $availableTypes)) { - throw new \LogicException( - "Invalid user type: '{$userType}'. Allowed types: " . implode(", ", $availableTypes) - ); - } - $this->_userType = $userType; - return $this; - } -} diff --git a/app/code/Magento/Authz/Service/AuthorizationV1.php b/app/code/Magento/Authz/Service/AuthorizationV1.php deleted file mode 100644 index 216c3c56c8aca..0000000000000 --- a/app/code/Magento/Authz/Service/AuthorizationV1.php +++ /dev/null @@ -1,377 +0,0 @@ -_aclBuilder = $aclBuilder; - $this->_userIdentifier = $userIdentifier; - $this->_roleFactory = $roleFactory; - $this->_rulesFactory = $rulesFactory; - $this->_rulesCollectionFactory = $rulesCollectionFactory; - $this->_roleCollectionFactory = $roleCollectionFactory; - $this->_logger = $logger; - $this->_rootAclResource = $rootAclResource; - } - - /** - * {@inheritdoc} - */ - public function isAllowed($resources, UserIdentifier $userIdentifier = null) - { - $resources = is_array($resources) ? $resources : [$resources]; - $userIdentifier = $userIdentifier ? $userIdentifier : $this->_userIdentifier; - if ($this->_isAnonymousOrSelfAllowed($resources, $userIdentifier)) { - return true; - } - return $this->_isUserWithRoleAllowed($resources, $userIdentifier); - } - - /** - * {@inheritdoc} - */ - public function grantPermissions(UserIdentifier $userIdentifier, array $resources) - { - try { - $role = $this->_getUserRole($userIdentifier); - if (!$role) { - $role = $this->_createRole($userIdentifier); - } - $this->_associateResourcesWithRole($role, $resources); - } catch (\Exception $e) { - $this->_logger->logException($e); - throw new LocalizedException('Error happened while granting permissions. Check exception log for details.'); - } - } - - /** - * {@inheritdoc} - */ - public function grantAllPermissions(UserIdentifier $userIdentifier) - { - $this->grantPermissions($userIdentifier, array($this->_rootAclResource->getId())); - } - - /** - * {@inheritdoc} - */ - public function getAllowedResources(UserIdentifier $userIdentifier) - { - if ($userIdentifier->getUserType() == UserIdentifier::USER_TYPE_GUEST) { - return [self::PERMISSION_ANONYMOUS]; - } elseif ($userIdentifier->getUserType() == UserIdentifier::USER_TYPE_CUSTOMER) { - return [self::PERMISSION_SELF]; - } - $allowedResources = []; - try { - $role = $this->_getUserRole($userIdentifier); - if (!$role) { - throw new AuthorizationException('The role associated with the specified user cannot be found.'); - } - $rulesCollection = $this->_rulesCollectionFactory->create(); - $rulesCollection->getByRoles($role->getId())->load(); - $acl = $this->_aclBuilder->getAcl(); - /** @var \Magento\User\Model\Rules $ruleItem */ - foreach ($rulesCollection->getItems() as $ruleItem) { - $resourceId = $ruleItem->getResourceId(); - if ($acl->has($resourceId) && $acl->isAllowed($role->getId(), $resourceId)) { - $allowedResources[] = $resourceId; - } - } - } catch (AuthorizationException $e) { - throw $e; - } catch (\Exception $e) { - $this->_logger->logException($e); - throw new LocalizedException( - 'Error happened while getting a list of allowed resources. Check exception log for details.' - ); - } - return $allowedResources; - } - - /** - * {@inheritdoc} - */ - public function removePermissions(UserIdentifier $userIdentifier) - { - try { - $this->_deleteRole($userIdentifier); - } catch (NoSuchEntityException $e) { - throw $e; - } catch (\Exception $e) { - $this->_logger->logException($e); - throw new LocalizedException( - 'Error happened while deleting role and permissions. Check exception log for details.' - ); - } - } - - /** - * Create new ACL role. - * - * @param UserIdentifier $userIdentifier - * @return Role - * @throws NoSuchEntityException - * @throws \LogicException - */ - protected function _createRole($userIdentifier) - { - $userType = $userIdentifier->getUserType(); - if (!$this->_canRoleBeCreatedForUserType($userType)) { - throw new \LogicException("The role with user type '{$userType}' cannot be created"); - } - $userId = $userIdentifier->getUserId(); - switch ($userType) { - case UserIdentifier::USER_TYPE_INTEGRATION: - $roleName = $userType . $userId; - $roleType = \Magento\User\Model\Acl\Role\User::ROLE_TYPE; - $parentId = 0; - $userId = $userIdentifier->getUserId(); - break; - default: - throw NoSuchEntityException::singleField('userType', $userType); - } - $role = $this->_roleFactory->create(); - $role->setRoleName($roleName) - ->setUserType($userType) - ->setUserId($userId) - ->setRoleType($roleType) - ->setParentId($parentId) - ->save(); - return $role; - } - - /** - * Remove an ACL role. This deletes the cascading permissions - * - * @param UserIdentifier $userIdentifier - * @return Role - * @throws NoSuchEntityException - * @throws \LogicException - */ - protected function _deleteRole($userIdentifier) - { - $userType = $userIdentifier->getUserType(); - if (!$this->_canRoleBeCreatedForUserType($userType)) { - throw new \LogicException("The role with user type '{$userType}' cannot be created or deleted."); - } - $userId = $userIdentifier->getUserId(); - switch ($userType) { - case UserIdentifier::USER_TYPE_INTEGRATION: - $roleName = $userType . $userId; - break; - default: - throw NoSuchEntityException::singleField('userType', $userType); - } - $role = $this->_roleFactory->create()->load($roleName, 'role_name'); - return $role->delete(); - } - - /** - * Identify user role from user identifier. - * - * @param UserIdentifier $userIdentifier - * @return Role|false Return false in case when no role associated with provided user was found. - * @throws \LogicException - */ - protected function _getUserRole($userIdentifier) - { - if (!$this->_canRoleBeCreatedForUserType($userIdentifier)) { - throw new \LogicException( - "The role with user type '{$userIdentifier->getUserType()}' does not exist and cannot be created" - ); - } - $roleCollection = $this->_roleCollectionFactory->create(); - $userType = $userIdentifier->getUserType(); - /** @var Role $role */ - $userId = $userIdentifier->getUserId(); - $role = $roleCollection->setUserFilter($userId, $userType)->getFirstItem(); - return $role->getId() ? $role : false; - } - - /** - * Associate resources with the specified role. All resources previously assigned to the role will be unassigned. - * - * @param Role $role - * @param string[] $resources - * @return void - * @throws \LogicException - */ - protected function _associateResourcesWithRole($role, array $resources) - { - /** @var \Magento\User\Model\Rules $rules */ - $rules = $this->_rulesFactory->create(); - $rules->setRoleId($role->getId())->setResources($resources)->saveRel(); - } - - /** - * Check if there role can be associated with user having provided user type. - * - * Roles cannot be created for guests and customers. - * - * @param string $userType - * @return bool - */ - protected function _canRoleBeCreatedForUserType($userType) - { - return ($userType != UserIdentifier::USER_TYPE_CUSTOMER) && ($userType != UserIdentifier::USER_TYPE_GUEST); - } - - /** - * Check if the user has permission to access the requested resources. - * - * @param string[] $resources - * @param UserIdentifier $userIdentifier - * @return bool - */ - protected function _isAnonymousOrSelfAllowed($resources, UserIdentifier $userIdentifier) - { - if (count($resources) == 1) { - $resource = reset($resources); - $isAnonymousAccess = ($resource == self::PERMISSION_ANONYMOUS); - $isSelfAccess = ($userIdentifier->getUserType() == UserIdentifier::USER_TYPE_CUSTOMER) - && ($resource == self::PERMISSION_SELF); - if ($isAnonymousAccess || $isSelfAccess) { - return true; - } - } - return false; - } - - /** - * Check if user who has role is allowed to access requested resources. - * - * @param string[] $resources - * @param UserIdentifier $userIdentifier - * @return bool - */ - protected function _isUserWithRoleAllowed($resources, UserIdentifier $userIdentifier) - { - try { - $role = $this->_getUserRole($userIdentifier); - if (!$role) { - throw NoSuchEntityException::doubleField( - 'userId', - $userIdentifier->getUserId(), - 'userType', - $userIdentifier->getUserType() - ); - } - foreach ($resources as $resource) { - if (!$this->_aclBuilder->getAcl()->isAllowed($role->getId(), $resource)) { - return false; - } - } - return true; - } catch (\Exception $e) { - $this->_logger->logException($e); - return false; - } - } -} diff --git a/app/code/Magento/Authz/Service/AuthorizationV1Interface.php b/app/code/Magento/Authz/Service/AuthorizationV1Interface.php deleted file mode 100644 index 9fbd2a5cc8662..0000000000000 --- a/app/code/Magento/Authz/Service/AuthorizationV1Interface.php +++ /dev/null @@ -1,88 +0,0 @@ -getUser()) { - $this->regenerateId(false); + $this->regenerateId(); if ($this->_backendUrl->useSecretKey()) { $this->_backendUrl->renewSecretUrls(); diff --git a/app/code/Magento/Backend/Model/Observer.php b/app/code/Magento/Backend/Model/Observer.php index a95b840671a2a..fced5d795f618 100644 --- a/app/code/Magento/Backend/Model/Observer.php +++ b/app/code/Magento/Backend/Model/Observer.php @@ -85,27 +85,4 @@ public function clearCacheConfigurationFilesAccessLevelVerification() { return $this; } - - /** - * Set url class name for store 'admin' - * - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function setUrlClassName(\Magento\Framework\Event\Observer $observer) - { - /** @var $storeCollection \Magento\Store\Model\Resource\Store\Collection */ - $storeCollection = $observer->getEvent()->getStoreCollection(); - /** @var $store \Magento\Store\Model\Store */ - foreach ($storeCollection as $store) { - if ($store->getId() == 0) { - $store->setUrlClassName('Magento\Backend\Model\UrlInterface'); - break; - } - } - $this->cache->remove( - \Magento\AdminNotification\Model\System\Message\Security::VERIFICATION_RESULT_CACHE_KEY - ); - return $this; - } } diff --git a/app/code/Magento/Backend/composer.json b/app/code/Magento/Backend/composer.json index 22d9a7215c106..2ff611ae678f2 100644 --- a/app/code/Magento/Backend/composer.json +++ b/app/code/Magento/Backend/composer.json @@ -2,34 +2,33 @@ "name": "magento/module-backend", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/module-sendfriend": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-reports": "0.1.0-alpha89", - "magento/module-catalog-search": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-user": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backup": "0.1.0-alpha89", - "magento/module-email": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-url-rewrite": "0.1.0-alpha89", - "magento/module-translation": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/module-sendfriend": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-reports": "0.1.0-alpha90", + "magento/module-catalog-search": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-user": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backup": "0.1.0-alpha90", + "magento/module-email": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-url-rewrite": "0.1.0-alpha90", + "magento/module-translation": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Backend/etc/adminhtml/acl.xml b/app/code/Magento/Backend/etc/acl.xml similarity index 98% rename from app/code/Magento/Backend/etc/adminhtml/acl.xml rename to app/code/Magento/Backend/etc/acl.xml index 45f9521fd7a37..3393e749dbba1 100644 --- a/app/code/Magento/Backend/etc/adminhtml/acl.xml +++ b/app/code/Magento/Backend/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Backend/etc/module.xml b/app/code/Magento/Backend/etc/module.xml index 101b83e07768a..1b15e3702c493 100644 --- a/app/code/Magento/Backend/etc/module.xml +++ b/app/code/Magento/Backend/etc/module.xml @@ -33,7 +33,6 @@ - diff --git a/app/code/Magento/Backup/composer.json b/app/code/Magento/Backup/composer.json index 8af68b4da0463..b14d724302611 100644 --- a/app/code/Magento/Backup/composer.json +++ b/app/code/Magento/Backup/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-backup", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Backup/etc/adminhtml/acl.xml b/app/code/Magento/Backup/etc/acl.xml similarity index 94% rename from app/code/Magento/Backup/etc/adminhtml/acl.xml rename to app/code/Magento/Backup/etc/acl.xml index eb2139dc270aa..1abed0fc99ef5 100644 --- a/app/code/Magento/Backup/etc/adminhtml/acl.xml +++ b/app/code/Magento/Backup/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php b/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php index 1a70af60d6375..678da2ceea6a0 100644 --- a/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php +++ b/app/code/Magento/Bundle/Model/Plugin/PriceBackend.php @@ -33,21 +33,22 @@ class PriceBackend /** * @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject * @param \Closure $proceed - * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Catalog\Model\Product|\Magento\Framework\Object $object * @return bool * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundValidate( \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject, \Closure $proceed, - \Magento\Catalog\Model\Product $product + $object ) { - if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE - && $product->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC + if ($object instanceof \Magento\Catalog\Model\Product + && $object->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE + && $object->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC ) { return true; } else { - return $proceed($product); + return $proceed($object); } } } diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php new file mode 100644 index 0000000000000..dfb605d843b29 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option.php @@ -0,0 +1,104 @@ +_get(self::ID); + } + + /** + * Get option title + * + * @return string|null + */ + public function getTitle() + { + return $this->_get(self::TITLE); + } + + /** + * Get is required option + * + * @return bool|null + */ + public function isRequired() + { + return $this->_get(self::REQUIRED); + } + + /** + * Get input type + * + * @return string|null + */ + public function getType() + { + return $this->_get(self::TYPE); + } + + /** + * Get option position + * + * @return int|null + */ + public function getPosition() + { + return $this->_get(self::POSITION); + } + + /** + * Get product sku + * + * @return string|null + */ + public function getSku() + { + return $this->_get(self::SKU); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.php new file mode 100644 index 0000000000000..596a44f534326 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/Type.php @@ -0,0 +1,56 @@ +_get(self::LABEL); + } + + /** + * Get type code + * + * @return string + */ + public function getCode() + { + return $this->_get(self::CODE); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php new file mode 100644 index 0000000000000..04af6800a3106 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeBuilder.php @@ -0,0 +1,54 @@ +_set(Type::LABEL, $value); + } + + /** + * Set type code + * + * @param int $value + * @return $this + */ + public function setCode($value) + { + return $this->_set(Type::CODE, $value); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php new file mode 100644 index 0000000000000..b64fecdbd27fc --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/Option/TypeConverter.php @@ -0,0 +1,53 @@ +builder = $builder; + } + + /** + * @param array $option + * @return Type + */ + public function createDataFromModel(array $option) + { + $this->builder->populateWithArray($option) + ->setCode($option['value']); + return $this->builder->create(); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php new file mode 100644 index 0000000000000..398f8f1a995b0 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionBuilder.php @@ -0,0 +1,98 @@ +_set(Option::ID, $value); + } + + /** + * Set option title + * + * @param string $value + * @return $this + */ + public function setTitle($value) + { + return $this->_set(Option::TITLE, $value); + } + + /** + * Set is required option + * + * @param bool $value + * @return $this + */ + public function setRequired($value) + { + return $this->_set(Option::REQUIRED, $value); + } + + /** + * Set input type + * + * @param string $value + * @return $this + */ + public function setType($value) + { + return $this->_set(Option::TYPE, $value); + } + + /** + * Set option position + * + * @param int $value + * @return $this + */ + public function setPosition($value) + { + return $this->_set(Option::POSITION, $value); + } + + /** + * Set product sku + * + * @param string $value + * @return $this + */ + public function setSku($value) + { + return $this->_set(Option::SKU, $value); + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php new file mode 100644 index 0000000000000..b5de09c3576a2 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Data/Product/OptionConverter.php @@ -0,0 +1,99 @@ +builder = $builder; + $this->optionFactory = $optionFactory; + } + + /** + * @param OptionModel $option + * @param Product $product + * @return Option + */ + public function createDataFromModel(OptionModel $option, Product $product) + { + $this->builder->populateWithArray($option->getData()) + ->setId($option->getId()) + ->setTitle(is_null($option->getTitle()) ? $option->getDefaultTitle() : $option->getTitle()) + ->setSku($product->getSku()); + return $this->builder->create(); + } + + /** + * @param Option $option + * @param Product $product + * @return OptionModel + */ + public function createModelFromData(Option $option, Product $product) + { + $optionModel = $this->optionFactory->create(); + $optionModel->addData($option->__toArray()) + ->unsetData($optionModel->getIdFieldName()) + ->setParentId($product->getId()) + ->setDefaultTitle($option->getTitle()); + return $optionModel; + } + + /** + * @param Option $option + * @param OptionModel $optionModel + * @return OptionModel + */ + public function getModelFromData(Option $option, OptionModel $optionModel) + { + $newOptionModel = $this->optionFactory->create(); + $newOptionModel->setData($optionModel->getData()) + ->addData($option->__toArray()) + ->setId($optionModel->getId()) + ->setDefaultTitle(is_null($option->getTitle()) ? $optionModel->getTitle() : $option->getTitle()); + return $newOptionModel; + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php index 1218d7fcfa70a..2964310bc693c 100644 --- a/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php +++ b/app/code/Magento/Bundle/Service/V1/Product/Link/WriteService.php @@ -169,7 +169,7 @@ public function removeChild($productSku, $optionId, $childSku) $removeSelectionIds = array(); foreach ($this->getOptions($product) as $option) { foreach ($option->getSelections() as $selection) { - if (($selection->getSku() == $childSku) && ($selection->getOptionId() == $optionId)) { + if ((strcasecmp($selection->getSku(), $childSku) == 0) && ($selection->getOptionId() == $optionId)) { $removeSelectionIds[] = $selection->getSelectionId(); continue; } diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php new file mode 100644 index 0000000000000..714401d72e441 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadService.php @@ -0,0 +1,113 @@ +optionConverter = $optionConverter; + $this->productRepository = $productRepository; + $this->type = $type; + } + + /** + * {@inheritdoc} + */ + public function get($productSku, $optionId) + { + $product = $this->getProduct($productSku); + $optionCollection = $this->type->getOptionsCollection($product); + $optionCollection->setIdFilter($optionId); + + /** @var \Magento\Bundle\Model\Option $option */ + $option = $optionCollection->getFirstItem(); + if (!$option->getId()) { + throw new NoSuchEntityException('Requested option doesn\'t exist'); + } + return $this->optionConverter->createDataFromModel($option, $product); + } + + /** + * {@inheritdoc} + */ + public function getList($productSku) + { + $product = $this->getProduct($productSku); + $optionCollection = $this->type->getOptionsCollection($product); + + /** @var \Magento\Bundle\Service\V1\Data\Product\Option[] $optionDtoList */ + $optionDtoList = []; + /** @var \Magento\Bundle\Model\Option $option */ + foreach ($optionCollection as $option) { + $optionDtoList[] = $this->optionConverter->createDataFromModel($option, $product); + } + return $optionDtoList; + } + + /** + * @param string $productSku + * @return Product + * @throws Exception + */ + private function getProduct($productSku) + { + $product = $this->productRepository->get($productSku); + + if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { + throw new Exception('Only implemented for bundle product', Exception::HTTP_FORBIDDEN); + } + + return $product; + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.php new file mode 100644 index 0000000000000..14abab5ec34a5 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/ReadServiceInterface.php @@ -0,0 +1,48 @@ +type = $type; + $this->typeConverter = $typeConverter; + } + + /** + * {@inheritdoc} + */ + public function getTypes() + { + $optionList = $this->type->toOptionArray(); + + /** @var Type[] $typeDtoList */ + $typeDtoList = []; + foreach ($optionList as $option) { + $typeDtoList[] = $this->typeConverter->createDataFromModel($option); + } + return $typeDtoList; + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.php new file mode 100644 index 0000000000000..90fbc02a75e15 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/Type/ReadServiceInterface.php @@ -0,0 +1,34 @@ +productRepository = $productRepository; + $this->type = $type; + $this->optionConverter = $optionConverter; + $this->storeManager = $storeManager; + } + + /** + * {@inheritdoc} + */ + public function remove($productSku, $optionId) + { + $product = $this->getProduct($productSku); + $optionCollection = $this->type->getOptionsCollection($product); + $optionCollection->setIdFilter($optionId); + + /** @var \Magento\Bundle\Model\Option $removeOption */ + $removeOption = $optionCollection->getFirstItem(); + if (!$removeOption->getId()) { + throw new NoSuchEntityException('Requested option doesn\'t exist'); + } + $removeOption->delete(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function add($productSku, Option $option) + { + $product = $this->getProduct($productSku); + $optionModel = $this->optionConverter->createModelFromData($option, $product); + $optionModel->setStoreId($this->storeManager->getStore()->getId()); + + try { + $optionModel->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not save option', [], $e); + } + + return $optionModel->getId(); + } + + /** + * {@inheritdoc} + */ + public function update($productSku, $optionId, \Magento\Bundle\Service\V1\Data\Product\Option $option) + { + $product = $this->getProduct($productSku); + $optionCollection = $this->type->getOptionsCollection($product); + $optionCollection->setIdFilter($optionId); + + /** @var \Magento\Bundle\Model\Option $optionModel */ + $optionModel = $optionCollection->getFirstItem(); + $updateOption = $this->optionConverter->getModelFromData($option, $optionModel); + + if (!$updateOption->getId()) { + throw new NoSuchEntityException('Requested option doesn\'t exist'); + } + $updateOption->setStoreId($this->storeManager->getStore()->getId()); + + try { + $updateOption->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not save option', [], $e); + } + + return true; + } + + /** + * @param string $productSku + * @return Product + * @throws Exception + */ + private function getProduct($productSku) + { + $product = $this->productRepository->get($productSku); + + if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { + throw new Exception( + 'Product with specified sku: "%1" is not a bundle product', + Exception::HTTP_FORBIDDEN, + Exception::HTTP_FORBIDDEN, + [ + $product->getSku() + ] + ); + } + + return $product; + } +} diff --git a/app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.php b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.php new file mode 100644 index 0000000000000..a5992eb2f7af9 --- /dev/null +++ b/app/code/Magento/Bundle/Service/V1/Product/Option/WriteServiceInterface.php @@ -0,0 +1,61 @@ + + + + diff --git a/app/code/Magento/Bundle/etc/webapi.xml b/app/code/Magento/Bundle/etc/webapi.xml index 757c74cee5b13..8e9ea1b5287af 100644 --- a/app/code/Magento/Bundle/etc/webapi.xml +++ b/app/code/Magento/Bundle/etc/webapi.xml @@ -43,4 +43,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml index c66e9c8e7070c..f59849e66d53f 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml @@ -42,19 +42,19 @@ getOrderItem()->getParentItem()): ?> getSelectionAttributes($_item) ?> - +
- +getParentItem()): ?> data-th=""> getOrderItem()->getParentItem()): ?> escapeHtml($_item->getName()) ?> - getValueHtml($_item) ?> + getValueHtml($_item) ?> escapeHtml($_item->getSku()) ?> diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/invoice/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/invoice/items/renderer.phtml index 2515d5a29c3a2..20b29c9f31724 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/invoice/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/invoice/items/renderer.phtml @@ -41,19 +41,19 @@ getOrderItem()->getParentItem()): ?> getSelectionAttributes($_item) ?> - +
- + getOrderItem()->getParentItem()): ?> data-th=""> getOrderItem()->getParentItem()): ?> escapeHtml($_item->getName()) ?> - getValueHtml($_item) ?> + getValueHtml($_item) ?> escapeHtml($_item->getSku()) ?> diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml index 1581213677eaf..b1908e1964b73 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml @@ -42,19 +42,19 @@ getParentItem()): ?> getSelectionAttributes($_item) ?> - getLastRow()) echo 'class="last"'; ?>> -
+ + - +getParentItem()): ?> data-th=""> getParentItem()): ?> escapeHtml($_item->getName()) ?> - getValueHtml($_item)?> + getValueHtml($_item)?> prepareSku($_item->getSku()) ?> @@ -295,7 +295,7 @@ - + getItemOptions()): ?>
diff --git a/app/code/Magento/Bundle/view/frontend/templates/sales/order/shipment/items/renderer.phtml b/app/code/Magento/Bundle/view/frontend/templates/sales/order/shipment/items/renderer.phtml index d47b684a7d80d..5e3fc45b43d7e 100644 --- a/app/code/Magento/Bundle/view/frontend/templates/sales/order/shipment/items/renderer.phtml +++ b/app/code/Magento/Bundle/view/frontend/templates/sales/order/shipment/items/renderer.phtml @@ -41,19 +41,19 @@ getParentItem()): ?> getSelectionAttributes($_item) ?> - +
- + getParentItem()): ?> data-th=""> getParentItem()): ?> escapeHtml($_item->getName()) ?> - getValueHtml($_item) ?> + getValueHtml($_item) ?> escapeHtml($_item->getSku()) ?> diff --git a/app/code/Magento/Captcha/composer.json b/app/code/Magento/Captcha/composer.json index 958b9216861f4..c00bf2b08251e 100644 --- a/app/code/Magento/Captcha/composer.json +++ b/app/code/Magento/Captcha/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-captcha", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Captcha/view/frontend/templates/default.phtml b/app/code/Magento/Captcha/view/frontend/templates/default.phtml index ef872a1f59271..f382e4f6eb353 100644 --- a/app/code/Magento/Captcha/view/frontend/templates/default.phtml +++ b/app/code/Magento/Captcha/view/frontend/templates/default.phtml @@ -36,13 +36,13 @@ data-mage-init='{"captcha":{"url": "getRefreshUrl()?>", "type": "getFormId() ?>"}}'>
- <?php echo __('Please type the letters below')?> isCaseSensitive()) :?>
Attention: Captcha is case sensitive.') ?>
+
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php index 5d17b451a4a87..d4a5e5e111d46 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php @@ -334,7 +334,8 @@ protected function _prepareColumns() 'editable' => !$this->isReadonly(), 'edit_only' => !$this->getProduct()->getId(), 'header_css_class' => 'col-position', - 'column_css_class' => 'col-position' + 'column_css_class' => 'col-position', + 'filter_condition_callback' => array($this, 'filterProductPosition') ) ); @@ -385,4 +386,17 @@ public function getSelectedCrossSellProducts() } return $products; } + + /** + * Apply `position` filter to cross-sell grid. + * + * @param \Magento\Catalog\Model\Resource\Product\Link\Product\Collection $collection $collection + * @param \Magento\Backend\Block\Widget\Grid\Column\Extended $column + * @return $this + */ + public function filterProductPosition($collection, $column) + { + $collection->addLinkAttributeToFilter($column->getIndex(), $column->getFilter()->getCondition()); + return $this; + } } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php index 738fe7b50d242..323ead3a5cfda 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Option.php @@ -340,7 +340,7 @@ public function getOptionValues() ) : '', 'price_type' => $showPrice ? $_value->getPriceType() : 0, 'sku' => $this->escapeHtml($_value->getSku()), - 'sort_order' => $_value->getSortOrder() + 'sort_order' => $_value->getSortOrder(), ); if ($this->getProduct()->getStoreId() != '0') { @@ -358,7 +358,8 @@ public function getOptionValues() $_value->getOptionId(), 'price', is_null($_value->getstorePrice()), - $_value->getOptionTypeId() + $_value->getOptionTypeId(), + ['$(this).up(1).previous()'] ); $value['optionValues'][$i]['scopePriceDisabled'] = is_null( $_value->getStorePrice() @@ -404,9 +405,10 @@ public function getOptionValues() * @param string $name * @param boolean $checked * @param string $select_id + * @param array $containers * @return string */ - public function getCheckboxScopeHtml($id, $name, $checked = true, $select_id = '-1') + public function getCheckboxScopeHtml($id, $name, $checked = true, $select_id = '-1', array $containers = []) { $checkedHtml = ''; if ($checked) { @@ -418,14 +420,20 @@ public function getCheckboxScopeHtml($id, $name, $checked = true, $select_id = ' $selectNameHtml = '[values][' . $select_id . ']'; $selectIdHtml = 'select_' . $select_id . '_'; } + $containers[] = '$(this).up(1)'; + $containers = implode(',', $containers); + $localId = $this->getFieldId() . '_' . $id . '_' . $selectIdHtml . $name . '_use_default'; + $localName = "options_use_default[" . $id . "]" . $selectNameHtml . "[" . $name . "]"; $useDefault = - '
' . '
'; + '
' + . '' + . '
'; return $useDefault; } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php index 5fc2bd2a1460b..e55b1ef0ec37d 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Options/Type/Select.php @@ -94,9 +94,12 @@ public function getDeleteButtonHtml() } /** + * Return select input for price type + * + * @param string $extraParams * @return string */ - public function getPriceTypeSelectHtml() + public function getPriceTypeSelectHtml($extraParams = '') { $this->getChildBlock( 'option_price_type' @@ -105,7 +108,7 @@ public function getPriceTypeSelectHtml() 'product_option_${id}_select_${select_id}_price_type' )->setName( 'product[options][${id}][values][${select_id}][price_type]' - ); + )->setExtraParams($extraParams); return parent::getPriceTypeSelectHtml(); } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php index b17bdfcbb78c3..746bb97b50001 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php @@ -325,7 +325,8 @@ protected function _prepareColumns() 'editable' => !$this->getProduct()->getUpsellReadonly(), 'edit_only' => !$this->getProduct()->getId(), 'header_css_class' => 'col-position', - 'column_css_class' => 'col-position' + 'column_css_class' => 'col-position', + 'filter_condition_callback' => array($this, 'filterProductPosition') ) ); @@ -376,4 +377,17 @@ public function getSelectedUpsellProducts() } return $products; } + + /** + * Apply `position` filter to cross-sell grid. + * + * @param \Magento\Catalog\Model\Resource\Product\Link\Product\Collection $collection + * @param \Magento\Backend\Block\Widget\Grid\Column\Extended $column + * @return $this + */ + public function filterProductPosition($collection, $column) + { + $collection->addLinkAttributeToFilter($column->getIndex(), $column->getFilter()->getCondition()); + return $this; + } } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index c8d62fa9e671e..81a22bbbdd45a 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -122,6 +122,18 @@ protected function _construct() $this->setDestElementId('product-edit-form-tabs'); } + /** + * @param int $attributeSetId + * @return \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection + */ + public function getGroupCollection($attributeSetId) + { + return $this->_collectionFactory->create() + ->setAttributeSetFilter($attributeSetId) + ->setSortOrder() + ->load(); + } + /** * @return $this */ @@ -134,16 +146,13 @@ protected function _prepareLayout() } if ($setId) { - $groupCollection = $this->_collectionFactory->create()->setAttributeSetFilter( - $setId - )->setSortOrder()->load(); - $tabAttributesBlock = $this->getLayout()->createBlock( $this->getAttributeTabBlock(), $this->getNameInLayout() . '_attributes_tab' ); $advancedGroups = array(); - foreach ($groupCollection as $group) { + + foreach ($this->getGroupCollection($setId) as $group) { /** @var $group \Magento\Eav\Model\Entity\Attribute\Group*/ $attributes = $product->getAttributes($group->getId(), true); diff --git a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php index 0e5cc16085e42..d1a2a44fcf66e 100644 --- a/app/code/Magento/Catalog/Block/Product/AbstractProduct.php +++ b/app/code/Magento/Catalog/Block/Product/AbstractProduct.php @@ -244,36 +244,6 @@ public function getMinimalQty($product) return $minSaleQty > 0 ? $minSaleQty : null; } - /** - * Returns product price block html - * - * @param \Magento\Catalog\Model\Product $product - * @param boolean $displayMinimalPrice - * @param string $idSuffix - * @return string - * @deprecated - */ - public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '') - { - $typeId = $product->getTypeId(); - if ($this->_catalogData->canApplyMsrp($product)) { - $realPriceHtml = $this->_preparePriceRenderer($typeId) - ->setProduct($product) - ->setDisplayMinimalPrice($displayMinimalPrice) - ->setIdSuffix($idSuffix) - ->toHtml(); - $product->setAddToCartUrl($this->getAddToCartUrl($product)); - $product->setRealPriceHtml($realPriceHtml); - $typeId = $this->_mapRenderer; - } - - return $this->_preparePriceRenderer($typeId) - ->setProduct($product) - ->setDisplayMinimalPrice($displayMinimalPrice) - ->setIdSuffix($idSuffix) - ->toHtml(); - } - /** * Get product reviews summary * diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php index e16c7a36c3bd5..c6ef67d194790 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php @@ -139,7 +139,12 @@ public function initialize(\Magento\Catalog\Model\Product $product) * Initialize product options */ if (isset($productData['options']) && !$product->getOptionsReadonly()) { - $product->setProductOptions($productData['options']); + // mark custom options that should to fall back to default value + $options = $this->mergeProductOptions( + $productData['options'], + $this->request->getPost('options_use_default') + ); + $product->setProductOptions($options); } $product->setCanSaveCustomOptions( @@ -148,4 +153,30 @@ public function initialize(\Magento\Catalog\Model\Product $product) return $product; } + + /** + * Merge product and default options for product + * + * @param array $productOptions product options + * @param array $overwriteOptions default value options + * @return array + */ + public function mergeProductOptions($productOptions, $overwriteOptions) + { + if (!is_array($productOptions)) { + $productOptions = []; + } + if (is_array($overwriteOptions)) { + $options = array_replace_recursive($productOptions, $overwriteOptions); + array_walk_recursive($options, function (&$item) { + if ($item === "") { + $item = null; + } + }); + } else { + $options = $productOptions; + } + + return $options; + } } diff --git a/app/code/Magento/Catalog/Model/Product/Link.php b/app/code/Magento/Catalog/Model/Product/Link.php index 447b1712261d6..40955dc3b44b0 100644 --- a/app/code/Magento/Catalog/Model/Product/Link.php +++ b/app/code/Magento/Catalog/Model/Product/Link.php @@ -51,7 +51,7 @@ class Link extends \Magento\Framework\Model\AbstractModel /** * @var mixed */ - protected $_attributeCollection = null; + protected $_attributes = null; /** * Product collection factory @@ -169,7 +169,11 @@ public function getAttributes($type = null) if (is_null($type)) { $type = $this->getLinkTypeId(); } - return $this->_getResource()->getAttributesByType($type); + if (!isset($this->_attributes[$type])) { + $this->_attributes[$type] = $this->_getResource()->getAttributesByType($type); + } + + return $this->_attributes[$type]; } /** diff --git a/app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php b/app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php index 6433e327fcb86..72067a2e19356 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Validator/DefaultValidator.php @@ -102,7 +102,33 @@ public function isValid($value) */ protected function validateOptionRequiredFields(Option $option) { - return !$this->isEmpty($option->getTitle()) && !$this->isEmpty($option->getType()); + $storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID; + $product = $option->getProduct(); + if ($product) { + $storeId = $product->getStoreId(); + } + $title = $option->getTitle(); + return $this->isValidOptionTitle($title, $storeId) && !$this->isEmpty($option->getType()); + } + + /** + * Validate option title + * + * @param string $title + * @param int $storeId + * @return bool + */ + protected function isValidOptionTitle($title, $storeId) + { + // we should be able to set null title for not default store (used for deletion from store view) + if ($storeId > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $title === null) { + return true; + } + if ($this->isEmpty($title)) { + return false; + } + + return true; } /** diff --git a/app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php b/app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php index 37a8dfc9ad0b8..4ee412006c0a7 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Validator/Select.php @@ -62,14 +62,41 @@ protected function validateOptionValue(Option $option) return false; } + $storeId = \Magento\Store\Model\Store::DEFAULT_STORE_ID; + if ($option->getProduct()) { + $storeId = $option->getProduct()->getStoreId(); + } foreach ($option->getData('values') as $value) { - $type = isset($value['price_type']) ? $value['price_type'] : ''; - $price = isset($value['price']) ? $value['price'] : 0; - $title = isset($value['title']) ? $value['title'] : ''; - if (!$this->isInRange($type, $this->priceTypes) || $this->isNegative($price) || $this->isEmpty($title)) { + $type = isset($value['price_type']) ? $value['price_type'] : null; + $price = isset($value['price']) ? $value['price'] : null; + $title = isset($value['title']) ? $value['title'] : null; + if (!$this->isValidOptionPrice($type, $price, $storeId) + || !$this->isValidOptionTitle($title, $storeId) + ) { return false; } } return true; } + + /** + * Validate option price + * + * @param string $priceType + * @param int $price + * @param int $storeId + * @return bool + */ + protected function isValidOptionPrice($priceType, $price, $storeId) + { + // we should be able to remove website values for default store fallback + if ($storeId > \Magento\Store\Model\Store::DEFAULT_STORE_ID && $priceType === null && $price === null) { + return true; + } + if (!$this->isInRange($priceType, $this->priceTypes) || $this->isNegative($price)) { + return false; + } + + return true; + } } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php index 6fa34b625770c..a23c57bfcd11a 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Link/Product/Collection.php @@ -280,10 +280,8 @@ public function joinAttributes() if (!$this->getLinkModel()) { return $this; } - $attributes = $this->getLinkModel()->getAttributes(); - $attributesByType = array(); - foreach ($attributes as $attribute) { + foreach ($this->getLinkAttributes() as $attribute) { $table = $this->getLinkModel()->getAttributeTypeTable($attribute['type']); $alias = sprintf('link_attribute_%s_%s', $attribute['code'], $attribute['type']); @@ -319,4 +317,34 @@ public function setOrder($attribute, $dir = self::SORT_ORDER_ASC) } return parent::setOrder($attribute, $dir); } + + /** + * Get attributes of specified link type + * + * @param int $type + * @return array + */ + public function getLinkAttributes($type = null) + { + return $this->getLinkModel()->getAttributes($type); + } + + /** + * Add link attribute to filter. + * + * @param string $code + * @param array $condition + * @return $this + */ + public function addLinkAttributeToFilter($code, $condition) + { + foreach ($this->getLinkAttributes() as $attribute) { + if ($attribute['code'] == $code) { + $alias = sprintf('link_attribute_%s_%s', $code, $attribute['type']); + $whereCondition = $this->_getConditionSql($alias.'.`value`', $condition); + $this->getSelect()->where($whereCondition); + } + } + return $this; + } } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option.php b/app/code/Magento/Catalog/Model/Resource/Product/Option.php index 60578fff48f94..a87e5e2bdf8a7 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option.php @@ -252,95 +252,87 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje */ protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $object) { - $readAdapter = $this->_getReadAdapter(); $writeAdapter = $this->_getWriteAdapter(); - $titleTable = $this->getTable('catalog_product_option_title'); - - //title - if (!$object->getData('scope', 'title')) { - $statement = $readAdapter->select()->from( - $titleTable - )->where( - 'option_id = ?', - $object->getId() - )->where( - 'store_id = ?', + $titleTableName = $this->getTable('catalog_product_option_title'); + foreach ([\Magento\Store\Model\Store::DEFAULT_STORE_ID, $object->getStoreId()] as $storeId) { + $existInCurrentStore = $this->getColFromOptionTable($titleTableName, (int)$object->getId(), (int)$storeId); + $existInDefaultStore = $this->getColFromOptionTable( + $titleTableName, + (int)$object->getId(), \Magento\Store\Model\Store::DEFAULT_STORE_ID ); - - if ($readAdapter->fetchOne($statement)) { - if ($object->getStoreId() == '0') { - $data = $this->_prepareDataForTable( - new \Magento\Framework\Object(array('title' => $object->getTitle())), - $titleTable - ); - - $writeAdapter->update( - $titleTable, - $data, + if ($object->getTitle()) { + if ($existInCurrentStore) { + if ($object->getStoreId() == $storeId) { + $data = $this->_prepareDataForTable( + new \Magento\Framework\Object(array('title' => $object->getTitle())), + $titleTableName + ); + $writeAdapter->update( + $titleTableName, + $data, + array( + 'option_id = ?' => $object->getId(), + 'store_id = ?' => $storeId, + ) + ); + } + } else { + // we should insert record into not default store only of if it does not exist in default store + if (($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInDefaultStore) + || ($storeId != \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInCurrentStore) + ) { + $data = $this->_prepareDataForTable( + new \Magento\Framework\Object( + array( + 'option_id' => $object->getId(), + 'store_id' => $storeId, + 'title' => $object->getTitle(), + ) + ), + $titleTableName + ); + $writeAdapter->insert($titleTableName, $data); + } + } + } else { + if ($object->getId() && $object->getStoreId() > \Magento\Store\Model\Store::DEFAULT_STORE_ID + && $storeId + ) { + $writeAdapter->delete( + $titleTableName, array( 'option_id = ?' => $object->getId(), - 'store_id = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID + 'store_id = ?' => $object->getStoreId(), ) ); } - } else { - $data = $this->_prepareDataForTable( - new \Magento\Framework\Object( - array( - 'option_id' => $object->getId(), - 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, - 'title' => $object->getTitle() - ) - ), - $titleTable - ); - - $writeAdapter->insert($titleTable, $data); } } + } - if ($object->getStoreId() != '0' && !$object->getData('scope', 'title')) { - $statement = $readAdapter->select()->from( - $titleTable - )->where( - 'option_id = ?', - $object->getId() - )->where( - 'store_id = ?', - $object->getStoreId() - ); - - if ($readAdapter->fetchOne($statement)) { - $data = $this->_prepareDataForTable( - new \Magento\Framework\Object(array('title' => $object->getTitle())), - $titleTable - ); + /** + * Get first col from from first row for option table + * + * @param string $tableName + * @param int $optionId + * @param int $storeId + * @return string + */ + protected function getColFromOptionTable($tableName, $optionId, $storeId) + { + $readAdapter = $this->_getReadAdapter(); + $statement = $readAdapter->select()->from( + $tableName + )->where( + 'option_id = ?', + $optionId + )->where( + 'store_id = ?', + $storeId + ); - $writeAdapter->update( - $titleTable, - $data, - array('option_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()) - ); - } else { - $data = $this->_prepareDataForTable( - new \Magento\Framework\Object( - array( - 'option_id' => $object->getId(), - 'store_id' => $object->getStoreId(), - 'title' => $object->getTitle() - ) - ), - $titleTable - ); - $writeAdapter->insert($titleTable, $data); - } - } elseif ($object->getData('scope', 'title')) { - $writeAdapter->delete( - $titleTable, - array('option_id = ?' => $object->getId(), 'store_id = ?' => $object->getStoreId()) - ); - } + return $readAdapter->fetchOne($statement); } /** diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php index 8cbe4443b0ac2..741aa4c7c3ea1 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php @@ -109,7 +109,7 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje $price = (double)sprintf('%F', $object->getPrice()); $priceType = $object->getPriceType(); - if (!$object->getData('scope', 'price')) { + if ($object->getPrice() && $priceType) { //save for store_id = 0 $select = $this->_getReadAdapter()->select()->from( $priceTable, @@ -149,7 +149,11 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); - if ($object->getStoreId() != '0' && $scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE) { + if ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE + && $priceType + && $object->getPrice() + && $object->getStoreId() != \Magento\Store\Model\Store::DEFAULT_STORE_ID + ) { $baseCurrency = $this->_config->getValue( \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, @@ -203,12 +207,18 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje } } } else { - if ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE && $object->getData('scope', 'price')) { - $where = array( - 'option_type_id = ?' => (int)$object->getId(), - 'store_id = ?' => (int)$object->getStoreId() - ); - $this->_getWriteAdapter()->delete($priceTable, $where); + if ($scope == \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE + && !$object->getPrice() + && !$priceType + ) { + $storeIds = $this->_storeManager->getStore($object->getStoreId())->getWebsite()->getStoreIds(); + foreach ($storeIds as $storeId) { + $where = array( + 'option_type_id = ?' => (int)$object->getId(), + 'store_id = ?' => $storeId, + ); + $this->_getWriteAdapter()->delete($priceTable, $where); + } } } } @@ -221,9 +231,8 @@ protected function _saveValuePrices(\Magento\Framework\Model\AbstractModel $obje */ protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $object) { - $titleTable = $this->getTable('catalog_product_option_type_title'); - - if (!$object->getData('scope', 'title')) { + foreach ([\Magento\Store\Model\Store::DEFAULT_STORE_ID, $object->getStoreId()] as $storeId) { + $titleTable = $this->getTable('catalog_product_option_type_title'); $select = $this->_getReadAdapter()->select()->from( $titleTable, array('option_type_id') @@ -232,69 +241,78 @@ protected function _saveValueTitles(\Magento\Framework\Model\AbstractModel $obje (int)$object->getId() )->where( 'store_id = ?', - \Magento\Store\Model\Store::DEFAULT_STORE_ID + (int)$storeId ); $optionTypeId = $this->_getReadAdapter()->fetchOne($select); - - if ($optionTypeId) { - if ($object->getStoreId() == '0') { + $existInCurrentStore = $this->getOptionIdFromOptionTable($titleTable, (int)$object->getId(), (int)$storeId); + if ($object->getTitle()) { + if ($existInCurrentStore) { + if ($storeId == $object->getStoreId()) { + $where = array( + 'option_type_id = ?' => (int)$optionTypeId, + 'store_id = ?' => $storeId, + ); + $bind = array('title' => $object->getTitle()); + $this->_getWriteAdapter()->update($titleTable, $bind, $where); + } + } else { + $existInDefaultStore = $this->getOptionIdFromOptionTable( + $titleTable, + (int)$object->getId(), + \Magento\Store\Model\Store::DEFAULT_STORE_ID + ); + // we should insert record into not default store only of if it does not exist in default store + if (($storeId == \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInDefaultStore) + || ($storeId != \Magento\Store\Model\Store::DEFAULT_STORE_ID && !$existInCurrentStore) + ) { + $bind = array( + 'option_type_id' => (int)$object->getId(), + 'store_id' => $storeId, + 'title' => $object->getTitle() + ); + $this->_getWriteAdapter()->insert($titleTable, $bind); + } + } + } else { + if ($storeId + && $optionTypeId + && $object->getStoreId() > \Magento\Store\Model\Store::DEFAULT_STORE_ID + ) { $where = array( 'option_type_id = ?' => (int)$optionTypeId, - 'store_id = ?' => \Magento\Store\Model\Store::DEFAULT_STORE_ID + 'store_id = ?' => $storeId, ); - $bind = array('title' => $object->getTitle()); - $bind = array('title' => $object->getTitle()); - $this->_getWriteAdapter()->update($titleTable, $bind, $where); + $this->_getWriteAdapter()->delete($titleTable, $where); } - } else { - $bind = array( - 'option_type_id' => (int)$object->getId(), - 'store_id' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, - 'title' => $object->getTitle() - ); - $this->_getWriteAdapter()->insert($titleTable, $bind); } } + } - if ($object->getStoreId() != '0' && !$object->getData('scope', 'title')) { - $select = $this->_getReadAdapter()->select()->from( - $titleTable, - array('option_type_id') - )->where( - 'option_type_id = ?', - (int)$object->getId() - )->where( - 'store_id = ?', - (int)$object->getStoreId() - ); - $optionTypeId = $this->_getReadAdapter()->fetchOne($select); - - if ($optionTypeId) { - $bind = array('title' => $object->getTitle()); - $where = array( - 'option_type_id = ?' => (int)$optionTypeId, - 'store_id = ?' => (int)$object->getStoreId() - ); - $this->_getWriteAdapter()->update($titleTable, $bind, $where); - } else { - $bind = array( - 'option_type_id' => (int)$object->getId(), - 'store_id' => (int)$object->getStoreId(), - 'title' => $object->getTitle() - ); - $this->_getWriteAdapter()->insert($titleTable, $bind); - } - } else { - if ($object->getData('scope', 'title')) { - $where = array( - 'option_type_id = ?' => (int)$object->getId(), - 'store_id = ?' => (int)$object->getStoreId() - ); - $this->_getWriteAdapter()->delete($titleTable, $where); - } - } + /** + * Get first col from from first row for option table + * + * @param string $tableName + * @param int $optionId + * @param int $storeId + * @return string + */ + protected function getOptionIdFromOptionTable($tableName, $optionId, $storeId) + { + $readAdapter = $this->_getReadAdapter(); + $select = $readAdapter->select()->from( + $tableName, + array('option_type_id') + )->where( + 'option_type_id = ?', + $optionId + )->where( + 'store_id = ?', + (int)$storeId + ); + return $readAdapter->fetchOne($select); } + /** * Delete values by option id * diff --git a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadService.php b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadService.php index 6b8b1d3fa5a5e..15a67d8eac56c 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadService.php @@ -26,9 +26,8 @@ use Magento\Catalog\Model\Category as CategoryModel; use Magento\Catalog\Model\CategoryFactory; use Magento\Catalog\Service\V1\Data\Category; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductConverterFactory; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLinkBuilder; +use Magento\Catalog\Service\V1\Data\Category\ProductLink; +use Magento\Catalog\Service\V1\Data\Category\ProductLinkBuilder; use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\NoSuchEntityException; diff --git a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceInterface.php b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceInterface.php index 597d54019382d..2d9601c55df9c 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceInterface.php +++ b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/ReadServiceInterface.php @@ -27,7 +27,7 @@ interface ReadServiceInterface { /** * @param int $categoryId - * @return \Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink[] + * @return \Magento\Catalog\Service\V1\Data\Category\ProductLink[] * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function assignedProducts($categoryId); diff --git a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteService.php b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteService.php index b52114a39f18e..082b927dd1099 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteService.php @@ -29,7 +29,7 @@ use Magento\Catalog\Model\ProductFactory; use Magento\Catalog\Service\V1\Category\CategoryLoaderFactory; use Magento\Catalog\Service\V1\Data\Category; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink; +use Magento\Catalog\Service\V1\Data\Category\ProductLink; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\StateException; diff --git a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceInterface.php b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceInterface.php index cd0c22d8e44aa..bcf6f75250404 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceInterface.php +++ b/app/code/Magento/Catalog/Service/V1/Category/ProductLinks/WriteServiceInterface.php @@ -23,7 +23,7 @@ */ namespace Magento\Catalog\Service\V1\Category\ProductLinks; -use Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink; +use Magento\Catalog\Service\V1\Data\Category\ProductLink; interface WriteServiceInterface { @@ -31,7 +31,7 @@ interface WriteServiceInterface * Assign a product to the required category * * @param int $categoryId - * @param \Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink $productLink + * @param \Magento\Catalog\Service\V1\Data\Category\ProductLink $productLink * @return bool Will returned True if assigned * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \Magento\Framework\Exception\NoSuchEntityException @@ -41,7 +41,7 @@ public function assignProduct($categoryId, ProductLink $productLink); /** * @param int $categoryId - * @param \Magento\Catalog\Service\V1\Data\Eav\Category\ProductLink $productLink + * @param \Magento\Catalog\Service\V1\Data\Category\ProductLink $productLink * @return bool Will returned True if updated * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \Magento\Framework\Exception\NoSuchEntityException diff --git a/app/code/Magento/Catalog/Service/V1/Category/WriteService.php b/app/code/Magento/Catalog/Service/V1/Category/WriteService.php index 8936631404a7d..8e0a607ff1868 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/WriteService.php +++ b/app/code/Magento/Catalog/Service/V1/Category/WriteService.php @@ -27,7 +27,9 @@ use Magento\Catalog\Model\CategoryFactory; use Magento\Catalog\Service\V1\Data\Category as CategoryDataObject; use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\StateException; use Magento\Catalog\Service\V1\Data\Category\Mapper as CategoryMapper; use Magento\Store\Model\StoreManagerInterface; @@ -94,13 +96,16 @@ public function create(CategoryDataObject $category) */ public function delete($categoryId) { + if (\Magento\Catalog\Model\Category::TREE_ROOT_ID == $categoryId) { + throw new InputException('Cannot remove the system category.'); + } /** @var Category $category */ $category = $this->loadCategory($categoryId); try { $category->delete(); } catch (\Exception $e) { - throw new CouldNotSaveException('Cannot delete category with id %1', [$categoryId], $e); + throw new StateException('Cannot delete category with id %1', [$categoryId], $e); } return true; @@ -131,10 +136,11 @@ public function move($categoryId, $parentId, $afterId = null) $model = $this->loadCategory($categoryId); $parentCategory = $this->loadCategory($parentId); - if (is_null($afterId) && $parentCategory->hasChildren()) { + if ($parentCategory->hasChildren()) { $parentChildren = $parentCategory->getChildren(); $categoryIds = explode(',', $parentChildren); - $afterId = array_pop($categoryIds); + $lastId = array_pop($categoryIds); + $afterId = (is_null($afterId) || $afterId > $lastId) ? $lastId : $afterId; } if (strpos($parentCategory->getPath(), $model->getPath()) === 0) { diff --git a/app/code/Magento/Catalog/Service/V1/Category/WriteServiceInterface.php b/app/code/Magento/Catalog/Service/V1/Category/WriteServiceInterface.php index 29a6ec6646441..46d46f8729957 100644 --- a/app/code/Magento/Catalog/Service/V1/Category/WriteServiceInterface.php +++ b/app/code/Magento/Catalog/Service/V1/Category/WriteServiceInterface.php @@ -39,7 +39,8 @@ public function create(\Magento\Catalog\Service\V1\Data\Category $category); * * @param int $categoryId category which will deleted * @return bool Will returned True if deleted - * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Framework\Exception\InputException + * @throws \Magento\Framework\Exception\StateException * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function delete($categoryId); diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLink.php b/app/code/Magento/Catalog/Service/V1/Data/Category/ProductLink.php similarity index 96% rename from app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLink.php rename to app/code/Magento/Catalog/Service/V1/Data/Category/ProductLink.php index fe5a6a1976bcd..8383aa9a983ae 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLink.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Category/ProductLink.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Service\V1\Data\Eav\Category; +namespace Magento\Catalog\Service\V1\Data\Category; /** * @codeCoverageIgnore diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLinkBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Category/ProductLinkBuilder.php similarity index 96% rename from app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLinkBuilder.php rename to app/code/Magento/Catalog/Service/V1/Data/Category/ProductLinkBuilder.php index 7b0a76b7e1095..6f00b75e6869e 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/ProductLinkBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Category/ProductLinkBuilder.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Catalog\Service\V1\Data\Eav\Category; +namespace Magento\Catalog\Service\V1\Data\Category; /** * @codeCoverageIgnore diff --git a/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php b/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php index 33bf85cbaa6d4..e0eb764246679 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Category/Tree.php @@ -136,6 +136,7 @@ public function getTree($node, $depth = null, $currentLevel = 0) ->setPosition($node->getPosition()) ->setLevel($node->getLevel()) ->setActive($node->getIsActive()) + ->setProductCount($node->getProductCount()) ->setChildren([]); if ($node->hasChildren()) { diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Tree.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Tree.php index 1b77875b87cb3..087b9798c7fb7 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Tree.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/Tree.php @@ -32,6 +32,7 @@ class Tree extends \Magento\Framework\Service\Data\AbstractObject const POSITION = 'position'; const LEVEL = 'level'; const CHILDREN = 'children'; + const PRODUCT_COUNT = 'product_count'; /** * Get category ID @@ -93,6 +94,16 @@ public function getLevel() return $this->_get(self::LEVEL); } + /** + * Get product count + * + * @return int + */ + public function getProductCount() + { + return $this->_get(self::PRODUCT_COUNT); + } + /** * Get category level * diff --git a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/TreeBuilder.php b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/TreeBuilder.php index b2250ff04e57d..f46ca55aaddcf 100644 --- a/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/TreeBuilder.php +++ b/app/code/Magento/Catalog/Service/V1/Data/Eav/Category/TreeBuilder.php @@ -82,6 +82,17 @@ public function setPosition($position) return $this->_set(Tree::POSITION, $position); } + /** + * Set product count + * + * @param int $productCount + * @return int + */ + public function setProductCount($productCount) + { + return $this->_set(Tree::PRODUCT_COUNT, $productCount); + } + /** * Set category level * diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index ff3ef067362d9..76630102310a3 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -2,35 +2,35 @@ "name": "magento/module-catalog", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/module-indexer": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-log": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-bundle": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-catalog-rule": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-catalog-search": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-product-alert": "0.1.0-alpha89", - "magento/module-url-rewrite": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/module-indexer": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-log": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-bundle": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-catalog-rule": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-catalog-search": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-product-alert": "0.1.0-alpha90", + "magento/module-url-rewrite": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Catalog/etc/adminhtml/acl.xml b/app/code/Magento/Catalog/etc/acl.xml similarity index 96% rename from app/code/Magento/Catalog/etc/adminhtml/acl.xml rename to app/code/Magento/Catalog/etc/acl.xml index ca0bad3473dc2..d7e1600640987 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/acl.xml +++ b/app/code/Magento/Catalog/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml index 96c4185e5a750..15128975a4c51 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/option.phtml @@ -58,7 +58,9 @@ class="required-entry input-text" type="text" value="${title}" - data-store-label="${title}"> + data-store-label="${title}" + {{if typeof(scopeTitleDisabled) != 'undefined' && scopeTitleDisabled != null}} disabled="disabled" {{/if}} + > {{html checkboxScopeTitle}} @@ -83,7 +85,7 @@ - + diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/type/select.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/type/select.phtml index 732dc46363904..ea85c37c21b57 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/type/select.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/edit/options/type/select.phtml @@ -59,11 +59,12 @@ - {{html checkboxScopeTitle}} + {{html checkboxScopeTitle}} getCanReadPrice() !== false) : ?> > - getPriceTypeSelectHtml() ?>{{html checkboxScopePrice}} + getPriceTypeSelectHtml('{{if typeof(scopePriceDisabled) != "undefined" && scopePriceDisabled != null}} disabled="disabled" {{/if}}') ?>{{html checkboxScopePrice}} diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml index e3692359697b6..8aef6a6e4b963 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/compare/list.phtml @@ -30,7 +30,7 @@ getLayout()->createBlock('Magento\Catalog\Block\Product\Image'); ?>
- - helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - - + helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - - - - - - - - - diff --git a/app/code/Magento/Cms/etc/adminhtml/acl.xml b/app/code/Magento/Cms/etc/acl.xml similarity index 95% rename from app/code/Magento/Cms/etc/adminhtml/acl.xml rename to app/code/Magento/Cms/etc/acl.xml index 59a0ca89f89be..c26880bbbbb3c 100644 --- a/app/code/Magento/Cms/etc/adminhtml/acl.xml +++ b/app/code/Magento/Cms/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json index 8eb91f0ab2bd0..091d2ae7c31be 100644 --- a/app/code/Magento/CmsUrlRewrite/composer.json +++ b/app/code/Magento/CmsUrlRewrite/composer.json @@ -2,13 +2,13 @@ "name": "magento/module-cms-url-rewrite", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-url-redirect": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89" + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-url-redirect": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Configurable.php b/app/code/Magento/ConfigurableImportExport/Model/Export/Product/Type/Configurable.php similarity index 93% rename from app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Configurable.php rename to app/code/Magento/ConfigurableImportExport/Model/Export/Product/Type/Configurable.php index 290a8019075f8..8aa67371907e2 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableImportExport/Model/Export/Product/Type/Configurable.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\CatalogImportExport\Model\Export\Product\Type; +namespace Magento\ConfigurableImportExport\Model\Export\Product\Type; class Configurable extends \Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType { diff --git a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer.php b/app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php similarity index 96% rename from app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer.php rename to app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php index 97db1a13b3ca6..280d3af873ba6 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/RowCustomizer.php +++ b/app/code/Magento/ConfigurableImportExport/Model/Export/RowCustomizer.php @@ -21,7 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\CatalogImportExport\Model\Export; +namespace Magento\ConfigurableImportExport\Model\Export; + +use \Magento\CatalogImportExport\Model\Export\RowCustomizerInterface; class RowCustomizer implements RowCustomizerInterface { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Configurable.php b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php similarity index 99% rename from app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Configurable.php rename to app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php index 8baafce4c66ea..ba6b3f4ddecc0 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php @@ -1,7 +1,7 @@ + + + + + + Magento\ConfigurableImportExport\Model\Export\RowCustomizer + + + + diff --git a/app/code/Magento/ConfigurableImportExport/etc/export.xml b/app/code/Magento/ConfigurableImportExport/etc/export.xml new file mode 100644 index 0000000000000..ff4060a99d80a --- /dev/null +++ b/app/code/Magento/ConfigurableImportExport/etc/export.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/app/code/Magento/ConfigurableImportExport/etc/import.xml b/app/code/Magento/ConfigurableImportExport/etc/import.xml new file mode 100644 index 0000000000000..0ae338bc6fe4d --- /dev/null +++ b/app/code/Magento/ConfigurableImportExport/etc/import.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/app/code/Magento/Authz/etc/module.xml b/app/code/Magento/ConfigurableImportExport/etc/module.xml similarity index 76% rename from app/code/Magento/Authz/etc/module.xml rename to app/code/Magento/ConfigurableImportExport/etc/module.xml index 6d155cc637440..1d64d1dcc52bc 100644 --- a/app/code/Magento/Authz/etc/module.xml +++ b/app/code/Magento/ConfigurableImportExport/etc/module.xml @@ -24,14 +24,13 @@ */ --> - - - - + - - - + + + + + diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php index 040930fe74861..9326f2db453f8 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php @@ -409,7 +409,7 @@ public function getConfigurableAttributesAsArray($product) * @param \Magento\Catalog\Model\Product $product * @return \Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection */ - public function getConfigurableAttributeCollection($product) + public function getConfigurableAttributeCollection(\Magento\Catalog\Model\Product $product) { return $this->_attributeCollectionFactory->create()->setProductFilter($product); } @@ -537,8 +537,9 @@ public function beforeSave($product) /** * Save configurable product depended data * - * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Catalog\Model\Product $product * @return $this + * @throws \InvalidArgumentException */ public function save($product) { @@ -553,21 +554,26 @@ public function save($product) if (!$product->getIsDuplicate()) { if (!empty($attributeData['id'])) { $configurableAttribute->load($attributeData['id']); - } else { - $configurableAttribute->loadByProductAndAttribute( - $product, - $this->getAttributeById($attributeData['attribute_id'], $product) + $attributeData['attribute_id'] = $configurableAttribute->getAttributeId(); + } elseif (!empty($attributeData['attribute_id'])) { + $attribute = $this->_eavConfig->getAttribute( + \Magento\Catalog\Model\Product::ENTITY, $attributeData['attribute_id'] ); + $attributeData['attribute_id'] = $attribute->getId(); + if (!$this->canUseAttribute($attribute)) { + throw new \InvalidArgumentException( + 'Provided attribute can not be used with configurable product' + ); + } + $configurableAttribute->loadByProductAndAttribute($product, $attribute); } } unset($attributeData['id']); - $configurableAttribute->addData( - $attributeData - )->setStoreId( - $product->getStoreId() - )->setProductId( - $product->getId() - )->save(); + $configurableAttribute + ->addData($attributeData) + ->setStoreId($product->getStoreId()) + ->setProductId($product->getId()) + ->save(); } /** @var $configurableAttributesCollection \Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable\Attribute\Collection */ $configurableAttributesCollection = $this->_attributeCollectionFactory->create(); diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php index dc79a87d08438..f00b375161712 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php @@ -25,6 +25,8 @@ */ namespace Magento\ConfigurableProduct\Model\Product\Type\Configurable; +use Magento\Framework\Model\Context; + /** * @method Attribute _getResource() * @method Attribute getResource() diff --git a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php index a84a84b574565..b832a6c8c4e08 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php +++ b/app/code/Magento/ConfigurableProduct/Model/Resource/Product/Type/Configurable/Attribute.php @@ -25,6 +25,8 @@ */ namespace Magento\ConfigurableProduct\Model\Resource\Product\Type\Configurable; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute as ConfigurableAttribute; + class Attribute extends \Magento\Framework\Model\Resource\Db\AbstractDb { /** @@ -349,4 +351,74 @@ public function deleteAttributesByProductId($productId) ); $this->_getWriteAdapter()->query($this->_getReadAdapter()->deleteFromSelect($select, $this->getMainTable())); } + + /** + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + */ + protected function _afterLoad(\Magento\Framework\Model\AbstractModel $object) + { + parent::_afterLoad($object); + $this->loadLabel($object); + $this->loadPrices($object); + return $this; + } + + /** + * Load label for configurable attribute + * + * @param ConfigurableAttribute $object + * @return $this + */ + protected function loadLabel(ConfigurableAttribute $object) + { + $storeId = (int)$this->_storeManager->getStore()->getId(); + $connection = $this->_getReadAdapter(); + $useDefaultCheck = $connection + ->getCheckSql('store.use_default IS NULL', 'def.use_default', 'store.use_default'); + $labelCheck = $connection->getCheckSql('store.value IS NULL', 'def.value', 'store.value'); + $select = $connection + ->select() + ->from(array('def' => $this->_labelTable)) + ->joinLeft( + array('store' => $this->_labelTable), + $connection->quoteInto( + 'store.product_super_attribute_id = def.product_super_attribute_id AND store.store_id = ?', + $storeId + ), + array('use_default' => $useDefaultCheck, 'label' => $labelCheck) + ) + ->where('def.product_super_attribute_id = ?', $object->getId()) + ->where('def.store_id = ?', 0); + + $data = $connection->fetchRow($select); + $object->setLabel($data['label']); + $object->setUseDefault($data['use_default']); + return $this; + } + + /** + * Load prices for configurable attribute + * + * @param ConfigurableAttribute $object + * @return $this + */ + protected function loadPrices(ConfigurableAttribute $object) + { + $websiteId = $this->_catalogData->isPriceGlobal() ? 0 : (int)$this->_storeManager->getStore()->getWebsiteId(); + $select = $this->_getReadAdapter()->select() + ->from($this->_priceTable) + ->where('product_super_attribute_id = ?', $object->getId()) + ->where('website_id = ?', $websiteId); + + foreach ($select->query() as $row) { + $data = [ + 'value_index' => $row['value_index'], + 'is_percent' => $row['is_percent'], + 'pricing_value' => $row['pricing_value'], + ]; + $object->addPrice($data); + } + return $this; + } } diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php similarity index 76% rename from app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute.php rename to app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php index 99e92729f394e..0a723a8b6f2af 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option.php @@ -23,14 +23,25 @@ */ namespace Magento\ConfigurableProduct\Service\V1\Data; -class ConfigurableAttribute extends \Magento\Framework\Service\Data\AbstractObject +class Option extends \Magento\Framework\Service\Data\AbstractObject { + /**#@+ + * Constants defined for keys of array + */ const ID = 'id'; + const LABEL = 'label'; + + const TYPE = 'type'; + const USE_DEFAULT = 'use_default'; + const POSITION = 'position'; + const VALUES = 'values'; + const ATTRIBUTE_ID = 'attribute_id'; + /**#@-*/ /** * @return int|null @@ -41,7 +52,7 @@ public function getId() } /** - * @return string + * @return string|null */ public function getAttributeId() { @@ -56,6 +67,22 @@ public function getLabel() return $this->_get(self::LABEL); } + /** + * @return string|null + */ + public function getType() + { + return $this->_get(self::TYPE); + } + + /** + * @return int|null + */ + public function getPosition() + { + return $this->_get(self::POSITION); + } + /** * @return bool|null */ @@ -65,7 +92,7 @@ public function isUseDefault() } /** - * @return \Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute\Value[] + * @return \Magento\ConfigurableProduct\Service\V1\Data\Option\Value[]|null */ public function getValues() { diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/Value.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php similarity index 82% rename from app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/Value.php rename to app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php index 6b88e10b4ac8b..0ecd1e149249f 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/Value.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/Value.php @@ -1,6 +1,4 @@ _get(self::PRICE_IS_PERCENT); + return $this->_get(self::IS_PERCENT); } /** diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/ValueBuilder.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.php similarity index 88% rename from app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/ValueBuilder.php rename to app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.php index 511e1c33b15f7..f113fde85bf72 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttribute/ValueBuilder.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueBuilder.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute; +namespace Magento\ConfigurableProduct\Service\V1\Data\Option; use Magento\Framework\Service\Data\AbstractObjectBuilder; @@ -40,9 +40,9 @@ public function setPrice($value) * @param int $value * @return self */ - public function setPriceIsPercent($value) + public function setPercent($value) { - return $this->_set(Value::PRICE_IS_PERCENT, $value); + return $this->_set(Value::IS_PERCENT, $value); } /** diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php new file mode 100644 index 0000000000000..202c6f19b1f2c --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/Option/ValueConverter.php @@ -0,0 +1,40 @@ + $value->getIndex(), + 'is_percent' => $value->isPercent(), + 'pricing_value' => $value->getPrice(), + ]; + } +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttributeBuilder.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php similarity index 58% rename from app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttributeBuilder.php rename to app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php index a50a266156f4f..e720f3e8213fa 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/Data/ConfigurableAttributeBuilder.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionBuilder.php @@ -23,50 +23,68 @@ */ namespace Magento\ConfigurableProduct\Service\V1\Data; -class ConfigurableAttributeBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder +class OptionBuilder extends \Magento\Framework\Service\Data\AbstractObjectBuilder { /** - * @param int $value - * @return self + * @param int $value + * @return $this */ public function setId($value) { - return $this->_set(ConfigurableAttribute::ID, $value); + return $this->_set(Option::ID, $value); } /** * @param string $value - * @return self + * @return $this */ public function setAttributeId($value) { - return $this->_set(ConfigurableAttribute::ATTRIBUTE_ID, $value); + return $this->_set(Option::ATTRIBUTE_ID, $value); } /** - * @param string $value - * @return self + * @param string $value + * @return $this */ public function setLabel($value) { - return $this->_set(ConfigurableAttribute::LABEL, $value); + return $this->_set(Option::LABEL, $value); + } + + /** + * @param int $value + * @return $this + */ + public function setPosition($value) + { + return $this->_set(Option::POSITION, $value); } /** * @param bool $value * @return self */ - public function useDefault($value) + public function setType($value) { - return $this->_set(ConfigurableAttribute::USE_DEFAULT, $value); + return $this->_set(Option::TYPE, $value); } /** - * @param \Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute\Value[] $value - * @return self + * @param bool $value + * @return $this + */ + public function setUseDefault($value) + { + return $this->_set(Option::USE_DEFAULT, $value); + } + + /** + * @param \Magento\ConfigurableProduct\Service\V1\Data\Option\Value[] $value + * @return $this */ public function setValues($value) { - return $this->_set(ConfigurableAttribute::VALUES, $value); + return $this->_set(Option::VALUES, $value); } } diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionConverter.php b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionConverter.php new file mode 100644 index 0000000000000..d50d21f1f612b --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Data/OptionConverter.php @@ -0,0 +1,152 @@ +optionBuilder = $optionBuilder; + $this->valueBuilder = $valueBuilder; + $this->attributeFactory = $attributeFactory; + $this->valueConverter = $valueConverter; + } + + /** + * Convert configurable attribute to option data object + * + * @param Attribute $configurableAttribute + * @return \Magento\ConfigurableProduct\Service\V1\Data\Option + */ + public function convertFromModel(Attribute $configurableAttribute) + { + $values = []; + $prices = $configurableAttribute->getPrices(); + if (is_array($prices)) { + foreach ($prices as $price) { + $values[] = $this->valueBuilder + ->setIndex($price['value_index']) + ->setPrice($price['pricing_value']) + ->setPercent($price['is_percent']) + ->create(); + } + } + + $data = [ + Option::ID => $configurableAttribute->getId(), + Option::ATTRIBUTE_ID => $configurableAttribute->getAttributeId(), + Option::LABEL => $configurableAttribute->getLabel(), + Option::TYPE => $configurableAttribute->getProductAttribute()->getFrontend()->getInputType(), + Option::POSITION => $configurableAttribute->getPosition(), + Option::USE_DEFAULT => $configurableAttribute->getData('use_default'), + Option::VALUES => $values + ]; + + return $this->optionBuilder->populateWithArray($data)->create(); + } + + /** + * @param Option $option + * @return array + */ + public function convertArrayFromData(Option $option) + { + $values = []; + if (is_array($option->getValues())) { + foreach ($option->getValues() as $value) { + $values[] = $this->valueConverter->convertArrayFromData($value); + } + } + return [ + 'attribute_id' => $option->getAttributeId(), + 'position' => $option->getPosition(), + 'use_default' => $option->isUseDefault(), + 'label' => $option->getLabel(), + 'values' => $values + ]; + } + + /** + * @param Option $option + * @param Attribute $configurableAttribute + * @return Attribute + */ + public function getModelFromData(Option $option, Attribute $configurableAttribute) + { + /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $returnConfigurableAttribute */ + $returnConfigurableAttribute = $this->attributeFactory->create(); + $returnConfigurableAttribute->setData($configurableAttribute->getData()); + $returnConfigurableAttribute->addData($option->__toArray()); + $returnConfigurableAttribute->setId($configurableAttribute->getId()); + $returnConfigurableAttribute->setAttributeId($configurableAttribute->getAttributeId()); + $returnConfigurableAttribute->setValues($configurableAttribute->getPrices()); + + $values = $option->getValues(); + if (!is_null($values)) { + $prices = []; + foreach ($values as $value) { + $prices[] = $this->valueConverter->convertArrayFromData($value); + } + $returnConfigurableAttribute->setValues($prices); + } + + return $returnConfigurableAttribute; + } +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadService.php b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadService.php new file mode 100644 index 0000000000000..57b4e17625fe6 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadService.php @@ -0,0 +1,144 @@ +productRepository = $productRepository; + $this->optionConverter = $optionConverter; + $this->configurableType = $configurableType; + $this->inputType = $inputType; + } + + /** + * {@inheritdoc} + */ + public function get($productSku, $optionId) + { + $product = $this->getProduct($productSku); + $collection = $this->getConfigurableAttributesCollection($product); + $collection->addFieldToFilter($collection->getResource()->getIdFieldName(), $optionId); + /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $configurableAttribute */ + $configurableAttribute = $collection->getFirstItem(); + if (!$configurableAttribute->getId()) { + throw new NoSuchEntityException(sprintf('Requested option doesn\'t exist: %s', $optionId)); + } + return $this->optionConverter->convertFromModel($configurableAttribute); + } + + /** + * {@inheritdoc} + */ + public function getList($productSku) + { + $options = []; + $product = $this->getProduct($productSku); + foreach ($this->getConfigurableAttributesCollection($product) as $option) { + $options[] = $this->optionConverter->convertFromModel($option); + } + return $options; + } + + /** + * @inheritdoc + */ + public function getTypes() + { + return array_map( + function ($inputType) { + return $inputType['value']; + }, + $this->inputType->toOptionArray() + ); + } + + /** + * Retrieve product instance by sku + * + * @param string $productSku + * @return \Magento\Catalog\Model\Product + * @throws \Magento\Webapi\Exception + */ + private function getProduct($productSku) + { + $product = $this->productRepository->get($productSku); + if (ConfigurableType::TYPE_CODE !== $product->getTypeId()) { + throw new Exception( + sprintf('Only implemented for configurable product: %s', $productSku), + Exception::HTTP_FORBIDDEN + ); + } + return $product; + } + + /** + * Retrieve configurable attribute collection through product object + * + * @param \Magento\Catalog\Model\Product $product + * @return Collection + */ + private function getConfigurableAttributesCollection(\Magento\Catalog\Model\Product $product) + { + return $this->configurableType->getConfigurableAttributeCollection($product); + } +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceInterface.php b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceInterface.php new file mode 100644 index 0000000000000..1cfd5c2d8e801 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/ReadServiceInterface.php @@ -0,0 +1,58 @@ +productRepository = $productRepository; + $this->configurableAttributeFactory = $configurableAttributeFactory; + $this->eavConfig = $eavConfig; + $this->optionConverter = $optionConverter; + $this->storeManager = $storeManager; + $this->productType = $productType; + } + + /** + * {@inheritdoc} + */ + public function add($productSku, Option $option) + { + $product = $this->productRepository->get($productSku); + $allowedTypes = [ProductType::TYPE_SIMPLE, ProductType::TYPE_VIRTUAL, ConfigurableType::TYPE_CODE]; + if (!in_array($product->getTypeId(), $allowedTypes)) { + throw new \InvalidArgumentException('Incompatible product type'); + } + + $eavAttribute = $this->eavConfig->getAttribute(Product::ENTITY, $option->getAttributeId()); + + /** @var $configurableAttribute \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute */ + $configurableAttribute = $this->configurableAttributeFactory->create(); + $configurableAttribute->loadByProductAndAttribute($product, $eavAttribute); + if ($configurableAttribute->getId()) { + throw new CouldNotSaveException('Product already has this option'); + } + + try { + $product->setTypeId(ConfigurableType::TYPE_CODE); + $product->setConfigurableAttributesData([$this->optionConverter->convertArrayFromData($option)]); + $product->setStoreId($this->storeManager->getStore(Store::ADMIN_CODE)->getId()); + $product->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('An error occurred while saving option'); + } + + $configurableAttribute = $this->configurableAttributeFactory->create(); + $configurableAttribute->loadByProductAndAttribute($product, $eavAttribute); + if (!$configurableAttribute->getId()) { + throw new CouldNotSaveException('An error occurred while saving option'); + } + + return $configurableAttribute->getId(); + } + + /** + * {@inheritdoc} + */ + public function update($productSku, $optionId, Option $option) + { + $product = $this->getProduct($productSku); + + $configurableAttribute = $this->configurableAttributeFactory->create(); + $configurableAttribute->load($optionId); + if (!$configurableAttribute->getId() || $configurableAttribute->getProductId() != $product->getId()) { + throw new NoSuchEntityException('Option with id "%1" not found', [$optionId]); + } + $configurableAttribute = $this->optionConverter->getModelFromData($option, $configurableAttribute); + try { + $configurableAttribute->save(); + } catch (\Exception $e) { + throw new CouldNotSaveException('Could not update option with id "%1"', [$optionId]); + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function remove($productSku, $optionId) + { + $product = $this->getProduct($productSku); + + $attributeCollection = $this->productType->getConfigurableAttributeCollection($product); + /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $option */ + $option = $attributeCollection->getItemById($optionId); + + if ($option === null) { + throw new NoSuchEntityException('Requested option doesn\'t exist'); + } + $option->delete(); + + return true; + } + + /** + * @param string $productSku + * @return \Magento\Catalog\Model\Product + * @throws \Magento\Webapi\Exception + */ + private function getProduct($productSku) + { + $product = $this->productRepository->get($productSku); + if (ConfigurableType::TYPE_CODE !== $product->getTypeId()) { + throw new Exception( + 'Product with specified sku: "%1" is not a configurable product', + Exception::HTTP_FORBIDDEN, + Exception::HTTP_FORBIDDEN, + [ + $product->getSku() + ] + ); + } + return $product; + } +} diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceInterface.php b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceInterface.php new file mode 100644 index 0000000000000..4b01d72194bfd --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Service/V1/Product/Option/WriteServiceInterface.php @@ -0,0 +1,61 @@ +getAttributesForMatrix($configurableAttributes); + $attributes = $this->getAttributesForMatrix($options); $variations = $this->variationMatrix->getVariations($attributes); $products = $this->populateProductVariation($product, $variations, $attributes); return $products; @@ -74,18 +74,18 @@ public function generateVariation(Product $product, $configurableAttributes) /** * Prepare attribute info for variation matrix generation * - * @param \Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute[] $configurableAttributes + * @param \Magento\ConfigurableProduct\Service\V1\Data\Option[] $options * @return array */ - private function getAttributesForMatrix($configurableAttributes) + private function getAttributesForMatrix($options) { $attributes = []; - foreach ($configurableAttributes as $configurableAttribute) { - $configurable = $configurableAttribute->__toArray(); - $attribute = $this->attributeReadService->info($configurableAttribute->getAttributeId()); + foreach ($options as $option) { + $configurable = $option->__toArray(); + $attribute = $this->attributeReadService->info($option->getAttributeId()); $configurable['options'] = $attribute->__toArray()['options']; $configurable['attribute_code'] = $attribute->getAttributeCode(); - $attributes[$configurableAttribute->getAttributeId()] = $configurable; + $attributes[$option->getAttributeId()] = $configurable; } return $attributes; } @@ -113,7 +113,7 @@ private function populateProductVariation(Product $product, $variations, $attrib ); $priceInfo = $valueInfo['price']; $price += (!empty($priceInfo['is_percent']) ? $product->getPrice() / 100.0 : 1.0) - * $priceInfo['pricing_value']; + * $priceInfo['price']; } $this->productBuilder->setPrice($price); $this->productBuilder->setName($product->getName() . $suffix); diff --git a/app/code/Magento/ConfigurableProduct/Service/V1/ReadServiceInterface.php b/app/code/Magento/ConfigurableProduct/Service/V1/ReadServiceInterface.php index 49ac8f1ff90f1..7b4bd51b40519 100644 --- a/app/code/Magento/ConfigurableProduct/Service/V1/ReadServiceInterface.php +++ b/app/code/Magento/ConfigurableProduct/Service/V1/ReadServiceInterface.php @@ -29,11 +29,11 @@ interface ReadServiceInterface * Generate variation based on same product * * @param \Magento\Catalog\Service\V1\Data\Product $product - * @param \Magento\ConfigurableProduct\Service\V1\Data\ConfigurableAttribute[] $configurableAttributes + * @param \Magento\ConfigurableProduct\Service\V1\Data\Option[] $options * @return \Magento\Catalog\Service\V1\Data\Product[] */ public function generateVariation( \Magento\Catalog\Service\V1\Data\Product $product, - $configurableAttributes + $options ); } diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index 27f4fed2b11a9..7c456e44c9bf2 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -2,26 +2,26 @@ "name": "magento/module-configurable-product", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-catalog-rule": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", - "magento/module-webapi": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-catalog-rule": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", + "magento/module-webapi": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/ConfigurableProduct/etc/di.xml b/app/code/Magento/ConfigurableProduct/etc/di.xml index 472fdd85bdc1e..447c8e94c509b 100644 --- a/app/code/Magento/ConfigurableProduct/etc/di.xml +++ b/app/code/Magento/ConfigurableProduct/etc/di.xml @@ -24,9 +24,12 @@ */ --> + + + diff --git a/app/code/Magento/ConfigurableProduct/etc/webapi.xml b/app/code/Magento/ConfigurableProduct/etc/webapi.xml index fd11c2f6b29fa..315bcd1423e5f 100644 --- a/app/code/Magento/ConfigurableProduct/etc/webapi.xml +++ b/app/code/Magento/ConfigurableProduct/etc/webapi.xml @@ -49,4 +49,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json index 067e82511f5de..acae9e53d5a32 100644 --- a/app/code/Magento/Contact/composer.json +++ b/app/code/Magento/Contact/composer.json @@ -2,16 +2,16 @@ "name": "magento/module-contact", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Contact/etc/adminhtml/acl.xml b/app/code/Magento/Contact/etc/acl.xml similarity index 94% rename from app/code/Magento/Contact/etc/adminhtml/acl.xml rename to app/code/Magento/Contact/etc/acl.xml index d957ae0cd5a16..4a8bd27964d7f 100644 --- a/app/code/Magento/Contact/etc/adminhtml/acl.xml +++ b/app/code/Magento/Contact/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Core/composer.json b/app/code/Magento/Core/composer.json index 1cef33c57154d..a79885d900b34 100644 --- a/app/code/Magento/Core/composer.json +++ b/app/code/Magento/Core/composer.json @@ -2,19 +2,19 @@ "name": "magento/module-core", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-page-cache": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-page-cache": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php index 56d23dbff9d8f..0e03bc5a2968d 100644 --- a/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php +++ b/app/code/Magento/Core/data/core_setup/data-upgrade-1.6.0.4-1.6.0.5.php @@ -26,7 +26,7 @@ $installer = $this; $installer->startSetup(); -$tableName = $installer->getTable('admin_rule'); +$tableName = $installer->getTable('authorization_rule'); if ($tableName) { $installer->getConnection()->delete($tableName, array('resource_id = ?' => 'admin/system/tools/compiler')); } diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json index a46386ee52150..24bb9c00e22f3 100644 --- a/app/code/Magento/Cron/composer.json +++ b/app/code/Magento/Cron/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-cron", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json index a47864769f579..616e2e5509aad 100644 --- a/app/code/Magento/CurrencySymbol/composer.json +++ b/app/code/Magento/CurrencySymbol/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-currency-symbol", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-page-cache": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-page-cache": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CurrencySymbol/etc/adminhtml/acl.xml b/app/code/Magento/CurrencySymbol/etc/acl.xml similarity index 94% rename from app/code/Magento/CurrencySymbol/etc/adminhtml/acl.xml rename to app/code/Magento/CurrencySymbol/etc/acl.xml index 001ddce966885..5afa8f8b167f1 100644 --- a/app/code/Magento/CurrencySymbol/etc/adminhtml/acl.xml +++ b/app/code/Magento/CurrencySymbol/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Customer/Model/Authorization/CustomerSessionUserContext.php b/app/code/Magento/Customer/Model/Authorization/CustomerSessionUserContext.php new file mode 100644 index 0000000000000..4fa7209e97906 --- /dev/null +++ b/app/code/Magento/Customer/Model/Authorization/CustomerSessionUserContext.php @@ -0,0 +1,66 @@ +_customerSession = $customerSession; + } + + /** + * {@inheritdoc} + */ + public function getUserId() + { + return $this->_customerSession->getId(); + } + + /** + * {@inheritdoc} + */ + public function getUserType() + { + return UserContextInterface::USER_TYPE_CUSTOMER; + } +} diff --git a/app/code/Magento/Customer/Model/Plugin/CustomerAuthorization.php b/app/code/Magento/Customer/Model/Plugin/CustomerAuthorization.php new file mode 100644 index 0000000000000..d75d2f4d91e6f --- /dev/null +++ b/app/code/Magento/Customer/Model/Plugin/CustomerAuthorization.php @@ -0,0 +1,79 @@ +userContext = $userContext; + } + + /** + * Check if resource for which access is needed has self permissions defined in webapi config. + * + * @param \Magento\Framework\Authorization $subject + * @param callable $proceed + * @param string $resource + * @param string $privilege + * + * @return bool true If resource permission is self, to allow + * customer access without further checks in parent method + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundIsAllowed( + \Magento\Framework\Authorization $subject, + \Closure $proceed, + $resource, + $privilege = null + ) { + if ($resource == AuthorizationService::PERMISSION_SELF + && $this->userContext->getUserId() + && $this->userContext->getUserType() === UserContextInterface::USER_TYPE_CUSTOMER + ) { + return true; + } else { + return $proceed($resource, $privilege); + } + } +} diff --git a/app/code/Magento/Customer/Model/Resource/Address.php b/app/code/Magento/Customer/Model/Resource/Address.php index 756b65d6fefea..c86f39abb472b 100644 --- a/app/code/Magento/Customer/Model/Resource/Address.php +++ b/app/code/Magento/Customer/Model/Resource/Address.php @@ -25,6 +25,8 @@ */ namespace Magento\Customer\Model\Resource; +use \Magento\Framework\Exception\InputException; + class Address extends \Magento\Eav\Model\Entity\AbstractEntity { /** @@ -140,7 +142,12 @@ protected function _validate($address) $validator = $this->_validatorFactory->createValidator('customer_address', 'save'); if (!$validator->isValid($address)) { - throw new \Magento\Framework\Validator\ValidatorException($validator->getMessages()); + throw new \Magento\Framework\Validator\ValidatorException( + InputException::DEFAULT_MESSAGE, + [], + null, + $validator->getMessages() + ); } } diff --git a/app/code/Magento/Customer/Model/Resource/Customer.php b/app/code/Magento/Customer/Model/Resource/Customer.php index 663754c47e06f..b4e646ba88c82 100644 --- a/app/code/Magento/Customer/Model/Resource/Customer.php +++ b/app/code/Magento/Customer/Model/Resource/Customer.php @@ -23,6 +23,8 @@ */ namespace Magento\Customer\Model\Resource; +use \Magento\Framework\Exception\InputException; + /** * Customer entity resource model */ @@ -174,7 +176,12 @@ protected function _validate($customer) $validator = $this->_validatorFactory->createValidator('customer', 'save'); if (!$validator->isValid($customer)) { - throw new \Magento\Framework\Validator\ValidatorException($validator->getMessages()); + throw new \Magento\Framework\Validator\ValidatorException( + InputException::DEFAULT_MESSAGE, + [], + null, + $validator->getMessages() + ); } } diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php index b98cad217d009..5b847f192ad4a 100755 --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -547,12 +547,11 @@ public function setAfterAuthUrl($url) /** * Reset core session hosts after reseting session ID * - * @param bool $deleteOldSession * @return $this */ - public function regenerateId($deleteOldSession = true) + public function regenerateId() { - parent::regenerateId($deleteOldSession); + parent::regenerateId(); $this->_cleanHosts(); return $this; } diff --git a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php index be9307eff68ca..5a14411d22d21 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerAccountService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerAccountService.php @@ -278,10 +278,10 @@ public function authenticate($username, $password) $this->eventManager->dispatch('customer_login', array('customer' => $customerModel)); - $customerDto = $this->converter->createCustomerFromModel($customerModel); - $this->eventManager->dispatch('customer_data_object_login', array('customer' => $customerDto)); + $customerData = $this->converter->createCustomerFromModel($customerModel); + $this->eventManager->dispatch('customer_data_object_login', array('customer' => $customerData)); - return $customerDto; + return $customerData; } /** diff --git a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php index 1551885f95754..ae79cc3044e33 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php @@ -226,7 +226,7 @@ private function _createMetadataAttribute($attribute) } $validationRules = []; foreach ($attribute->getValidateRules() as $name => $value) { - $validationRules[$name] = $this->_validationRuleBuilder->setName($name) + $validationRules[] = $this->_validationRuleBuilder->setName($name) ->setValue($value) ->create(); } @@ -243,6 +243,7 @@ private function _createMetadataAttribute($attribute) ->setOptions($options) ->setFrontendClass($attribute->getFrontend()->getClass()) ->setFrontendLabel($attribute->getFrontendLabel()) + ->setBackendType($attribute->getBackendType()) ->setNote($attribute->getNote()) ->setIsSystem($attribute->getIsSystem()) ->setIsUserDefined($attribute->getIsUserDefined()) diff --git a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadata.php b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadata.php index c9ba34c2d77d9..4ba3c371fcb15 100644 --- a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadata.php +++ b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadata.php @@ -51,7 +51,7 @@ class AttributeMetadata extends \Magento\Framework\Service\Data\AbstractObject const DATA_MODEL = 'data_model'; - const IS_USER_DEFINED = 'is_user_defined'; + const USER_DEFINED = 'user_defined'; const FRONTEND_CLASS = 'frontend_class'; @@ -59,7 +59,7 @@ class AttributeMetadata extends \Magento\Framework\Service\Data\AbstractObject const FRONTEND_LABEL = 'frontend_label'; - const IS_SYSTEM = 'is_system'; + const SYSTEM = 'system'; const NOTE = 'note'; @@ -184,7 +184,7 @@ public function getFrontendClass() */ public function isUserDefined() { - return $this->_get(self::IS_USER_DEFINED); + return $this->_get(self::USER_DEFINED); } /** @@ -224,7 +224,7 @@ public function getNote() */ public function isSystem() { - return $this->_get(self::IS_SYSTEM); + return $this->_get(self::SYSTEM); } /** diff --git a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php index e45d018fad67e..ef50ab9a124a1 100644 --- a/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Data/Eav/AttributeMetadataBuilder.php @@ -188,7 +188,7 @@ public function setFrontendClass($frontendClass) */ public function setIsUserDefined($isUserDefined) { - return $this->_set(AttributeMetadata::IS_USER_DEFINED, $isUserDefined); + return $this->_set(AttributeMetadata::USER_DEFINED, $isUserDefined); } /** @@ -221,7 +221,7 @@ public function setFrontendLabel($frontendLabel) */ public function setIsSystem($isSystem) { - return $this->_set(AttributeMetadata::IS_SYSTEM, $isSystem); + return $this->_set(AttributeMetadata::SYSTEM, $isSystem); } /** diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json index 020cabb48bc29..883e23e784e9e 100644 --- a/app/code/Magento/Customer/composer.json +++ b/app/code/Magento/Customer/composer.json @@ -2,28 +2,30 @@ "name": "magento/module-customer", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-newsletter": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/module-log": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-review": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-page-cache": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-newsletter": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/module-log": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-review": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-page-cache": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", + "magento/module-authorization": "0.1.0-alpha90", + "magento/module-integration": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Customer/etc/adminhtml/acl.xml b/app/code/Magento/Customer/etc/acl.xml similarity index 95% rename from app/code/Magento/Customer/etc/adminhtml/acl.xml rename to app/code/Magento/Customer/etc/acl.xml index 392c11a835982..0544b9cd0e614 100644 --- a/app/code/Magento/Customer/etc/adminhtml/acl.xml +++ b/app/code/Magento/Customer/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 186380578ca14..f84399e87a6a7 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -68,7 +68,7 @@ - + diff --git a/app/code/Magento/Customer/etc/module.xml b/app/code/Magento/Customer/etc/module.xml index 91d05a2966cf1..57366ea6e061a 100644 --- a/app/code/Magento/Customer/etc/module.xml +++ b/app/code/Magento/Customer/etc/module.xml @@ -30,6 +30,7 @@ + @@ -46,6 +47,7 @@ + diff --git a/app/code/Magento/Customer/etc/webapi.xml b/app/code/Magento/Customer/etc/webapi.xml index 2d2179ffa7a68..842e90b8f0445 100644 --- a/app/code/Magento/Customer/etc/webapi.xml +++ b/app/code/Magento/Customer/etc/webapi.xml @@ -161,7 +161,7 @@ - null + %customer_id% diff --git a/app/code/Magento/Customer/etc/webapi_rest/di.xml b/app/code/Magento/Customer/etc/webapi_rest/di.xml new file mode 100644 index 0000000000000..8eb5b6d92bad5 --- /dev/null +++ b/app/code/Magento/Customer/etc/webapi_rest/di.xml @@ -0,0 +1,45 @@ + + + + + + + + + frontend + + + + + + + Magento\Customer\Model\Authorization\CustomerSessionUserContext + 20 + + + + + diff --git a/app/code/Magento/Authz/etc/adminhtml/di.xml b/app/code/Magento/Customer/etc/webapi_soap/di.xml similarity index 86% rename from app/code/Magento/Authz/etc/adminhtml/di.xml rename to app/code/Magento/Customer/etc/webapi_soap/di.xml index d4a583c57f7a1..2b574a8f2377a 100644 --- a/app/code/Magento/Authz/etc/adminhtml/di.xml +++ b/app/code/Magento/Customer/etc/webapi_soap/di.xml @@ -24,5 +24,7 @@ */ --> - + + + diff --git a/app/code/Magento/Customer/view/frontend/templates/account/customer.phtml b/app/code/Magento/Customer/view/frontend/templates/account/customer.phtml index d4be822c8c8dd..81f3c80517d47 100644 --- a/app/code/Magento/Customer/view/frontend/templates/account/customer.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/account/customer.phtml @@ -23,13 +23,13 @@ */ ?> customerLoggedIn()): ?> -
  • +
  • getCustomerName(); ?> getChildHtml()):?> -
  • - + init($_item, 'product_comparison_list')->toHtml() ?> - + productAttribute($_item, $_item->getName(), 'name') ?> getReviewsSummaryHtml($_item, 'short') ?> getProductPrice($_item, '-compare-list-top') ?> -
    -
    +
    +
    isSaleable()): ?>
    helper('Magento\Wishlist\Helper\Data')->isAllow()) : ?> -
    escapeHtml($this->getProductName()) ?> + escapeHtml($this->getProductName()) ?> getOptionList()):?>
    @@ -54,7 +54,7 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data');
    + helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> @@ -138,9 +138,9 @@ $_weeeHelper = $this->helper('Magento\Weee\Helper\Data'); getQty() ?>getQty() ?> + helper('Magento\Weee\Helper\Data')->typeOfDisplay(array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js index 3cbfea4d16992..5b5dfcf568ba1 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js @@ -44,6 +44,7 @@ define([ registerCustomerPasswordSelector: '#co-billing-form .field.password,#co-billing-form .field.confirm', suggestRegistration: false }, + pageMessages: '#maincontent .messages .message', sectionSelectorPrefix: 'opc-', billingSection: 'billing', ajaxLoaderPlaceButton: false, @@ -174,6 +175,9 @@ define([ loginRegister = $( checkout.loginRegisterSelector )[0], method = 'register', action = 'show'; + + //Remove page messages + $(this.options.pageMessages).remove(); if (json.isGuestCheckoutAllowed) { @@ -288,5 +292,4 @@ define([ } } }); - }); diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json index e7721e204233a..53612c3a15a99 100644 --- a/app/code/Magento/CheckoutAgreements/composer.json +++ b/app/code/Magento/CheckoutAgreements/composer.json @@ -2,15 +2,15 @@ "name": "magento/module-checkout-agreements", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/CheckoutAgreements/etc/adminhtml/acl.xml b/app/code/Magento/CheckoutAgreements/etc/acl.xml similarity index 93% rename from app/code/Magento/CheckoutAgreements/etc/adminhtml/acl.xml rename to app/code/Magento/CheckoutAgreements/etc/acl.xml index b51f0fe9565ca..5bedc875cd001 100644 --- a/app/code/Magento/CheckoutAgreements/etc/adminhtml/acl.xml +++ b/app/code/Magento/CheckoutAgreements/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index 94f9e1f5d553c..04e668fb805eb 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-cms", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-email": "0.1.0-alpha89", - "magento/module-install": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-email": "0.1.0-alpha90", + "magento/module-install": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php b/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php index e01cc7508ba85..2ad56df0bea7e 100644 --- a/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php +++ b/app/code/Magento/Cms/data/cms_setup/data-upgrade-1.6.0.0.0-1.6.0.0.1.php @@ -202,14 +202,6 @@ PERSISTENT_SHOPPING_CART A link to information about your cart and viewing history if you have asked the site.
    POLLThe ID of any polls you have recently voted in.
    POLLNInformation on what polls you have voted on.
    RECENTLYCOMPARED The items that you have recently compared.
    diff --git a/app/code/Magento/Eav/composer.json b/app/code/Magento/Eav/composer.json index 650b3fa8db6bd..4ff54743f5838 100644 --- a/app/code/Magento/Eav/composer.json +++ b/app/code/Magento/Eav/composer.json @@ -2,16 +2,16 @@ "name": "magento/module-eav", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index 3f8c783a0bf51..1f01b6d4c0d69 100644 --- a/app/code/Magento/Email/composer.json +++ b/app/code/Magento/Email/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-email", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Email/etc/adminhtml/acl.xml b/app/code/Magento/Email/etc/acl.xml similarity index 93% rename from app/code/Magento/Email/etc/adminhtml/acl.xml rename to app/code/Magento/Email/etc/acl.xml index 46699dfcc8fee..39c597eb28d92 100644 --- a/app/code/Magento/Email/etc/adminhtml/acl.xml +++ b/app/code/Magento/Email/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 10a02701ac657..1daa81c68b192 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -62,6 +62,22 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C */ protected $_code = self::CODE; + /** + * Types of rates, order is important + * + * @var array + */ + protected $_ratesOrder = [ + 'RATED_ACCOUNT_PACKAGE', + 'PAYOR_ACCOUNT_PACKAGE', + 'RATED_ACCOUNT_SHIPMENT', + 'PAYOR_ACCOUNT_SHIPMENT', + 'RATED_LIST_PACKAGE', + 'PAYOR_LIST_PACKAGE', + 'RATED_LIST_SHIPMENT', + 'PAYOR_LIST_SHIPMENT' + ]; + /** * Rate request data * @@ -585,8 +601,7 @@ protected function _getRateAmountOriginBased($rate) $rateTypeAmounts[$rateType] = $netAmount; } - // Order is important - foreach (array('RATED_ACCOUNT_SHIPMENT', 'RATED_LIST_SHIPMENT', 'RATED_LIST_PACKAGE') as $rateType) { + foreach ($this->_ratesOrder as $rateType) { if (!empty($rateTypeAmounts[$rateType])) { $amount = $rateTypeAmounts[$rateType]; break; diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 9c13f7eb7d88a..462b906d62026 100644 --- a/app/code/Magento/Fedex/composer.json +++ b/app/code/Magento/Fedex/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-fedex", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index d48fce67defd6..1b7228317bb77 100644 --- a/app/code/Magento/GiftMessage/composer.json +++ b/app/code/Magento/GiftMessage/composer.json @@ -2,21 +2,21 @@ "name": "magento/module-gift-message", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-multishipping": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-multishipping": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAdwords/composer.json b/app/code/Magento/GoogleAdwords/composer.json index 5fc47874f0d9f..d6f7e5d6a8e8c 100644 --- a/app/code/Magento/GoogleAdwords/composer.json +++ b/app/code/Magento/GoogleAdwords/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-google-adwords", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAnalytics/composer.json b/app/code/Magento/GoogleAnalytics/composer.json index 5cb9bc78c2587..4919131005d3a 100644 --- a/app/code/Magento/GoogleAnalytics/composer.json +++ b/app/code/Magento/GoogleAnalytics/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-google-analytics", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleAnalytics/etc/adminhtml/acl.xml b/app/code/Magento/GoogleAnalytics/etc/acl.xml similarity index 94% rename from app/code/Magento/GoogleAnalytics/etc/adminhtml/acl.xml rename to app/code/Magento/GoogleAnalytics/etc/acl.xml index 7354a089cf21e..4107ab44caa7e 100644 --- a/app/code/Magento/GoogleAnalytics/etc/adminhtml/acl.xml +++ b/app/code/Magento/GoogleAnalytics/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/GoogleOptimizer/composer.json b/app/code/Magento/GoogleOptimizer/composer.json index 094f6b1f9dcd6..c4caba7bbb770 100644 --- a/app/code/Magento/GoogleOptimizer/composer.json +++ b/app/code/Magento/GoogleOptimizer/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-google-optimizer", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-google-analytics": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-google-analytics": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php index 512f6b69ab884..74e74bb29299d 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php @@ -23,6 +23,9 @@ */ namespace Magento\GoogleShopping\Controller\Adminhtml\Googleshopping; +use \Magento\Framework\Notification\NotifierInterface; +use \Magento\Backend\App\Action; + /** * GoogleShopping Admin Items Controller * @@ -31,6 +34,20 @@ */ class Items extends \Magento\Backend\App\Action { + /** + * @var NotifierInterface + */ + protected $notifier; + + /** + * @param \Magento\Backend\App\Action\Context $context + * @param NotifierInterface $notifier + */ + public function __construct(Action\Context $context, NotifierInterface $notifier) + { + parent::__construct($context); + $this->notifier = $notifier; + } /** * Retrieve synchronization process mutex diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAdd.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAdd.php index 0b8245af5f0ca..d3030a4e92e14 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAdd.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/MassAdd.php @@ -44,7 +44,6 @@ public function execute() $storeId = $this->_getStore()->getId(); $productIds = $this->getRequest()->getParam('product', null); - $notifier = $this->_objectManager->create('Magento\AdminNotification\Model\Inbox'); try { $flag->lock(); @@ -64,7 +63,7 @@ public function execute() return; } catch (\Exception $e) { $flag->unlock(); - $notifier->addMajor( + $this->notifier->addMajor( __('An error has occurred while adding products to google shopping account.'), $e->getMessage() ); diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Refresh.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Refresh.php index bb294d6af1e3c..2e6514c7b19e5 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Refresh.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items/Refresh.php @@ -68,9 +68,7 @@ public function execute() return; } catch (\Exception $e) { $flag->unlock(); - $this->_objectManager->create( - 'Magento\AdminNotification\Model\Inbox' - )->addMajor( + $this->notifier->addMajor( __('An error has occurred while deleting products from google shopping account.'), __( 'One or more products were not deleted from google shopping account. Refer to the log file for details.' diff --git a/app/code/Magento/GoogleShopping/Model/MassOperations.php b/app/code/Magento/GoogleShopping/Model/MassOperations.php index 8cf0e940823cd..180aa443eeec6 100644 --- a/app/code/Magento/GoogleShopping/Model/MassOperations.php +++ b/app/code/Magento/GoogleShopping/Model/MassOperations.php @@ -69,11 +69,11 @@ class MassOperations protected $_productFactory; /** - * Inbox factory + * Notifier * - * @var \Magento\AdminNotification\Model\InboxFactory + * @var \Magento\Framework\Notification\NotifierInterface */ - protected $_inboxFactory; + protected $_notifier; /** * Collection factory @@ -86,7 +86,7 @@ class MassOperations * @param \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory * @param \Magento\GoogleShopping\Model\ItemFactory $itemFactory * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\AdminNotification\Model\InboxFactory $inboxFactory + * @param \Magento\Framework\Notification\NotifierInterface $notifier * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Logger $logger * @param \Magento\GoogleShopping\Helper\Data $gleShoppingData @@ -97,7 +97,7 @@ public function __construct( \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory, \Magento\GoogleShopping\Model\ItemFactory $itemFactory, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\AdminNotification\Model\InboxFactory $inboxFactory, + \Magento\Framework\Notification\NotifierInterface $notifier, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Logger $logger, \Magento\GoogleShopping\Helper\Data $gleShoppingData, @@ -107,7 +107,7 @@ public function __construct( $this->_collectionFactory = $collectionFactory; $this->_itemFactory = $itemFactory; $this->_productFactory = $productFactory; - $this->_inboxFactory = $inboxFactory; + $this->_notifier = $notifier; $this->_storeManager = $storeManager; $this->_gleShoppingData = $gleShoppingData; $this->_gleShoppingCategory = $gleShoppingCategory; @@ -211,18 +211,18 @@ public function addProducts($productIds, $storeId) } if ($totalAdded > 0) { - $this->_getNotifier()->addNotice( + $this->_notifier->addNotice( __('Products were added to Google Shopping account.'), __('A total of %1 product(s) have been added to Google Content.', $totalAdded) ); } if (count($errors)) { - $this->_getNotifier()->addMajor(__('Errors happened while adding products to Google Shopping.'), $errors); + $this->_notifier->addMajor(__('Errors happened while adding products to Google Shopping.'), $errors); } if ($this->_flag->isExpired()) { - $this->_getNotifier()->addMajor( + $this->_notifier->addMajor( __('Operation of adding products to Google Shopping expired.'), __('Some products may have not been added to Google Shopping bacause of expiration') ); @@ -298,7 +298,7 @@ public function synchronizeItems($items) return $this; } - $this->_getNotifier()->addNotice( + $this->_notifier->addNotice( __('Product synchronization with Google Shopping completed'), __( 'A total of %1 items(s) have been deleted; a total of %2 items(s) have been updated.', @@ -308,7 +308,7 @@ public function synchronizeItems($items) ); if ($totalFailed > 0 || count($errors)) { array_unshift($errors, __("We cannot update %1 items.", $totalFailed)); - $this->_getNotifier()->addMajor( + $this->_notifier->addMajor( __('Errors happened during synchronization with Google Shopping'), $errors ); @@ -359,13 +359,13 @@ public function deleteItems($items) } if ($totalDeleted > 0) { - $this->_getNotifier()->addNotice( + $this->_notifier->addNotice( __('Google Shopping item removal process succeded'), __('Total of %1 items(s) have been removed from Google Shopping.', $totalDeleted) ); } if (count($errors)) { - $this->_getNotifier()->addMajor(__('Errors happened while deleting items from Google Shopping'), $errors); + $this->_notifier->addMajor(__('Errors happened while deleting items from Google Shopping'), $errors); } return $this; @@ -390,16 +390,6 @@ protected function _getItemsCollection($items) return $itemsCollection; } - /** - * Retrieve admin notifier - * - * @return \Magento\AdminNotification\Model\Inbox - */ - protected function _getNotifier() - { - return $this->_inboxFactory->create(); - } - /** * Provides general error information * @@ -408,7 +398,7 @@ protected function _getNotifier() protected function _addGeneralError() { if (!$this->_hasError) { - $this->_getNotifier()->addMajor(__('Google Shopping Error'), $this->_gleShoppingCategory->getMessage()); + $this->_notifier->addMajor(__('Google Shopping Error'), $this->_gleShoppingCategory->getMessage()); $this->_hasError = true; } } diff --git a/app/code/Magento/GoogleShopping/Model/Observer.php b/app/code/Magento/GoogleShopping/Model/Observer.php index 83dd68d6432e3..4eafd2d0704cf 100644 --- a/app/code/Magento/GoogleShopping/Model/Observer.php +++ b/app/code/Magento/GoogleShopping/Model/Observer.php @@ -55,11 +55,11 @@ class Observer protected $_operationsFactory; /** - * Inbox factory + * Notifier * - * @var \Magento\AdminNotification\Model\InboxFactory + * @var \Magento\Framework\Notification\NotifierInterface */ - protected $_inboxFactory; + protected $_notifier; /** * Collection factory @@ -71,7 +71,7 @@ class Observer /** * @param \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory * @param \Magento\GoogleShopping\Model\MassOperationsFactory $operationsFactory - * @param \Magento\AdminNotification\Model\InboxFactory $inboxFactory + * @param \Magento\Framework\Notification\NotifierInterface $notifier * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param \Magento\GoogleShopping\Model\Flag $flag @@ -79,14 +79,14 @@ class Observer public function __construct( \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory, \Magento\GoogleShopping\Model\MassOperationsFactory $operationsFactory, - \Magento\AdminNotification\Model\InboxFactory $inboxFactory, + \Magento\Framework\Notification\NotifierInterface $notifier, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\GoogleShopping\Model\Flag $flag ) { $this->_collectionFactory = $collectionFactory; $this->_operationsFactory = $operationsFactory; - $this->_inboxFactory = $inboxFactory; + $this->_notifier = $notifier; $this->_scopeConfig = $scopeConfig; $this->messageManager = $messageManager; $this->_flag = $flag; @@ -146,7 +146,12 @@ protected function _getItemsCollection($product) } foreach ($items as $item) { - if (!$this->_scopeConfig->isSetFlag('google/googleshopping/observed', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $item->getStoreId())) { + $flag = $this->_scopeConfig->isSetFlag( + 'google/googleshopping/observed', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $item->getStoreId() + ); + if (!$flag) { $items->removeItemByKey($item->getId()); } } @@ -164,7 +169,7 @@ public function checkSynchronizationOperations(\Magento\Framework\Event\Observer { $this->_flag->loadSelf(); if ($this->_flag->isExpired()) { - $this->_inboxFactory->create()->addMajor( + $this->_notifier->addMajor( __('Google Shopping operation has expired.'), __('One or more google shopping synchronization operations failed because of timeout.') ); diff --git a/app/code/Magento/GoogleShopping/composer.json b/app/code/Magento/GoogleShopping/composer.json index 1714fabb5098e..5fc87f04a43f2 100644 --- a/app/code/Magento/GoogleShopping/composer.json +++ b/app/code/Magento/GoogleShopping/composer.json @@ -2,22 +2,21 @@ "name": "magento/module-google-shopping", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/GoogleShopping/etc/adminhtml/acl.xml b/app/code/Magento/GoogleShopping/etc/acl.xml similarity index 94% rename from app/code/Magento/GoogleShopping/etc/adminhtml/acl.xml rename to app/code/Magento/GoogleShopping/etc/acl.xml index 965d797ebb1af..0a8c2e4245cf4 100644 --- a/app/code/Magento/GoogleShopping/etc/adminhtml/acl.xml +++ b/app/code/Magento/GoogleShopping/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/GoogleShopping/etc/module.xml b/app/code/Magento/GoogleShopping/etc/module.xml index e7a52ba4ee9d9..89c6286283da0 100644 --- a/app/code/Magento/GoogleShopping/etc/module.xml +++ b/app/code/Magento/GoogleShopping/etc/module.xml @@ -30,7 +30,6 @@ - diff --git a/app/code/Magento/GroupedImportExport/Model/Export/Product/Type/Grouped.php b/app/code/Magento/GroupedImportExport/Model/Export/Product/Type/Grouped.php new file mode 100644 index 0000000000000..1f8478909aa5f --- /dev/null +++ b/app/code/Magento/GroupedImportExport/Model/Export/Product/Type/Grouped.php @@ -0,0 +1,30 @@ + + + + + + + Magento\GroupedImportExport\Model\Export\RowCustomizer + + + + diff --git a/app/code/Magento/GroupedImportExport/etc/export.xml b/app/code/Magento/GroupedImportExport/etc/export.xml new file mode 100644 index 0000000000000..c29cda67913dc --- /dev/null +++ b/app/code/Magento/GroupedImportExport/etc/export.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/app/code/Magento/GroupedImportExport/etc/import.xml b/app/code/Magento/GroupedImportExport/etc/import.xml new file mode 100644 index 0000000000000..20251196082f6 --- /dev/null +++ b/app/code/Magento/GroupedImportExport/etc/import.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/app/code/Magento/GroupedImportExport/etc/module.xml b/app/code/Magento/GroupedImportExport/etc/module.xml new file mode 100644 index 0000000000000..27708b2a0323c --- /dev/null +++ b/app/code/Magento/GroupedImportExport/etc/module.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + diff --git a/app/code/Magento/GroupedProduct/composer.json b/app/code/Magento/GroupedProduct/composer.json index 65984cf03f57c..cf8b138e08efe 100644 --- a/app/code/Magento/GroupedProduct/composer.json +++ b/app/code/Magento/GroupedProduct/composer.json @@ -2,23 +2,23 @@ "name": "magento/module-grouped-product", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/ImportExport/composer.json b/app/code/Magento/ImportExport/composer.json index 004eb3554d516..3b83b03847620 100644 --- a/app/code/Magento/ImportExport/composer.json +++ b/app/code/Magento/ImportExport/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-import-export", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "ext-ctype": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/ImportExport/etc/adminhtml/acl.xml b/app/code/Magento/ImportExport/etc/acl.xml similarity index 94% rename from app/code/Magento/ImportExport/etc/adminhtml/acl.xml rename to app/code/Magento/ImportExport/etc/acl.xml index 21a4534e03b3c..1ea1488aedc1d 100644 --- a/app/code/Magento/ImportExport/etc/adminhtml/acl.xml +++ b/app/code/Magento/ImportExport/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Index/Model/System/Message/IndexOutdated.php b/app/code/Magento/Index/Model/System/Message/IndexOutdated.php index a5a46aa6bd080..a25fc378e5605 100644 --- a/app/code/Magento/Index/Model/System/Message/IndexOutdated.php +++ b/app/code/Magento/Index/Model/System/Message/IndexOutdated.php @@ -17,13 +17,13 @@ * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. - * + * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace Magento\Index\Model\System\Message; -class IndexOutdated implements \Magento\AdminNotification\Model\System\MessageInterface +class IndexOutdated implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Index\Model\Indexer diff --git a/app/code/Magento/Index/composer.json b/app/code/Magento/Index/composer.json index 4d5201a449caf..fcf3e916598bb 100644 --- a/app/code/Magento/Index/composer.json +++ b/app/code/Magento/Index/composer.json @@ -2,15 +2,14 @@ "name": "magento/module-index", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Index/etc/adminhtml/acl.xml b/app/code/Magento/Index/etc/acl.xml similarity index 93% rename from app/code/Magento/Index/etc/adminhtml/acl.xml rename to app/code/Magento/Index/etc/acl.xml index 3c2f0f4925083..915fc10d066e0 100644 --- a/app/code/Magento/Index/etc/adminhtml/acl.xml +++ b/app/code/Magento/Index/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Index/etc/adminhtml/di.xml b/app/code/Magento/Index/etc/adminhtml/di.xml index 8ec4ff4eadd2c..5805634b012d4 100644 --- a/app/code/Magento/Index/etc/adminhtml/di.xml +++ b/app/code/Magento/Index/etc/adminhtml/di.xml @@ -24,7 +24,7 @@ */ --> - + Magento\Index\Model\System\Message\IndexOutdated diff --git a/app/code/Magento/Index/etc/module.xml b/app/code/Magento/Index/etc/module.xml index 8ff8a9e206d54..92b3bfd022cbe 100644 --- a/app/code/Magento/Index/etc/module.xml +++ b/app/code/Magento/Index/etc/module.xml @@ -32,7 +32,6 @@ - diff --git a/app/code/Magento/Indexer/composer.json b/app/code/Magento/Indexer/composer.json index 71272f04ac08d..4409860e4a068 100644 --- a/app/code/Magento/Indexer/composer.json +++ b/app/code/Magento/Indexer/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-indexer", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-page-cache": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-page-cache": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Indexer/etc/adminhtml/acl.xml b/app/code/Magento/Indexer/etc/acl.xml similarity index 94% rename from app/code/Magento/Indexer/etc/adminhtml/acl.xml rename to app/code/Magento/Indexer/etc/acl.xml index 43be5a630531e..ecc2b372817d9 100644 --- a/app/code/Magento/Indexer/etc/adminhtml/acl.xml +++ b/app/code/Magento/Indexer/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Install/Block/End.php b/app/code/Magento/Install/Block/End.php index 012870dabd884..75d895086e988 100644 --- a/app/code/Magento/Install/Block/End.php +++ b/app/code/Magento/Install/Block/End.php @@ -24,8 +24,6 @@ /** * Installation ending block - * - * @author Magento Core Team */ namespace Magento\Install\Block; @@ -37,7 +35,7 @@ class End extends \Magento\Install\Block\AbstractBlock protected $_template = 'end.phtml'; /** - * @var \Magento\AdminNotification\Model\Survey + * @var \Magento\Install\Model\Survey */ protected $_survey; @@ -53,7 +51,7 @@ class End extends \Magento\Install\Block\AbstractBlock * @param \Magento\Install\Model\Installer $installer * @param \Magento\Install\Model\Wizard $installWizard * @param \Magento\Framework\Session\Generic $session - * @param \Magento\AdminNotification\Model\Survey $survey + * @param \Magento\Install\Model\Survey $survey * @param string $cryptKey * @param array $data */ @@ -62,7 +60,7 @@ public function __construct( \Magento\Install\Model\Installer $installer, \Magento\Install\Model\Wizard $installWizard, \Magento\Framework\Session\Generic $session, - \Magento\AdminNotification\Model\Survey $survey, + \Magento\Install\Model\Survey $survey, $cryptKey, array $data = array() ) { diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Survey.php b/app/code/Magento/Install/Controller/Adminhtml/Survey.php similarity index 90% rename from app/code/Magento/AdminNotification/Controller/Adminhtml/Survey.php rename to app/code/Magento/Install/Controller/Adminhtml/Survey.php index e7650a90e5a9e..5358b053e9d2f 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Survey.php +++ b/app/code/Magento/Install/Controller/Adminhtml/Survey.php @@ -21,12 +21,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\AdminNotification\Controller\Adminhtml; +namespace Magento\Install\Controller\Adminhtml; /** * Adminhtml Survey Action - * - * @author Magento Core Team */ class Survey extends \Magento\Backend\App\Action { diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Survey/Index.php b/app/code/Magento/Install/Controller/Adminhtml/Survey/Index.php similarity index 83% rename from app/code/Magento/AdminNotification/Controller/Adminhtml/Survey/Index.php rename to app/code/Magento/Install/Controller/Adminhtml/Survey/Index.php index 98caa51c392c1..69fb6a58c2b68 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Survey/Index.php +++ b/app/code/Magento/Install/Controller/Adminhtml/Survey/Index.php @@ -22,9 +22,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\AdminNotification\Controller\Adminhtml\Survey; +namespace Magento\Install\Controller\Adminhtml\Survey; -class Index extends \Magento\AdminNotification\Controller\Adminhtml\Survey +class Index extends \Magento\Install\Controller\Adminhtml\Survey { /** * Index Action @@ -34,7 +34,7 @@ class Index extends \Magento\AdminNotification\Controller\Adminhtml\Survey public function execute() { if ($this->getRequest()->getParam('isAjax', false)) { - $this->_objectManager->get('Magento\AdminNotification\Model\Survey')->saveSurveyViewed(true); + $this->_objectManager->get('Magento\Install\Model\Survey')->saveSurveyViewed(true); } $this->getResponse()->representJson(\Zend_Json::encode(array('survey_decision_saved' => 1))); } diff --git a/app/code/Magento/Install/Controller/Wizard/End.php b/app/code/Magento/Install/Controller/Wizard/End.php index dfd9c13d944c2..ce9238c03484c 100644 --- a/app/code/Magento/Install/Controller/Wizard/End.php +++ b/app/code/Magento/Install/Controller/Wizard/End.php @@ -42,7 +42,7 @@ public function execute() $this->_getInstaller()->finish(); - $this->_objectManager->get('Magento\AdminNotification\Model\Survey')->saveSurveyViewed(true); + $this->_objectManager->get('Magento\Install\Model\Survey')->saveSurveyViewed(true); $this->_prepareLayout(); $this->_view->getLayout()->initMessages(); diff --git a/app/code/Magento/AdminNotification/Model/Survey.php b/app/code/Magento/Install/Model/Survey.php similarity index 94% rename from app/code/Magento/AdminNotification/Model/Survey.php rename to app/code/Magento/Install/Model/Survey.php index 1b061be7a1dca..1278e3938f4b2 100644 --- a/app/code/Magento/AdminNotification/Model/Survey.php +++ b/app/code/Magento/Install/Model/Survey.php @@ -24,11 +24,9 @@ /** - * AdminNotification survey model - * - * @author Magento Core Team + * Installation survey model */ -namespace Magento\AdminNotification\Model; +namespace Magento\Install\Model; class Survey { @@ -37,7 +35,7 @@ class Survey /** * @var string */ - protected $_flagCode = 'admin_notification_survey'; + protected $_flagCode = 'install_survey'; /** * @var \Magento\Framework\Flag diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Survey.php b/app/code/Magento/Install/Model/System/Message/Survey.php similarity index 87% rename from app/code/Magento/AdminNotification/Model/System/Message/Survey.php rename to app/code/Magento/Install/Model/System/Message/Survey.php index e2aad4101909c..3d516ed61c2a1 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Survey.php +++ b/app/code/Magento/Install/Model/System/Message/Survey.php @@ -21,9 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\AdminNotification\Model\System\Message; +namespace Magento\Install\Model\System\Message; -class Survey implements \Magento\AdminNotification\Model\System\MessageInterface +class Survey implements \Magento\Framework\Notification\MessageInterface { /** * @var \Magento\Backend\Model\Auth\Session @@ -41,7 +41,7 @@ class Survey implements \Magento\AdminNotification\Model\System\MessageInterface protected $_urlBuilder; /** - * @var \Magento\AdminNotification\Model\Survey + * @var \Magento\Install\Model\Survey */ protected $_survey; @@ -49,13 +49,13 @@ class Survey implements \Magento\AdminNotification\Model\System\MessageInterface * @param \Magento\Backend\Model\Auth\Session $authSession * @param \Magento\Framework\AuthorizationInterface $authorization * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\AdminNotification\Model\Survey $survey + * @param \Magento\Install\Model\Survey $survey */ public function __construct( \Magento\Backend\Model\Auth\Session $authSession, \Magento\Framework\AuthorizationInterface $authorization, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\AdminNotification\Model\Survey $survey + \Magento\Install\Model\Survey $survey ) { $this->_authorization = $authorization; $this->_authSession = $authSession; @@ -118,7 +118,7 @@ public function getText() ) ); return __( - 'We appreciate our merchants\' feedback. Please take our survey and tell us about features you\'d like to see in Magento.', + 'We appreciate our merchants\' feedback. Please take our survey and tell us about features you\'d like to see in Magento.', json_encode($params, JSON_FORCE_OBJECT) ); } @@ -130,6 +130,6 @@ public function getText() */ public function getSeverity() { - return \Magento\AdminNotification\Model\System\MessageInterface::SEVERITY_MAJOR; + return \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR; } } diff --git a/app/code/Magento/Install/composer.json b/app/code/Magento/Install/composer.json index fc8c08ee1d03b..37ae0241420a8 100644 --- a/app/code/Magento/Install/composer.json +++ b/app/code/Magento/Install/composer.json @@ -2,18 +2,17 @@ "name": "magento/module-install", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-admin-notification": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-user": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-user": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Install/etc/adminhtml/routes.xml b/app/code/Magento/Install/etc/adminhtml/routes.xml new file mode 100644 index 0000000000000..6561687d7773f --- /dev/null +++ b/app/code/Magento/Install/etc/adminhtml/routes.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/app/code/Magento/Install/etc/di.xml b/app/code/Magento/Install/etc/di.xml index 5978523573d55..c502e62e5a7ad 100644 --- a/app/code/Magento/Install/etc/di.xml +++ b/app/code/Magento/Install/etc/di.xml @@ -36,6 +36,13 @@ Magento\Install\Model\Session\Storage + + + + Magento\Install\Model\System\Message\Survey + + + LICENSE.html diff --git a/app/code/Magento/Install/etc/module.xml b/app/code/Magento/Install/etc/module.xml index bb2fd20c81ddc..64f361175393f 100644 --- a/app/code/Magento/Install/etc/module.xml +++ b/app/code/Magento/Install/etc/module.xml @@ -31,7 +31,6 @@ - diff --git a/app/code/Magento/Install/view/adminhtml/layout/default.xml b/app/code/Magento/Install/view/adminhtml/layout/default.xml new file mode 100644 index 0000000000000..4eb246a43bf1f --- /dev/null +++ b/app/code/Magento/Install/view/adminhtml/layout/default.xml @@ -0,0 +1,34 @@ + + + + + + + Magento_Install::survey_notification.js + + + + diff --git a/app/code/Magento/Install/view/adminhtml/web/survey_notification.js b/app/code/Magento/Install/view/adminhtml/web/survey_notification.js new file mode 100644 index 0000000000000..c008c47217a2d --- /dev/null +++ b/app/code/Magento/Install/view/adminhtml/web/survey_notification.js @@ -0,0 +1,41 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +/*jshint jquery:true*/ +require(["jquery"], function($){ + "use strict"; + + $(document).ready(function(){ + $('body').on('surveyYes surveyNo', function(e, data) { + if (e.type == 'surveyYes') { + var win = window.open(data.surveyUrl, '', 'width=900,height=600,resizable=1,scrollbars=1'); + win.focus(); + } + $.ajax({ + url: data.surveyAction, + type: 'post', + data: {decision: data.decision} + }); + }); + }); + +}); diff --git a/app/code/Magento/Integration/Block/Adminhtml/Integration/Tokens.php b/app/code/Magento/Integration/Block/Adminhtml/Integration/Tokens.php index a18d4416e1e42..fc65d977e6ad6 100644 --- a/app/code/Magento/Integration/Block/Adminhtml/Integration/Tokens.php +++ b/app/code/Magento/Integration/Block/Adminhtml/Integration/Tokens.php @@ -33,16 +33,12 @@ class Tokens extends \Magento\Backend\Block\Widget\Form\Generic { /**#@+ - * Form elements names. + * Form element name. */ const DATA_TOKEN = 'token'; - const DATA_TOKEN_SECRET = 'token_secret'; - const DATA_CONSUMER_KEY = 'consumer_key'; - const DATA_CONSUMER_SECRET = 'consumer_secret'; - /**#@-*/ /** diff --git a/app/code/Magento/Integration/Controller/Adminhtml/Integration/TokensExchange.php b/app/code/Magento/Integration/Controller/Adminhtml/Integration/TokensExchange.php index 6c68fd46dfd4a..978d7394e6bbb 100644 --- a/app/code/Magento/Integration/Controller/Adminhtml/Integration/TokensExchange.php +++ b/app/code/Magento/Integration/Controller/Adminhtml/Integration/TokensExchange.php @@ -60,7 +60,7 @@ public function execute() $integration = $this->_integrationService->get($integrationId); if ($isReauthorize) { /** Remove existing token associated with consumer before issuing a new one. */ - $this->_oauthService->deleteToken($integration->getConsumerId()); + $this->_oauthService->deleteIntegrationToken($integration->getConsumerId()); $integration->setStatus(IntegrationModel::STATUS_INACTIVE)->save(); } //Integration chooses to use Oauth for token exchange diff --git a/app/code/Magento/Integration/Model/Integration.php b/app/code/Magento/Integration/Model/Integration.php index 03df47f4b4032..4daefc25f71bd 100644 --- a/app/code/Magento/Integration/Model/Integration.php +++ b/app/code/Magento/Integration/Model/Integration.php @@ -43,6 +43,7 @@ * @method Integration setCreatedAt(\string $createdAt) * @method \string getUpdatedAt() * @method Integration setUpdatedAt(\string $createdAt) + * @method \Magento\Integration\Model\Resource\Integration getResource() */ class Integration extends \Magento\Framework\Model\AbstractModel { @@ -147,6 +148,19 @@ public function loadByConsumerId($consumerId) return $this->load($consumerId, self::CONSUMER_ID); } + /** + * Load active integration by oAuth consumer ID. + * + * @param int $consumerId + * @return $this + */ + public function loadActiveIntegrationByConsumerId($consumerId) + { + $integrationData = $this->getResource()->selectActiveIntegrationByConsumerId($consumerId); + $this->setData($integrationData ? $integrationData : []); + return $this; + } + /** * Get integration status. Cast to the type of STATUS_* constants in order to make strict comparison valid. * diff --git a/app/code/Magento/Integration/Model/Oauth/Token.php b/app/code/Magento/Integration/Model/Oauth/Token.php index 67f2a3632d417..1d692ba2c6569 100644 --- a/app/code/Magento/Integration/Model/Oauth/Token.php +++ b/app/code/Magento/Integration/Model/Oauth/Token.php @@ -23,6 +23,7 @@ */ namespace Magento\Integration\Model\Oauth; +use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\Oauth\Helper\Oauth as OauthHelper; use Magento\Integration\Model\Resource\Oauth\Token\Collection as TokenCollection; use Magento\Framework\Oauth\Exception as OauthException; @@ -41,6 +42,8 @@ * @method Token setAdminId() setAdminId(int $adminId) * @method int getCustomerId() * @method Token setCustomerId() setCustomerId(int $customerId) + * @method int getUserType() + * @method Token setUserType() setUserType(int $userType) * @method string getType() * @method Token setType() setType(string $type) * @method string getCallbackUrl() @@ -70,15 +73,6 @@ class Token extends \Magento\Framework\Model\AbstractModel /**#@- */ - /**#@+ - * Customer types - */ - const USER_TYPE_ADMIN = 'admin'; - - const USER_TYPE_CUSTOMER = 'customer'; - - /**#@- */ - /** * @var OauthHelper */ @@ -191,65 +185,52 @@ public function createVerifierToken($consumerId) 'token' => $this->_oauthHelper->generateToken(), 'secret' => $this->_oauthHelper->generateTokenSecret(), 'verifier' => $this->_oauthHelper->generateVerifier(), - 'callback_url' => OauthHelper::CALLBACK_ESTABLISHED + 'callback_url' => OauthHelper::CALLBACK_ESTABLISHED, + 'user_type' => UserContextInterface::USER_TYPE_INTEGRATION //As of now only integrations use Oauth ) ); + $this->validate(); $this->save(); } return $this; } /** - * Authorize token + * Convert token to access type * - * @param int $userId Authorization user identifier - * @param string $userType Authorization user type * @return $this * @throws OauthException */ - public function authorize($userId, $userType) + public function convertToAccess() { - if (!$this->getId() || !$this->getConsumerId()) { - throw new OauthException('Token is not ready to be authorized'); - } - if ($this->getAuthorized()) { - throw new OauthException('Token is already authorized'); - } - if (self::USER_TYPE_ADMIN == $userType) { - $this->setAdminId($userId); - } elseif (self::USER_TYPE_CUSTOMER == $userType) { - $this->setCustomerId($userId); - } else { - throw new OauthException('User type is unknown'); + if (self::TYPE_REQUEST != $this->getType()) { + throw new OauthException('Cannot convert to access token due to token is not request type'); } - - $this->setVerifier($this->_oauthHelper->generateVerifier()); - $this->setAuthorized(1); - $this->save(); - - $this->getResource()->cleanOldAuthorizedTokensExcept($this); - - return $this; + return $this->saveAccessToken(UserContextInterface::USER_TYPE_INTEGRATION); } /** - * Convert token to access type + * Create access token for a admin * + * @param int $userId * @return $this - * @throws OauthException */ - public function convertToAccess() + public function createAdminToken($userId) { - if (self::TYPE_REQUEST != $this->getType()) { - throw new OauthException('Cannot convert to access token due to token is not request type'); - } - - $this->setType(self::TYPE_ACCESS); - $this->setToken($this->_oauthHelper->generateToken()); - $this->setSecret($this->_oauthHelper->generateTokenSecret()); - $this->save(); + $this->setAdminId($userId); + return $this->saveAccessToken(UserContextInterface::USER_TYPE_ADMIN); + } - return $this; + /** + * Create access token for a customer + * + * @param int $userId + * @return $this + */ + public function createCustomerToken($userId) + { + $this->setCustomerId($userId); + return $this->saveAccessToken(UserContextInterface::USER_TYPE_CUSTOMER, $userId); } /** @@ -271,28 +252,12 @@ public function createRequestToken($entityId, $callbackUrl) 'callback_url' => $callbackUrl ) ); + $this->validate(); $this->save(); return $this; } - /** - * Get OAuth user type - * - * @return string - * @throws OauthException - */ - public function getUserType() - { - if ($this->getAdminId()) { - return self::USER_TYPE_ADMIN; - } elseif ($this->getCustomerId()) { - return self::USER_TYPE_CUSTOMER; - } else { - throw new OauthException('User type is unknown'); - } - } - /** * Get string representation of token * @@ -312,8 +277,6 @@ public function toString($format = '') */ protected function _beforeSave() { - $this->validate(); - if ($this->isObjectNew() && null === $this->getCreatedAt()) { $this->setCreatedAt($this->_dateTime->now()); } @@ -365,39 +328,78 @@ public function validate() } /** - * Get Token Consumer + * Return the token's verifier. * - * @return \Magento\Integration\Model\Oauth\Consumer + * @return string */ - public function getConsumer() + public function getVerifier() { - if (!$this->getData('consumer')) { - $consumer = $this->_consumerFactory->create()->load($this->getConsumerId()); - $this->setData('consumer', $consumer); - } + return $this->getData('verifier'); + } - return $this->getData('consumer'); + /** + * Generate and save access token for a given user type + * + * @param int $userType + * @return $this + */ + protected function saveAccessToken($userType) + { + $this->setUserType($userType); + $this->setType(self::TYPE_ACCESS); + $this->setToken($this->_oauthHelper->generateToken()); + $this->setSecret($this->_oauthHelper->generateTokenSecret()); + return $this->save(); } /** - * Return the token's verifier. + * Get token by consumer and user type * - * @return string + * @param int $consumerId + * @param int $userType + * @return $this */ - public function getVerifier() + public function loadByConsumerIdAndUserType($consumerId, $userType) { - return $this->getData('verifier'); + $tokenData = $this->getResource()->selectTokenByConsumerIdAndUserType($consumerId, $userType); + $this->setData($tokenData ? $tokenData : []); + return $this; + } + + /** + * Get token by admin id + * + * @param int $adminId + * @return $this + */ + public function loadByAdminId($adminId) + { + $tokenData = $this->getResource()->selectTokenByAdminId($adminId); + $this->setData($tokenData ? $tokenData : []); + return $this; } /** - * Set the token's verifier. + * Get token by admin id * - * @param string $verifier + * @param int $customerId * @return $this */ - public function setVerifier($verifier) + public function loadByCustomerId($customerId) { - $this->setData('verifier', $verifier); + $tokenData = $this->getResource()->selectTokenByCustomerId($customerId); + $this->setData($tokenData ? $tokenData : []); return $this; } + + /** + * Load token data by token. + * + * @param string $token + * @return $this + */ + public function loadByToken($token) + { + return $this->load($token, 'token'); + } } diff --git a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php index 8ca3ff82b52b2..1ac01035d5027 100644 --- a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php +++ b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php @@ -21,9 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + namespace Magento\Integration\Model\Oauth\Token; +use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\Oauth\TokenProviderInterface; +use Magento\Integration\Model\Oauth\Token; class Provider implements TokenProviderInterface { @@ -47,22 +50,30 @@ class Provider implements TokenProviderInterface */ protected $_date; + /** + * @var Token + */ + protected $token; + /** * @param \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory * @param \Magento\Integration\Model\Oauth\Token\Factory $tokenFactory * @param \Magento\Integration\Helper\Oauth\Data $dataHelper * @param \Magento\Framework\Stdlib\DateTime\DateTime $date + * @param Token $token */ public function __construct( \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory, \Magento\Integration\Model\Oauth\Token\Factory $tokenFactory, \Magento\Integration\Helper\Oauth\Data $dataHelper, - \Magento\Framework\Stdlib\DateTime\DateTime $date + \Magento\Framework\Stdlib\DateTime\DateTime $date, + Token $token ) { $this->_consumerFactory = $consumerFactory; $this->_tokenFactory = $tokenFactory; $this->_dataHelper = $dataHelper; $this->_date = $date; + $this->token = $token; } /** @@ -86,8 +97,8 @@ public function validateConsumer($consumer) */ public function createRequestToken($consumer) { - $token = $this->getTokenByConsumerId($consumer->getId()); - if ($token->getType() != \Magento\Integration\Model\Oauth\Token::TYPE_VERIFIER) { + $token = $this->getIntegrationTokenByConsumerId($consumer->getId()); + if ($token->getType() != Token::TYPE_VERIFIER) { throw new \Magento\Framework\Oauth\Exception( 'Cannot create request token because consumer token is not a verifier token' ); @@ -111,7 +122,7 @@ public function validateRequestToken($requestToken, $consumer, $oauthVerifier) // The pre-auth token has a value of "request" in the type when it is requested and created initially. // In this flow (token flow) the token has to be of type "request" else its marked as reused. - if (\Magento\Integration\Model\Oauth\Token::TYPE_REQUEST != $token->getType()) { + if (Token::TYPE_REQUEST != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( 'Token is already being used' ); @@ -128,8 +139,8 @@ public function validateRequestToken($requestToken, $consumer, $oauthVerifier) public function getAccessToken($consumer) { /** TODO: log the request token in dev mode since its not persisted. */ - $token = $this->getTokenByConsumerId($consumer->getId()); - if (\Magento\Integration\Model\Oauth\Token::TYPE_REQUEST != $token->getType()) { + $token = $this->getIntegrationTokenByConsumerId($consumer->getId()); + if (Token::TYPE_REQUEST != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( 'Cannot get access token because consumer token is not a request token' ); @@ -150,7 +161,7 @@ public function validateAccessTokenRequest($accessToken, $consumer) 'Token is not associated with the specified consumer' ); } - if (\Magento\Integration\Model\Oauth\Token::TYPE_ACCESS != $token->getType()) { + if (Token::TYPE_ACCESS != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( 'Token is not an access token' ); @@ -173,7 +184,7 @@ public function validateAccessToken($accessToken) // Make sure a consumer is associated with the token. $this->_getConsumer($token->getConsumerId()); - if (\Magento\Integration\Model\Oauth\Token::TYPE_ACCESS != $token->getType()) { + if (Token::TYPE_ACCESS != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( 'Token is not an access token' ); @@ -270,7 +281,7 @@ protected function _getConsumer($consumerId) * Load token object and validate it. * * @param string $token - * @return \Magento\Integration\Model\Oauth\Token + * @return Token * @throws \Magento\Framework\Oauth\Exception */ protected function _getToken($token) @@ -296,12 +307,12 @@ protected function _getToken($token) * Load token object given a consumer Id. * * @param int $consumerId - The Id of the consumer. - * @return \Magento\Integration\Model\Oauth\Token + * @return Token * @throws \Magento\Framework\Oauth\Exception */ - public function getTokenByConsumerId($consumerId) + public function getIntegrationTokenByConsumerId($consumerId) { - $token = $this->_tokenFactory->create()->load($consumerId, 'consumer_id'); + $token = $this->token->loadByConsumerIdAndUserType($consumerId, UserContextInterface::USER_TYPE_INTEGRATION); if (!$token->getId()) { throw new \Magento\Framework\Oauth\Exception( @@ -316,7 +327,7 @@ public function getTokenByConsumerId($consumerId) /** * Check if token belongs to the same consumer. * - * @param \Magento\Integration\Model\Oauth\Token $token + * @param Token $token * @param \Magento\Framework\Oauth\ConsumerInterface $consumer * @return bool */ diff --git a/app/code/Magento/Integration/Model/Resource/Integration.php b/app/code/Magento/Integration/Model/Resource/Integration.php index 39c9f60bc1a53..54f3c460daba5 100644 --- a/app/code/Magento/Integration/Model/Resource/Integration.php +++ b/app/code/Magento/Integration/Model/Resource/Integration.php @@ -21,6 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + namespace Magento\Integration\Model\Resource; /** @@ -37,4 +38,20 @@ protected function _construct() { $this->_init('integration', 'integration_id'); } + + /** + * Select token for a given customer. + * + * @param int $consumerId + * @return array|boolean - Row data (array) or false if there is no corresponding row + */ + public function selectActiveIntegrationByConsumerId($consumerId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('consumer_id = ?', $consumerId) + ->where('status = ?', \Magento\Integration\Model\Integration::STATUS_ACTIVE); + return $adapter->fetchRow($select); + } } diff --git a/app/code/Magento/Integration/Model/Resource/Oauth/Token.php b/app/code/Magento/Integration/Model/Resource/Oauth/Token.php index 522696ae63ec6..469f492ac3a90 100644 --- a/app/code/Magento/Integration/Model/Resource/Oauth/Token.php +++ b/app/code/Magento/Integration/Model/Resource/Oauth/Token.php @@ -23,6 +23,8 @@ */ namespace Magento\Integration\Model\Resource\Oauth; +use Magento\Authorization\Model\UserContextInterface; + /** * OAuth token resource model */ @@ -116,15 +118,59 @@ public function deleteOldEntries($minutes) public function selectTokenByType($consumerId, $type) { $adapter = $this->_getReadAdapter(); - $select = $adapter->select()->from( - $this->getMainTable() - )->where( - 'consumer_id = ?', - $consumerId - )->where( - 'type = ?', - $type - ); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('consumer_id = ?', $consumerId) + ->where('type = ?', $type); + return $adapter->fetchRow($select); + } + + /** + * Select token for a given consumer and user type. + * + * @param int $consumerId + * @param int $userType + * @return array|boolean - Row data (array) or false if there is no corresponding row + */ + public function selectTokenByConsumerIdAndUserType($consumerId, $userType) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('consumer_id = ?', (int)$consumerId) + ->where('user_type = ?', (int)$userType); + return $adapter->fetchRow($select); + } + + /** + * Select token for a given admin id. + * + * @param int $adminId + * @return array|boolean - Row data (array) or false if there is no corresponding row + */ + public function selectTokenByAdminId($adminId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('admin_id = ?', $adminId) + ->where('user_type = ?', UserContextInterface::USER_TYPE_ADMIN); + return $adapter->fetchRow($select); + } + + /** + * Select token for a given customer. + * + * @param int $customerId + * @return array|boolean - Row data (array) or false if there is no corresponding row + */ + public function selectTokenByCustomerId($customerId) + { + $adapter = $this->_getReadAdapter(); + $select = $adapter->select() + ->from($this->getMainTable()) + ->where('customer_id = ?', $customerId) + ->where('user_type = ?', UserContextInterface::USER_TYPE_CUSTOMER); return $adapter->fetchRow($select); } } diff --git a/app/code/Magento/Integration/Service/V1/AuthorizationService.php b/app/code/Magento/Integration/Service/V1/AuthorizationService.php new file mode 100644 index 0000000000000..bcbcfdff755ef --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/AuthorizationService.php @@ -0,0 +1,214 @@ +_aclBuilder = $aclBuilder; + $this->_roleFactory = $roleFactory; + $this->_rulesFactory = $rulesFactory; + $this->_rulesCollectionFactory = $rulesCollectionFactory; + $this->_roleCollectionFactory = $roleCollectionFactory; + $this->_logger = $logger; + $this->_rootAclResource = $rootAclResource; + } + + /** + * {@inheritdoc} + */ + public function grantPermissions($integrationId, $resources) + { + try { + $role = $this->_getUserRole($integrationId); + if (!$role) { + $role = $this->_createRole($integrationId); + } + $this->_associateResourcesWithRole($role, $resources); + } catch (\Exception $e) { + $this->_logger->logException($e); + throw new LocalizedException('Error happened while granting permissions. Check exception log for details.'); + } + } + + /** + * {@inheritdoc} + */ + public function grantAllPermissions($integrationId) + { + $this->grantPermissions($integrationId, array($this->_rootAclResource->getId())); + } + + /** + * {@inheritdoc} + */ + public function removePermissions($integrationId) + { + try { + $this->_deleteRole($integrationId); + } catch (\Exception $e) { + $this->_logger->logException($e); + throw new LocalizedException( + 'Error happened while deleting role and permissions. Check exception log for details.' + ); + } + } + + /** + * Create new ACL role. + * + * @param int $integrationId + * @return \Magento\Authorization\Model\Role + */ + protected function _createRole($integrationId) + { + $roleName = UserContextInterface::USER_TYPE_INTEGRATION . $integrationId; + $role = $this->_roleFactory->create(); + $role->setRoleName($roleName) + ->setUserType(UserContextInterface::USER_TYPE_INTEGRATION) + ->setUserId($integrationId) + ->setRoleType(\Magento\Authorization\Model\Acl\Role\User::ROLE_TYPE) + ->setParentId(0) + ->save(); + return $role; + } + + /** + * Remove integration role. This deletes the cascading permissions + * + * @param int $integrationId + * @return \Magento\Authorization\Model\Role + */ + protected function _deleteRole($integrationId) + { + $roleName = UserContextInterface::USER_TYPE_INTEGRATION . $integrationId; + $role = $this->_roleFactory->create()->load($roleName, 'role_name'); + return $role->delete(); + } + + /** + * Identify authorization role associated with provided integration. + * + * @param int $integrationId + * @return \Magento\Authorization\Model\Role|false Return false in case when no role associated with user was found. + */ + protected function _getUserRole($integrationId) + { + $roleCollection = $this->_roleCollectionFactory->create(); + /** @var Role $role */ + $role = $roleCollection + ->setUserFilter($integrationId, UserContextInterface::USER_TYPE_INTEGRATION) + ->getFirstItem(); + return $role->getId() ? $role : false; + } + + /** + * Associate resources with the specified role. All resources previously assigned to the role will be unassigned. + * + * @param \Magento\Authorization\Model\Role $role + * @param string[] $resources + * @return void + * @throws \LogicException + */ + protected function _associateResourcesWithRole($role, $resources) + { + /** @var \Magento\Authorization\Model\Rules $rules */ + $rules = $this->_rulesFactory->create(); + $rules->setRoleId($role->getId())->setResources($resources)->saveRel(); + } +} diff --git a/app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php b/app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php new file mode 100644 index 0000000000000..1b7b04381387d --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/AuthorizationServiceInterface.php @@ -0,0 +1,68 @@ +_integrationFactory->create()->loadActiveIntegrationByConsumerId($consumerId); + return $integration; + } + /** * Check if an integration exists by the name * diff --git a/app/code/Magento/Integration/Service/V1/IntegrationInterface.php b/app/code/Magento/Integration/Service/V1/IntegrationInterface.php index 473d6926dd4e1..651089a51e577 100644 --- a/app/code/Magento/Integration/Service/V1/IntegrationInterface.php +++ b/app/code/Magento/Integration/Service/V1/IntegrationInterface.php @@ -64,6 +64,14 @@ public function findByName($integrationName); */ public function findByConsumerId($consumerId); + /** + * Get the details of an active Integration by consumer_id. + * + * @param int $consumerId + * @return IntegrationModel + */ + public function findActiveIntegrationByConsumerId($consumerId); + /** * Update an Integration. * diff --git a/app/code/Magento/Integration/Service/V1/Oauth.php b/app/code/Magento/Integration/Service/V1/Oauth.php index 054de2b401356..0456688ad2172 100644 --- a/app/code/Magento/Integration/Service/V1/Oauth.php +++ b/app/code/Magento/Integration/Service/V1/Oauth.php @@ -24,7 +24,7 @@ namespace Magento\Integration\Service\V1; use Magento\Integration\Model\Oauth\Token\Provider as TokenProvider; -use Magento\Integration\Model\Oauth\Token; +use Magento\Integration\Model\Oauth\Token as OauthTokenModel; use Magento\Integration\Model\Oauth\Token\Factory as TokenFactory; use Magento\Integration\Helper\Oauth\Data as IntegrationOauthHelper; use Magento\Framework\Oauth\Helper\Oauth as OauthHelper; @@ -138,7 +138,7 @@ public function createAccessToken($consumerId, $clearExistingToken = false) { try { $consumer = $this->_consumerFactory->create()->load($consumerId); - $existingToken = $this->_tokenProvider->getTokenByConsumerId($consumer->getId()); + $existingToken = $this->_tokenProvider->getIntegrationTokenByConsumerId($consumer->getId()); if ($existingToken && $clearExistingToken) { $existingToken->delete(); unset($existingToken); @@ -162,8 +162,8 @@ public function getAccessToken($consumerId) { try { $consumer = $this->_consumerFactory->create()->load($consumerId); - $token = $this->_tokenProvider->getTokenByConsumerId($consumer->getId()); - if ($token->getType() != Token::TYPE_ACCESS) { + $token = $this->_tokenProvider->getIntegrationTokenByConsumerId($consumer->getId()); + if ($token->getType() != OauthTokenModel::TYPE_ACCESS) { return false; } } catch (\Exception $e) { @@ -260,11 +260,11 @@ public function deleteConsumer($consumerId) /** * {@inheritdoc} */ - public function deleteToken($consumerId) + public function deleteIntegrationToken($consumerId) { try { $consumer = $this->_consumerFactory->create()->load($consumerId); - $existingToken = $this->_tokenProvider->getTokenByConsumerId($consumer->getId()); + $existingToken = $this->_tokenProvider->getIntegrationTokenByConsumerId($consumer->getId()); $existingToken->delete(); return true; } catch (\Exception $e) { diff --git a/app/code/Magento/Integration/Service/V1/OauthInterface.php b/app/code/Magento/Integration/Service/V1/OauthInterface.php index 7a1859b1bd4ee..c468a2067ab7a 100644 --- a/app/code/Magento/Integration/Service/V1/OauthInterface.php +++ b/app/code/Magento/Integration/Service/V1/OauthInterface.php @@ -23,7 +23,7 @@ */ namespace Magento\Integration\Service\V1; -use Magento\Integration\Model\Oauth\Token; +use Magento\Integration\Model\Oauth\Token as OauthTokenModel; /** * Integration oAuth Service Interface @@ -59,7 +59,7 @@ public function createAccessToken($consumerId, $clearExistingToken = false); * Retrieve access token assigned to the consumer. * * @param int $consumerId - * @return Token|bool Return false if no access token is available. + * @return OauthTokenModel|bool Return false if no access token is available. */ public function getAccessToken($consumerId); @@ -108,5 +108,5 @@ public function deleteConsumer($consumerId); * @param int $consumerId * @return bool If token was deleted */ - public function deleteToken($consumerId); + public function deleteIntegrationToken($consumerId); } diff --git a/app/code/Magento/Integration/Service/V1/TokenService.php b/app/code/Magento/Integration/Service/V1/TokenService.php new file mode 100644 index 0000000000000..0b860f33655ad --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/TokenService.php @@ -0,0 +1,132 @@ +tokenModelFactory = $tokenModelFactory; + $this->userModel = $userModel; + $this->customerAccountService = $customerAccountService; + } + + /** + * {@inheritdoc} + */ + public function createAdminAccessToken($username, $password) + { + $this->validateCredentials($username, $password); + try { + $this->userModel->login($username, $password); + if (!$this->userModel->getId()) { + /* + * This message is same as one thrown in \Magento\Backend\Model\Auth to keep the behavior consistent. + * Constant cannot be created in Auth Model since it uses legacy translation that doesn't support it. + * Need to make sure that this is refactored once exception handling is updated in Auth Model. + */ + throw new AuthenticationException('Please correct the user name or password.'); + } + } catch (\Magento\Backend\Model\Auth\Exception $e) { + throw new AuthenticationException($e->getMessage(), [], $e); + } catch (\Magento\Framework\Model\Exception $e) { + throw new LocalizedException($e->getMessage(), [], $e); + } + return $this->tokenModelFactory->create()->createAdminToken($this->userModel->getId())->getToken(); + } + + /** + * {@inheritdoc} + */ + public function createCustomerAccessToken($username, $password) + { + $this->validateCredentials($username, $password); + $customerDataObject = $this->customerAccountService->authenticate($username, $password); + return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken(); + } + + /** + * Validate user credentials + * + * @param string $username + * @param string $password + * @return void + * @throws \Magento\Framework\Exception\InputException + */ + protected function validateCredentials($username, $password) + { + $exception = new InputException(); + if (!is_string($username) || strlen($username) == 0) { + $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'username']); + } + if (!is_string($username) || strlen($password) == 0) { + $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'password']); + } + if ($exception->wasErrorAdded()) { + throw $exception; + } + } +} diff --git a/app/code/Magento/Integration/Service/V1/TokenServiceInterface.php b/app/code/Magento/Integration/Service/V1/TokenServiceInterface.php new file mode 100644 index 0000000000000..0f374a7a638a7 --- /dev/null +++ b/app/code/Magento/Integration/Service/V1/TokenServiceInterface.php @@ -0,0 +1,58 @@ + + + Magento\Framework\Stdlib\DateTime\DateTime\Proxy diff --git a/app/code/Magento/Integration/etc/module.xml b/app/code/Magento/Integration/etc/module.xml index e16c617dce958..eb76e22b29dd2 100644 --- a/app/code/Magento/Integration/etc/module.xml +++ b/app/code/Magento/Integration/etc/module.xml @@ -24,17 +24,20 @@ */ --> - + + + + diff --git a/app/code/Magento/Integration/etc/webapi.xml b/app/code/Magento/Integration/etc/webapi.xml new file mode 100644 index 0000000000000..2153888cff319 --- /dev/null +++ b/app/code/Magento/Integration/etc/webapi.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Integration/sql/integration_setup/upgrade-1.0.0.2-1.0.0.3.php b/app/code/Magento/Integration/sql/integration_setup/upgrade-1.0.0.2-1.0.0.3.php new file mode 100644 index 0000000000000..f77a5d32b3cad --- /dev/null +++ b/app/code/Magento/Integration/sql/integration_setup/upgrade-1.0.0.2-1.0.0.3.php @@ -0,0 +1,68 @@ +getConnection(); + +$oauthTokenTable = $installer->getTable('oauth_token'); +$adminTable = $installer->getTable('admin_user'); +$customerTable = $installer->getTable('customer_entity'); + +$connection->addColumn( + $oauthTokenTable, + 'user_type', + array( + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + 'comment' => 'User type' + ) +); +$connection->modifyColumn( + $oauthTokenTable, + 'consumer_id', + array( + 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + 'unsigned' => true, + 'nullable' => true, + 'comment' => 'Oauth Consumer ID' + ) +); +$connection->addForeignKey( + $installer->getFkName($oauthTokenTable, 'admin_id', $adminTable, 'user_id'), + $oauthTokenTable, + 'admin_id', + $adminTable, + 'user_id' +); +$connection->addForeignKey( + $installer->getFkName($oauthTokenTable, 'admin_id', $customerTable, 'entity_id'), + $oauthTokenTable, + 'customer_id', + $customerTable, + 'entity_id' +); diff --git a/app/code/Magento/LayeredNavigation/composer.json b/app/code/Magento/LayeredNavigation/composer.json index be9d3df13b419..00ec2ff67d6d6 100644 --- a/app/code/Magento/LayeredNavigation/composer.json +++ b/app/code/Magento/LayeredNavigation/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-layered-navigation", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/LayeredNavigation/view/frontend/layout/page_one_column.xml b/app/code/Magento/LayeredNavigation/view/frontend/layout/page_one_column.xml index a73bba5fcadae..d99697645da7f 100644 --- a/app/code/Magento/LayeredNavigation/view/frontend/layout/page_one_column.xml +++ b/app/code/Magento/LayeredNavigation/view/frontend/layout/page_one_column.xml @@ -24,5 +24,5 @@ */ --> - + diff --git a/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/state.phtml b/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/state.phtml index 77cb12ee001ef..431a63e830c71 100644 --- a/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/state.phtml +++ b/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/state.phtml @@ -31,8 +31,8 @@ ?> getActiveFilters() ?> -
    - +
    +
    1. diff --git a/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml b/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml index 6af9a7ed80eb4..2fb0ffd37cd0f 100644 --- a/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml +++ b/app/code/Magento/LayeredNavigation/view/frontend/templates/layer/view.phtml @@ -34,7 +34,6 @@
      - getLayer()->getState()->getActiveFilters()) ?>
      @@ -45,17 +44,20 @@
      - - - -
      - getFilters() as $filter): ?> + + getFilters() as $filter): ?> + + +
      + getItemsCount()): ?>
      escapeHtml(__($filter->getName())) ?>
      getChildBlock('renderer')->render($filter); ?>
      - -
      + + +
      +
    diff --git a/app/code/Magento/Log/composer.json b/app/code/Magento/Log/composer.json index a61e95929ee88..5fb3aacf06e9d 100644 --- a/app/code/Magento/Log/composer.json +++ b/app/code/Magento/Log/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-log", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index 8062806648e5e..c5a34e64e590d 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -24,6 +24,7 @@ namespace Magento\Multishipping\Model\Checkout\Type; use Magento\Customer\Service\V1\CustomerAddressServiceInterface; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; /** * Multishipping checkout model @@ -103,6 +104,11 @@ class Multishipping extends \Magento\Framework\Object */ protected $_customerAddressService; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession @@ -116,6 +122,7 @@ class Multishipping extends \Magento\Framework\Object * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification * @param \Magento\Multishipping\Helper\Data $helper + * @param OrderSender $orderSender * @param array $data */ public function __construct( @@ -131,6 +138,7 @@ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification, \Magento\Multishipping\Helper\Data $helper, + OrderSender $orderSender, array $data = array() ) { $this->_eventManager = $eventManager; @@ -145,6 +153,7 @@ public function __construct( $this->_customerSession = $customerSession; $this->_orderFactory = $orderFactory; $this->_customerAddressService = $customerAddressService; + $this->orderSender = $orderSender; parent::__construct($data); $this->_init(); } @@ -639,7 +648,7 @@ public function createOrders() $order->place(); $order->save(); if ($order->getCanSendNewEmailFlag()) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } $orderIds[$order->getId()] = $order->getIncrementId(); } diff --git a/app/code/Magento/Multishipping/composer.json b/app/code/Magento/Multishipping/composer.json index 6dee20220838b..023416f651c93 100644 --- a/app/code/Magento/Multishipping/composer.json +++ b/app/code/Magento/Multishipping/composer.json @@ -2,21 +2,21 @@ "name": "magento/module-multishipping", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-weee": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-weee": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Multishipping/etc/adminhtml/acl.xml b/app/code/Magento/Multishipping/etc/acl.xml similarity index 94% rename from app/code/Magento/Multishipping/etc/adminhtml/acl.xml rename to app/code/Magento/Multishipping/etc/acl.xml index 82bdbc1398e62..b6cad29cbc153 100644 --- a/app/code/Magento/Multishipping/etc/adminhtml/acl.xml +++ b/app/code/Magento/Multishipping/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Newsletter/composer.json b/app/code/Magento/Newsletter/composer.json index 1850aa528a443..4bc48b94f6994 100644 --- a/app/code/Magento/Newsletter/composer.json +++ b/app/code/Magento/Newsletter/composer.json @@ -2,22 +2,22 @@ "name": "magento/module-newsletter", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-email": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-email": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Newsletter/etc/adminhtml/acl.xml b/app/code/Magento/Newsletter/etc/acl.xml similarity index 96% rename from app/code/Magento/Newsletter/etc/adminhtml/acl.xml rename to app/code/Magento/Newsletter/etc/acl.xml index c8d22e1fd87db..d1eb2f175c35f 100644 --- a/app/code/Magento/Newsletter/etc/adminhtml/acl.xml +++ b/app/code/Magento/Newsletter/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/OfflinePayments/composer.json b/app/code/Magento/OfflinePayments/composer.json index 93acbbb7a2895..ec0bfcae4b8df 100644 --- a/app/code/Magento/OfflinePayments/composer.json +++ b/app/code/Magento/OfflinePayments/composer.json @@ -2,13 +2,13 @@ "name": "magento/module-offline-payments", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-payment": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-payment": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/OfflineShipping/composer.json b/app/code/Magento/OfflineShipping/composer.json index 417547b6b4d5a..e35cbbe21966b 100644 --- a/app/code/Magento/OfflineShipping/composer.json +++ b/app/code/Magento/OfflineShipping/composer.json @@ -2,20 +2,20 @@ "name": "magento/module-offline-shipping", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-sales-rule": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-sales-rule": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Ogone/Controller/Api.php b/app/code/Magento/Ogone/Controller/Api.php index 0a3493b972842..faff1fdefffbd 100644 --- a/app/code/Magento/Ogone/Controller/Api.php +++ b/app/code/Magento/Ogone/Controller/Api.php @@ -25,6 +25,7 @@ use Magento\Sales\Model\Order; use Magento\Sales\Model\Order\Payment\Transaction as PaymentTransaction; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; /** * Ogone Api Controller @@ -48,19 +49,27 @@ class Api extends \Magento\Framework\App\Action\Action */ protected $_transactionFactory; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\DB\TransactionFactory $transactionFactory * @param \Magento\Sales\Model\OrderFactory $salesOrderFactory + * @param OrderSender $orderSender */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\DB\TransactionFactory $transactionFactory, - \Magento\Sales\Model\OrderFactory $salesOrderFactory + \Magento\Sales\Model\OrderFactory $salesOrderFactory, + OrderSender $orderSender ) { parent::__construct($context); $this->_transactionFactory = $transactionFactory; $this->_salesOrderFactory = $salesOrderFactory; + $this->orderSender = $orderSender; } /** @@ -248,7 +257,7 @@ protected function _processDirectSale() $invoice->getOrder()->setIsInProcess(true); $this->_transactionFactory->create()->addObject($invoice)->addObject($invoice->getOrder())->save(); - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } } else { $order->save(); @@ -282,7 +291,7 @@ protected function _processAuthorize() } else { //to send new order email only when state is pending payment if ($order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } $order->setState( \Magento\Sales\Model\Order::STATE_PROCESSING, @@ -356,7 +365,7 @@ public function _exceptionProcess() $order->getPayment()->setLastTransId($params['PAYID']); //to send new order email only when state is pending payment if ($order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); $order->setState( \Magento\Sales\Model\Order::STATE_PROCESSING, \Magento\Ogone\Model\Api::PROCESSING_OGONE_STATUS, diff --git a/app/code/Magento/Ogone/composer.json b/app/code/Magento/Ogone/composer.json index 324926c35f230..c32adb17524fe 100644 --- a/app/code/Magento/Ogone/composer.json +++ b/app/code/Magento/Ogone/composer.json @@ -2,16 +2,16 @@ "name": "magento/module-ogone", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/PageCache/composer.json b/app/code/Magento/PageCache/composer.json index c0f7ecc263fac..1a1968b4da93f 100644 --- a/app/code/Magento/PageCache/composer.json +++ b/app/code/Magento/PageCache/composer.json @@ -2,14 +2,14 @@ "name": "magento/module-page-cache", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php b/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php index d04c57253fb70..f8908adecfe66 100644 --- a/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php +++ b/app/code/Magento/PayPalRecurringPayment/Model/Ipn.php @@ -25,6 +25,8 @@ use Exception; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; + /** * PayPal Recurring Instant Payment Notification processor model */ @@ -42,11 +44,17 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements \Magento\Paypal\M */ protected $_recurringPaymentFactory; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Paypal\Model\ConfigFactory $configFactory * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory * @param \Magento\RecurringPayment\Model\PaymentFactory $recurringPaymentFactory + * @param OrderSender $orderSender * @param array $data */ public function __construct( @@ -54,10 +62,12 @@ public function __construct( \Magento\Framework\Logger\AdapterFactory $logAdapterFactory, \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory, \Magento\RecurringPayment\Model\PaymentFactory $recurringPaymentFactory, + OrderSender $orderSender, array $data = array() ) { parent::__construct($configFactory, $logAdapterFactory, $curlFactory, $data); $this->_recurringPaymentFactory = $recurringPaymentFactory; + $this->orderSender = $orderSender; } /** @@ -171,7 +181,8 @@ protected function _processRecurringPayment() $invoice = $payment->getCreatedInvoice(); if ($invoice) { $message = __('You notified customer about invoice #%1.', $invoice->getIncrementId()); - $order->sendNewOrderEmail()->addStatusHistoryComment($message)->setIsCustomerNotified(true)->save(); + $this->orderSender->send($order); + $order->addStatusHistoryComment($message)->setIsCustomerNotified(true)->save(); } } catch (\Magento\Framework\Model\Exception $e) { $comment = $this->_createIpnComment(__('Note: %1', $e->getMessage()), true); diff --git a/app/code/Magento/PayPalRecurringPayment/composer.json b/app/code/Magento/PayPalRecurringPayment/composer.json index 61cff656014e1..8c2e560ad9641 100644 --- a/app/code/Magento/PayPalRecurringPayment/composer.json +++ b/app/code/Magento/PayPalRecurringPayment/composer.json @@ -2,17 +2,18 @@ "name": "magento/module-pay-pal-recurring-payment", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-paypal": "0.1.0-alpha89", - "magento/module-recurring-payment": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-paypal": "0.1.0-alpha90", + "magento/module-recurring-payment": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/PayPalRecurringPayment/etc/module.xml b/app/code/Magento/PayPalRecurringPayment/etc/module.xml index 1a7957cf93bbe..c0f24a5bf8276 100644 --- a/app/code/Magento/PayPalRecurringPayment/etc/module.xml +++ b/app/code/Magento/PayPalRecurringPayment/etc/module.xml @@ -30,6 +30,7 @@ + diff --git a/app/code/Magento/Payment/composer.json b/app/code/Magento/Payment/composer.json index 789f80d72d540..fce23ae89598a 100644 --- a/app/code/Magento/Payment/composer.json +++ b/app/code/Magento/Payment/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-payment", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-centinel": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-centinel": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Payment/etc/adminhtml/acl.xml b/app/code/Magento/Payment/etc/acl.xml similarity index 94% rename from app/code/Magento/Payment/etc/adminhtml/acl.xml rename to app/code/Magento/Payment/etc/acl.xml index c8ad3fd70b76a..30c6482acc4d8 100644 --- a/app/code/Magento/Payment/etc/adminhtml/acl.xml +++ b/app/code/Magento/Payment/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index 83bf85995421f..e1c9bb83bbd1c 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -27,6 +27,7 @@ use Magento\Sales\Model\Quote\Address; use Magento\Customer\Service\V1\Data\Customer as CustomerDataObject; use Magento\Paypal\Model\Config as PaypalConfig; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; /** * Wrapper that performs Paypal Express and Checkout communication @@ -280,6 +281,11 @@ class Checkout */ protected $_messageManager; + /** + * @var OrderSender + */ + protected $orderSender; + /** * Set config, session and quote instances * @@ -307,6 +313,7 @@ class Checkout * @param \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param OrderSender $orderSender * @param array $params * @throws \Exception */ @@ -335,6 +342,7 @@ public function __construct( \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Message\ManagerInterface $messageManager, + OrderSender $orderSender, $params = array() ) { $this->_customerData = $customerData; @@ -360,6 +368,7 @@ public function __construct( $this->_customerDetailsBuilder = $customerDetailsBuilder; $this->_encryptor = $encryptor; $this->_messageManager = $messageManager; + $this->orderSender = $orderSender; $this->_customerSession = isset($params['session']) && $params['session'] instanceof \Magento\Customer\Model\Session ? $params['session'] : $customerSession; @@ -842,7 +851,7 @@ public function place($token, $shippingMethodCode = null) case \Magento\Sales\Model\Order::STATE_PROCESSING: case \Magento\Sales\Model\Order::STATE_COMPLETE: case \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW: - $order->sendNewOrderEmail(); + $this->orderSender->send($order); break; default: break; diff --git a/app/code/Magento/Paypal/Model/Ipn.php b/app/code/Magento/Paypal/Model/Ipn.php index e871ca462aa00..d0d432d53c67e 100644 --- a/app/code/Magento/Paypal/Model/Ipn.php +++ b/app/code/Magento/Paypal/Model/Ipn.php @@ -24,6 +24,8 @@ namespace Magento\Paypal\Model; use Exception; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; /** * PayPal Instant Payment Notification processor model @@ -47,12 +49,24 @@ class Ipn extends \Magento\Paypal\Model\AbstractIpn implements IpnInterface */ protected $_paypalInfo; + /** + * @var OrderSender + */ + protected $orderSender; + + /** + * @var CreditmemoSender + */ + protected $creditmemoSender; + /** * @param \Magento\Paypal\Model\ConfigFactory $configFactory * @param \Magento\Framework\Logger\AdapterFactory $logAdapterFactory * @param \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param Info $paypalInfo + * @param OrderSender $orderSender + * @param CreditmemoSender $creditmemoSender * @param array $data */ public function __construct( @@ -61,11 +75,15 @@ public function __construct( \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory, \Magento\Sales\Model\OrderFactory $orderFactory, Info $paypalInfo, + OrderSender $orderSender, + CreditmemoSender $creditmemoSender, array $data = array() ) { parent::__construct($configFactory, $logAdapterFactory, $curlFactory, $data); $this->_orderFactory = $orderFactory; $this->_paypalInfo = $paypalInfo; + $this->orderSender = $orderSender; + $this->creditmemoSender = $creditmemoSender; } /** @@ -312,7 +330,8 @@ protected function _registerPaymentCapture($skipFraudDetection = false) // notify customer $invoice = $payment->getCreatedInvoice(); if ($invoice && !$this->_order->getEmailSent()) { - $this->_order->sendNewOrderEmail()->addStatusHistoryComment( + $this->orderSender->send($this->_order); + $this->_order->addStatusHistoryComment( __('You notified customer about invoice #%1.', $invoice->getIncrementId()) )->setIsCustomerNotified( true @@ -419,7 +438,7 @@ protected function _registerPaymentAuthorization() ); } if (!$this->_order->getEmailSent()) { - $this->_order->sendNewOrderEmail(); + $this->orderSender->send($this->_order); } $this->_order->save(); } @@ -490,7 +509,7 @@ protected function _registerPaymentRefund() $creditMemo = $payment->getCreatedCreditmemo(); if ($creditMemo) { - $creditMemo->sendEmail(); + $this->creditmemoSender->send($creditMemo); $this->_order->addStatusHistoryComment( __('You notified customer about creditmemo #%1.', $creditMemo->getIncrementId()) )->setIsCustomerNotified( diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index 31b9354b080bb..370bb739c7be0 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -23,6 +23,8 @@ */ namespace Magento\Paypal\Model; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; + /** * Payflow Link payment gateway model */ @@ -144,6 +146,11 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro */ protected $_websiteFactory; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Payment\Helper\Data $paymentData @@ -162,6 +169,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Framework\App\RequestInterface $requestHttp * @param \Magento\Store\Model\WebsiteFactory $websiteFactory + * @param OrderSender $orderSender * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -184,6 +192,7 @@ public function __construct( \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Store\Model\WebsiteFactory $websiteFactory, + OrderSender $orderSender, array $data = array() ) { $this->_requestFactory = $requestFactory; @@ -191,6 +200,7 @@ public function __construct( $this->_orderFactory = $orderFactory; $this->_requestHttp = $requestHttp; $this->_websiteFactory = $websiteFactory; + $this->orderSender = $orderSender; parent::__construct( $eventManager, $paymentData, @@ -389,7 +399,7 @@ protected function _processOrder(\Magento\Sales\Model\Order $order) try { if ($canSendNewOrderEmail) { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } $this->_quoteFactory->create()->load($order->getQuoteId())->setIsActive(false)->save(); } catch (\Exception $e) { diff --git a/app/code/Magento/Paypal/composer.json b/app/code/Magento/Paypal/composer.json index cfc787d36f474..cd97fcde61a55 100644 --- a/app/code/Magento/Paypal/composer.json +++ b/app/code/Magento/Paypal/composer.json @@ -2,26 +2,26 @@ "name": "magento/module-paypal", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/module-centinel": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/module-centinel": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Paypal/etc/adminhtml/acl.xml b/app/code/Magento/Paypal/etc/acl.xml similarity index 96% rename from app/code/Magento/Paypal/etc/adminhtml/acl.xml rename to app/code/Magento/Paypal/etc/acl.xml index d0f32046bc40a..3dc6a973cf8f9 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/acl.xml +++ b/app/code/Magento/Paypal/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Paypal/etc/adminhtml/system.xml b/app/code/Magento/Paypal/etc/adminhtml/system.xml index 6f826847aefca..838e2e42de045 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/system.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/system.xml @@ -749,7 +749,7 @@ You get paid up front, even though customers have more time to pay. A pre-integrated payment button lets customers pay quickly with Bill Me Later®. Learn More]]> - payment/paypal_express_bml/active + payment/payflow_express_bml/active diff --git a/app/code/Magento/Persistent/composer.json b/app/code/Magento/Persistent/composer.json index 92987b1525fad..9f15f4a5107fe 100644 --- a/app/code/Magento/Persistent/composer.json +++ b/app/code/Magento/Persistent/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-persistent", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Persistent/etc/adminhtml/acl.xml b/app/code/Magento/Persistent/etc/acl.xml similarity index 94% rename from app/code/Magento/Persistent/etc/adminhtml/acl.xml rename to app/code/Magento/Persistent/etc/acl.xml index 986e38739e4d8..8783b80c14f0c 100644 --- a/app/code/Magento/Persistent/etc/adminhtml/acl.xml +++ b/app/code/Magento/Persistent/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/ProductAlert/composer.json b/app/code/Magento/ProductAlert/composer.json index 478a634fc0441..cae86a3d2c98b 100644 --- a/app/code/Magento/ProductAlert/composer.json +++ b/app/code/Magento/ProductAlert/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-product-alert", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php b/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php index f6e988b9c9a2e..27bd0e404d5d7 100644 --- a/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php +++ b/app/code/Magento/RecurringPayment/Controller/RecurringPayment.php @@ -99,10 +99,12 @@ protected function _viewAction() { try { $payment = $this->_initPayment(); - $this->_title->add(__('Recurring Billing Payments')); - $this->_title->add(__('Payment #%1', $payment->getReferenceId())); $this->_view->loadLayout(); $this->_view->getLayout()->initMessages(); + + $title = __('Recurring Payment #%1', $payment->getReferenceId()); + $this->_view->getLayout()->getBlock('head')->setTitle($title); + $this->_view->renderLayout(); return; } catch (\Magento\Framework\Model\Exception $e) { diff --git a/app/code/Magento/RecurringPayment/Model/Plugin/Tabs.php b/app/code/Magento/RecurringPayment/Model/Plugin/Tabs.php new file mode 100644 index 0000000000000..4c4e54548c684 --- /dev/null +++ b/app/code/Magento/RecurringPayment/Model/Plugin/Tabs.php @@ -0,0 +1,60 @@ +_moduleManager = $moduleManager; + } + + /** + * @param \Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs $subject + * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection $result + * + * @return \Magento\Eav\Model\Resource\Entity\Attribute\Group\Collection + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetGroupCollection(\Magento\Catalog\Block\Adminhtml\Product\Edit\Tabs $subject, $result) + { + if (!$this->_moduleManager->isOutputEnabled('Magento_RecurringPayment')) { + foreach ($result as $key => $group) { + if ($group->getAttributeGroupCode() === 'recurring-payment') { + $result->removeItemByKey($key); + } + } + } + return $result; + } +} diff --git a/app/code/Magento/RecurringPayment/composer.json b/app/code/Magento/RecurringPayment/composer.json index 98a7df3d23c48..1c8a325da56aa 100644 --- a/app/code/Magento/RecurringPayment/composer.json +++ b/app/code/Magento/RecurringPayment/composer.json @@ -2,22 +2,22 @@ "name": "magento/module-recurring-payment", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-checkout": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-checkout": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php b/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php index 87c94686774a8..a6d44ef516618 100644 --- a/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php +++ b/app/code/Magento/RecurringPayment/data/recurringpayment_setup/data-install-1.0.0.0.php @@ -35,7 +35,7 @@ $this->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, 'recurring_payment'); $connection = $this->getConnection(); -$adminRuleTable = $this->getTable('admin_rule'); +$adminRuleTable = $this->getTable('authorization_rule'); $connection->update( $adminRuleTable, array('resource_id' => 'Magento_RecurringPayment::recurring_payment'), diff --git a/app/code/Magento/RecurringPayment/etc/adminhtml/acl.xml b/app/code/Magento/RecurringPayment/etc/acl.xml similarity index 94% rename from app/code/Magento/RecurringPayment/etc/adminhtml/acl.xml rename to app/code/Magento/RecurringPayment/etc/acl.xml index 5a259ef64af42..a83953dd5bc9e 100644 --- a/app/code/Magento/RecurringPayment/etc/adminhtml/acl.xml +++ b/app/code/Magento/RecurringPayment/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/RecurringPayment/etc/di.xml b/app/code/Magento/RecurringPayment/etc/di.xml index b2f1aba96635c..447db78390fe0 100644 --- a/app/code/Magento/RecurringPayment/etc/di.xml +++ b/app/code/Magento/RecurringPayment/etc/di.xml @@ -47,5 +47,7 @@ - + + + diff --git a/app/code/Magento/RecurringPayment/view/frontend/templates/catalog/product/view/payment/schedule.phtml b/app/code/Magento/RecurringPayment/view/frontend/templates/catalog/product/view/payment/schedule.phtml index f0472591fd0a5..5bfe9bb7ba80b 100644 --- a/app/code/Magento/RecurringPayment/view/frontend/templates/catalog/product/view/payment/schedule.phtml +++ b/app/code/Magento/RecurringPayment/view/frontend/templates/catalog/product/view/payment/schedule.phtml @@ -27,11 +27,11 @@ * @see \Magento\RecurringPayment\Block\Catalog\Product\View\Payment */ ?> -
    +
    getScheduleInfo() as $term => $definitions): ?> -
    escapeHtml($term); ?>
    +
    escapeHtml($term); ?>
    -
    escapeHtml($definition)?>
    +
    escapeHtml($definition)?>
    diff --git a/app/code/Magento/RecurringPayment/view/frontend/templates/recurring/grid.phtml b/app/code/Magento/RecurringPayment/view/frontend/templates/recurring/grid.phtml index 34a92266f3210..6d2199a981f61 100644 --- a/app/code/Magento/RecurringPayment/view/frontend/templates/recurring/grid.phtml +++ b/app/code/Magento/RecurringPayment/view/frontend/templates/recurring/grid.phtml @@ -32,9 +32,6 @@ getGridElements(); ?> - getChildHtml('pager')): ?> -
    getChildHtml('pager'); ?>
    -
    diff --git a/app/code/Magento/Reports/composer.json b/app/code/Magento/Reports/composer.json index 394f1be72ebe8..a1ffb43367285 100644 --- a/app/code/Magento/Reports/composer.json +++ b/app/code/Magento/Reports/composer.json @@ -2,28 +2,28 @@ "name": "magento/module-reports", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-log": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-review": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-downloadable": "0.1.0-alpha89", - "magento/module-sales-rule": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-log": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-review": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-downloadable": "0.1.0-alpha90", + "magento/module-sales-rule": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Reports/etc/adminhtml/acl.xml b/app/code/Magento/Reports/etc/acl.xml similarity index 97% rename from app/code/Magento/Reports/etc/adminhtml/acl.xml rename to app/code/Magento/Reports/etc/acl.xml index 45984f2766ebf..6c65b81e5eb70 100644 --- a/app/code/Magento/Reports/etc/adminhtml/acl.xml +++ b/app/code/Magento/Reports/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Reports/view/frontend/templates/product/widget/viewed/item.phtml b/app/code/Magento/Reports/view/frontend/templates/product/widget/viewed/item.phtml index 532168f0ba5b7..595f87c63e858 100644 --- a/app/code/Magento/Reports/view/frontend/templates/product/widget/viewed/item.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/product/widget/viewed/item.phtml @@ -45,7 +45,14 @@ $rating = 'short'; escapeHtml($item->getName()) ?> - getPriceHtml($item, true, '-' . $type) ?> + getProductPriceHtml( + $item, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-' . $type + ] + ) ?> getReviewsSummaryHtml($item, $rating) ?> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/compared/column/compared_default_list.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/compared/column/compared_default_list.phtml index cd799593ddead..3191111afded1 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/compared/column/compared_default_list.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/compared/column/compared_default_list.phtml @@ -62,7 +62,14 @@ if ($exist = $this->getRecentlyComparedProducts()) { helper('Magento\Catalog\Helper\Output')->productAttribute($_product, $_product->getName(), 'name') ?> - getPriceHtml($_product, true, '-widget-compared-'.$suffix) ?> + getProductPriceHtml( + $_product, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-widget-compared-' . $suffix + ] + ) ?> isSaleable()): ?>
    getTypeInstance()->hasRequiredOptions($_product)): ?> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_grid.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_grid.phtml index 5bda296b6a902..cec10c808cdad 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_grid.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_grid.phtml @@ -68,7 +68,14 @@ if ($exist = $this->getRecentlyComparedProducts()) { escapeHtml($_item->getName()) ?> - getPriceHtml($_item, true, '-' . $type) ?> + getProductPriceHtml( + $_item, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-' . $type + ] + ) ?> getReviewsSummaryHtml($_item, $rating) ?> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_list.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_list.phtml index 19c06d1021b19..49566e2fb98a8 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_list.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/compared/content/compared_list.phtml @@ -68,7 +68,14 @@ if ($exist = $this->getRecentlyComparedProducts()) { escapeHtml($_item->getName()) ?> - getPriceHtml($_item, true, '-' . $type) ?> + getProductPriceHtml( + $_item, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-' . $type + ] + ) ?> getReviewsSummaryHtml($_item, $rating) ?> diff --git a/app/code/Magento/Reports/view/frontend/templates/widget/viewed/column/viewed_default_list.phtml b/app/code/Magento/Reports/view/frontend/templates/widget/viewed/column/viewed_default_list.phtml index ccf3b04bbcf5d..8f9164b5577f6 100644 --- a/app/code/Magento/Reports/view/frontend/templates/widget/viewed/column/viewed_default_list.phtml +++ b/app/code/Magento/Reports/view/frontend/templates/widget/viewed/column/viewed_default_list.phtml @@ -69,20 +69,27 @@ if ($exist = $this->getRecentlyViewedProducts()) { helper('Magento\Catalog\Helper\Output')->productAttribute($_product, $_product->getName(), 'name') ?> - getPriceHtml($_product, true, '-widget-viewed-'.$suffix) ?> + getProductPriceHtml( + $_product, + \Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE, + \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, + [ + 'price_id_suffix' => '-widget-viewed-' . $suffix + ] + ) ?>
    isSaleable()): ?>
    - getTypeInstance()->hasRequiredOptions($_item)): ?> + getTypeInstance()->hasRequiredOptions($_product)): ?> helper('Magento\Core\Helper\PostData'); - $postData = $postDataHelper->getPostData($this->getAddToCartUrl($_item), ['product' => $_item->getEntityId()]); + $postData = $postDataHelper->getPostData($this->getAddToCartUrl($_product), ['product' => $_product->getEntityId()]); ?>
    diff --git a/app/code/Magento/Rss/composer.json b/app/code/Magento/Rss/composer.json index a4696099c4e77..dcef739b2ff34 100644 --- a/app/code/Magento/Rss/composer.json +++ b/app/code/Magento/Rss/composer.json @@ -2,23 +2,23 @@ "name": "magento/module-rss", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-sales-rule": "0.1.0-alpha89", - "magento/module-wishlist": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-review": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-gift-message": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-sales-rule": "0.1.0-alpha90", + "magento/module-wishlist": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-review": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-gift-message": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Rss/etc/adminhtml/acl.xml b/app/code/Magento/Rss/etc/acl.xml similarity index 94% rename from app/code/Magento/Rss/etc/adminhtml/acl.xml rename to app/code/Magento/Rss/etc/acl.xml index b3a7b17e76adc..2b86dd15ddbb0 100644 --- a/app/code/Magento/Rss/etc/adminhtml/acl.xml +++ b/app/code/Magento/Rss/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Rule/composer.json b/app/code/Magento/Rule/composer.json index 665db8299ceca..c673316805af1 100644 --- a/app/code/Magento/Rule/composer.json +++ b/app/code/Magento/Rule/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-rule", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "lib-libxml": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php index f33ac4e591ad5..9de7ad34c3815 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/AbstractCreditmemo/Email.php @@ -24,6 +24,8 @@ */ namespace Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo; +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; + class Email extends \Magento\Backend\App\Action { /** @@ -45,7 +47,11 @@ public function execute() if ($creditmemoId) { $creditmemo = $this->_objectManager->create('Magento\Sales\Model\Order\Creditmemo')->load($creditmemoId); if ($creditmemo) { - $creditmemo->sendEmail(); + /** @var CreditmemoSender $creditmemoSender */ + $creditmemoSender = $this->_objectManager + ->create('Magento\Sales\Model\Order\Email\Sender\CreditmemoSender'); + $creditmemoSender->send($creditmemo); + $historyItem = $this->_objectManager->create( 'Magento\Sales\Model\Resource\Order\Status\History\Collection' )->getUnnotifiedForInstance( diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php index dd60dec7ec33d..207cbeefdb1af 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/Email.php @@ -24,6 +24,8 @@ */ namespace Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice; +use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; + abstract class Email extends \Magento\Backend\App\Action { /** @@ -41,25 +43,33 @@ protected function _isAllowed() */ public function execute() { - if ($invoiceId = $this->getRequest()->getParam('invoice_id')) { - if ($invoice = $this->_objectManager->create('Magento\Sales\Model\Order\Invoice')->load($invoiceId)) { - $invoice->sendEmail(); - $historyItem = $this->_objectManager->create( - 'Magento\Sales\Model\Resource\Order\Status\History\Collection' - )->getUnnotifiedForInstance( - $invoice, - \Magento\Sales\Model\Order\Invoice::HISTORY_ENTITY_NAME - ); - if ($historyItem) { - $historyItem->setIsCustomerNotified(1); - $historyItem->save(); - } - $this->messageManager->addSuccess(__('We sent the message.')); - $this->_redirect( - 'sales/invoice/view', - array('order_id' => $invoice->getOrder()->getId(), 'invoice_id' => $invoiceId) - ); - } + $invoiceId = $this->getRequest()->getParam('invoice_id'); + if (!$invoiceId) { + return; + } + $invoice = $this->_objectManager->create('Magento\Sales\Model\Order\Invoice')->load($invoiceId); + if (!$invoice) { + return; + } + + /** @var InvoiceSender $invoiceSender */ + $invoiceSender = $this->_objectManager->create('Magento\Sales\Model\Order\Email\Sender\InvoiceSender'); + $invoiceSender->send($invoice); + + $historyItem = $this->_objectManager->create( + 'Magento\Sales\Model\Resource\Order\Status\History\Collection' + )->getUnnotifiedForInstance( + $invoice, + \Magento\Sales\Model\Order\Invoice::HISTORY_ENTITY_NAME + ); + if ($historyItem) { + $historyItem->setIsCustomerNotified(1); + $historyItem->save(); } + $this->messageManager->addSuccess(__('We sent the message.')); + $this->_redirect( + 'sales/invoice/view', + array('order_id' => $invoice->getOrder()->getId(), 'invoice_id' => $invoiceId) + ); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php index 161e89acf41a6..ae8584d6809ff 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/AddComment.php @@ -25,6 +25,7 @@ namespace Magento\Sales\Controller\Adminhtml\Order; use \Magento\Backend\App\Action; +use Magento\Sales\Model\Order\Email\Sender\OrderCommentSender; class AddComment extends \Magento\Sales\Controller\Adminhtml\Order { @@ -55,7 +56,11 @@ public function execute() $comment = trim(strip_tags($data['comment'])); $order->save(); - $order->sendOrderUpdateEmail($notify, $comment); + /** @var OrderCommentSender $orderCommentSender */ + $orderCommentSender = $this->_objectManager + ->create('Magento\Sales\Model\Order\Email\Sender\OrderCommentSender'); + + $orderCommentSender->send($order, $notify, $comment); $this->_view->loadLayout('empty'); $this->_view->renderLayout(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php index eba5f4c1422cc..02c9c6ea161c7 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php @@ -25,6 +25,7 @@ namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; use Magento\Backend\App\Action; +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; class AddComment extends \Magento\Backend\App\Action { @@ -33,15 +34,23 @@ class AddComment extends \Magento\Backend\App\Action */ protected $creditmemoLoader; + /** + * @var CreditmemoSender + */ + protected $creditmemoSender; + /** * @param Action\Context $context * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + * @param CreditmemoSender $creditmemoSender */ public function __construct( Action\Context $context, - \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader, + CreditmemoSender $creditmemoSender ) { $this->creditmemoLoader = $creditmemoLoader; + $this->creditmemoSender = $creditmemoSender; parent::__construct($context); } @@ -74,7 +83,8 @@ public function execute() isset($data['is_visible_on_front']) ); $comment->save(); - $creditmemo->sendUpdateEmail(!empty($data['is_customer_notified']), $data['comment']); + + $this->creditmemoSender->send($creditmemo, !empty($data['is_customer_notified']), $data['comment']); $this->_view->loadLayout(); $response = $this->_view->getLayout()->getBlock('creditmemo_comments')->toHtml(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php index bc9d8d695b574..11021c94b9fe0 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php @@ -26,6 +26,7 @@ use \Magento\Sales\Model\Order; use \Magento\Backend\App\Action; +use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; class Save extends \Magento\Backend\App\Action { @@ -34,15 +35,23 @@ class Save extends \Magento\Backend\App\Action */ protected $creditmemoLoader; + /** + * @var CreditmemoSender + */ + protected $creditmemoSender; + /** * @param Action\Context $context * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + * @param CreditmemoSender $creditmemoSender */ public function __construct( Action\Context $context, - \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader + \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader, + CreditmemoSender $creditmemoSender ) { $this->creditmemoLoader = $creditmemoLoader; + $this->creditmemoSender = $creditmemoSender; parent::__construct($context); } @@ -115,7 +124,8 @@ public function execute() $transactionSave->addObject($creditmemo->getInvoice()); } $transactionSave->save(); - $creditmemo->sendEmail(!empty($data['send_email']), $comment); + $this->creditmemoSender->send($creditmemo, !empty($data['send_email']), $comment); + $this->messageManager->addSuccess(__('You created the credit memo.')); $this->_getSession()->getCommentText(true); $this->_redirect('sales/order/view', array('order_id' => $creditmemo->getOrderId())); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php index d4c23da395d87..b5492f4f114da 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Email.php @@ -38,7 +38,12 @@ public function execute() $order = $this->_initOrder(); if ($order) { try { - $order->sendNewOrderEmail(); + /** @var \Magento\Sales\Model\Order\Email\Sender\OrderSender $orderSender */ + $orderSender = $this->_objectManager->create( + 'Magento\Sales\Model\Order\Email\Sender\OrderSender' + ); + $orderSender->send($order); + $historyItem = $this->_objectManager->create( 'Magento\Sales\Model\Resource\Order\Status\History\Collection' )->getUnnotifiedForInstance( diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php index af6483eebe374..1f715e8a264fe 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php @@ -26,6 +26,8 @@ use Magento\Backend\App\Action; use \Magento\Framework\Model\Exception; +use \Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender; +use \Magento\Sales\Model\Order\Invoice; class AddComment extends \Magento\Backend\App\Action { @@ -34,15 +36,23 @@ class AddComment extends \Magento\Backend\App\Action */ protected $invoiceLoader; + /** + * @var InvoiceCommentSender + */ + protected $invoiceCommentSender; + /** * @param Action\Context $context * @param \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader + * @param InvoiceCommentSender $invoiceCommentSender */ public function __construct( Action\Context $context, - \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader + \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader, + InvoiceCommentSender $invoiceCommentSender ) { $this->invoiceLoader = $invoiceLoader; + $this->invoiceCommentSender = $invoiceCommentSender; parent::__construct($context); } @@ -68,13 +78,15 @@ public function execute() throw new Exception(__('The Comment Text field cannot be empty.')); } $this->_title->add(__('Invoices')); + /** @var Invoice $invoice */ $invoice = $this->invoiceLoader->load($this->_request); $invoice->addComment( $data['comment'], isset($data['is_customer_notified']), isset($data['is_visible_on_front']) ); - $invoice->sendUpdateEmail(!empty($data['is_customer_notified']), $data['comment']); + + $this->invoiceCommentSender->send($invoice, !empty($data['is_customer_notified']), $data['comment']); $invoice->save(); $this->_view->loadLayout(); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php index 9b08f15f3e843..ac057bc6beaf6 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php @@ -26,6 +26,9 @@ use \Magento\Framework\Model\Exception; use Magento\Backend\App\Action; +use \Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender; +use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; +use \Magento\Sales\Model\Order\Invoice; class Save extends \Magento\Backend\App\Action { @@ -34,15 +37,31 @@ class Save extends \Magento\Backend\App\Action */ protected $invoiceLoader; + /** + * @var InvoiceCommentSender + */ + protected $invoiceCommentSender; + + /** + * @var ShipmentSender + */ + protected $shipmentSender; + /** * @param Action\Context $context * @param \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader + * @param InvoiceCommentSender $invoiceCommentSender + * @param ShipmentSender $shipmentSender */ public function __construct( Action\Context $context, - \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader + \Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader $invoiceLoader, + InvoiceCommentSender $invoiceCommentSender, + ShipmentSender $shipmentSender ) { $this->invoiceLoader = $invoiceLoader; + $this->invoiceCommentSender = $invoiceCommentSender; + $this->shipmentSender = $shipmentSender; parent::__construct($context); } @@ -104,6 +123,7 @@ public function execute() } try { + /** @var Invoice $invoice */ $invoice = $this->invoiceLoader->load($this->_request); if ($invoice) { @@ -164,14 +184,14 @@ public function execute() $comment = $data['comment_text']; } try { - $invoice->sendEmail(!empty($data['send_email']), $comment); + $this->invoiceCommentSender->send($invoice, !empty($data['send_email']), $comment); } catch (\Exception $e) { $this->_objectManager->get('Magento\Framework\Logger')->logException($e); $this->messageManager->addError(__('We can\'t send the invoice email.')); } if ($shipment) { try { - $shipment->sendEmail(!empty($data['send_email'])); + $this->shipmentSender->send($shipment, !empty($data['send_email'])); } catch (\Exception $e) { $this->_objectManager->get('Magento\Framework\Logger')->logException($e); $this->messageManager->addError(__('We can\'t send the shipment.')); diff --git a/app/code/Magento/Sales/Helper/Data.php b/app/code/Magento/Sales/Helper/Data.php index 73c439cfafe54..6a9ebc8661eea 100644 --- a/app/code/Magento/Sales/Helper/Data.php +++ b/app/code/Magento/Sales/Helper/Data.php @@ -62,7 +62,7 @@ public function checkQuoteAmount(\Magento\Sales\Model\Quote $quote, $amount) public function canSendNewOrderConfirmationEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\OrderIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -88,7 +88,7 @@ public function canSendNewOrderEmail($store = null) public function canSendOrderCommentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -103,7 +103,7 @@ public function canSendOrderCommentEmail($store = null) public function canSendNewShipmentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Shipment::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\ShipmentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -118,7 +118,7 @@ public function canSendNewShipmentEmail($store = null) public function canSendShipmentCommentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Shipment::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -133,7 +133,7 @@ public function canSendShipmentCommentEmail($store = null) public function canSendNewInvoiceEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Invoice::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\InvoiceIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -148,7 +148,7 @@ public function canSendNewInvoiceEmail($store = null) public function canSendInvoiceCommentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Invoice::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -163,7 +163,7 @@ public function canSendInvoiceCommentEmail($store = null) public function canSendNewCreditmemoEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Creditmemo::XML_PATH_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); @@ -178,7 +178,7 @@ public function canSendNewCreditmemoEmail($store = null) public function canSendCreditmemoCommentEmail($store = null) { return $this->_scopeConfig->isSetFlag( - \Magento\Sales\Model\Order\Creditmemo::XML_PATH_UPDATE_EMAIL_ENABLED, + \Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity::XML_PATH_EMAIL_ENABLED, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store ); diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 85b0010452368..f28db0b90f947 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -32,6 +32,7 @@ use Magento\Customer\Service\V1\Data\Customer as CustomerDataObject; use Magento\Customer\Model\Metadata\Form as CustomerForm; use Magento\Customer\Service\V1\Data\Address as CustomerAddressDataObject; +use Magento\Sales\Model\Quote\Item; /** * Order create model @@ -202,6 +203,11 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode */ protected $quoteItemUpdater; + /** + * @var \Magento\Framework\Object\Factory + */ + protected $objectFactory; + /** * @param \Magento\Framework\ObjectManager $objectManager * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -222,7 +228,8 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param EmailSender $emailSender * @param \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService - * @param \Magento\Sales\Model\Quote\Item\Updater $quoteItemUpdater + * @param Item\Updater $quoteItemUpdater + * @param \Magento\Framework\Object\Factory $objectFactory * @param array $data */ public function __construct( @@ -246,6 +253,7 @@ public function __construct( \Magento\Sales\Model\AdminOrder\EmailSender $emailSender, \Magento\CatalogInventory\Service\V1\StockItemService $stockItemService, \Magento\Sales\Model\Quote\Item\Updater $quoteItemUpdater, + \Magento\Framework\Object\Factory $objectFactory, array $data = array() ) { $this->_objectManager = $objectManager; @@ -268,6 +276,7 @@ public function __construct( $this->emailSender = $emailSender; $this->stockItemService = $stockItemService; $this->quoteItemUpdater = $quoteItemUpdater; + $this->objectFactory = $objectFactory; parent::__construct($data); } @@ -998,7 +1007,7 @@ public function updateQuoteItems($items) try { foreach ($items as $itemId => $info) { if (!empty($info['configured'])) { - $item = $this->getQuote()->updateItem($itemId, $this->_objectManager->create($info)); + $item = $this->getQuote()->updateItem($itemId, $this->objectFactory->create($info)); $info['qty'] = (double)$item->getQty(); } else { $item = $this->getQuote()->getItemById($itemId); @@ -1007,7 +1016,7 @@ public function updateQuoteItems($items) } $info['qty'] = (double)$info['qty']; } - $item = $this->quoteItemUpdater->update($item, $info); + $this->quoteItemUpdater->update($item, $info); if ($item && !empty($info['action'])) { $this->moveQuoteItem($item, $info['action'], $item->getQty()); } diff --git a/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php b/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php index 77c549d6f6ca0..2bfc9e5c8550a 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php +++ b/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php @@ -26,6 +26,7 @@ use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Logger; use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Email\Sender\OrderSender; /** * Class EmailSender @@ -33,23 +34,30 @@ class EmailSender { /** - * @var \Magento\Framework\Message\ManagerInterface + * @var ManagerInterface */ protected $messageManager; /** - * @var \Magento\Framework\Logger + * @var Logger */ protected $logger; + /** + * @var OrderSender + */ + protected $orderSender; + /** * @param ManagerInterface $messageManager * @param Logger $logger + * @param OrderSender $orderSender */ - public function __construct(ManagerInterface $messageManager, Logger $logger) + public function __construct(ManagerInterface $messageManager, Logger $logger, OrderSender $orderSender) { $this->messageManager = $messageManager; $this->logger = $logger; + $this->orderSender = $orderSender; } /** @@ -62,7 +70,7 @@ public function __construct(ManagerInterface $messageManager, Logger $logger) public function send(Order $order) { try { - $order->sendNewOrderEmail(); + $this->orderSender->send($order); } catch (\Magento\Framework\Mail\Exception $exception) { $this->logger->logException($exception); $this->messageManager->addWarning( diff --git a/app/code/Magento/Sales/Model/Notifier.php b/app/code/Magento/Sales/Model/Notifier.php new file mode 100644 index 0000000000000..bbe3ebfa38a01 --- /dev/null +++ b/app/code/Magento/Sales/Model/Notifier.php @@ -0,0 +1,96 @@ +historyCollectionFactory = $historyCollectionFactory; + $this->logger = $logger; + $this->orderSender = $orderSender; + } + + /** + * Notify user + * + * @param Order $order + * @return bool + * @throws \Magento\Framework\Mail\Exception + */ + public function notify(\Magento\Sales\Model\Order $order) + { + try { + $this->orderSender->send($order); + if (!$order->getEmailSent()) { + return false; + } + $historyItem = $this->historyCollectionFactory->create()->getUnnotifiedForInstance( + $order, + \Magento\Sales\Model\Order::HISTORY_ENTITY_NAME + ); + if ($historyItem) { + $historyItem->setIsCustomerNotified(1); + $historyItem->save(); + } + } catch (Exception $e) { + $this->logger->logException($e); + return false; + } + return true; + } +} diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index aa7f6b062367f..8a626144a1e51 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -315,33 +315,6 @@ class Order extends \Magento\Sales\Model\AbstractModel { const ENTITY = 'order'; - /** - * XML configuration paths - */ - const XML_PATH_EMAIL_TEMPLATE = 'sales_email/order/template'; - - const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/order/guest_template'; - - const XML_PATH_EMAIL_IDENTITY = 'sales_email/order/identity'; - - const XML_PATH_EMAIL_COPY_TO = 'sales_email/order/copy_to'; - - const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/order/copy_method'; - - const XML_PATH_EMAIL_ENABLED = 'sales_email/order/enabled'; - - const XML_PATH_UPDATE_EMAIL_TEMPLATE = 'sales_email/order_comment/template'; - - const XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE = 'sales_email/order_comment/guest_template'; - - const XML_PATH_UPDATE_EMAIL_IDENTITY = 'sales_email/order_comment/identity'; - - const XML_PATH_UPDATE_EMAIL_COPY_TO = 'sales_email/order_comment/copy_to'; - - const XML_PATH_UPDATE_EMAIL_COPY_METHOD = 'sales_email/order_comment/copy_method'; - - const XML_PATH_UPDATE_EMAIL_ENABLED = 'sales_email/order_comment/enabled'; - /** * Order states */ @@ -487,27 +460,6 @@ class Order extends \Magento\Sales\Model\AbstractModel */ protected $_historyEntityName = self::HISTORY_ENTITY_NAME; - /** - * Sales data - * - * @var \Magento\Sales\Helper\Data - */ - protected $_salesData; - - /** - * Payment data - * - * @var \Magento\Payment\Helper\Data - */ - protected $_paymentData; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - /** * @var \Magento\Store\Model\StoreManagerInterface */ @@ -523,11 +475,6 @@ class Order extends \Magento\Sales\Model\AbstractModel */ protected $_productFactory; - /** - * @var \Magento\Framework\Mail\Template\TransportBuilder - */ - protected $_transportBuilder; - /** * @var \Magento\Sales\Model\Resource\Order\Item\CollectionFactory */ @@ -608,13 +555,9 @@ class Order extends \Magento\Sales\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Sales\Helper\Data $salesData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param Order\Config $orderConfig * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param Resource\Order\Item\CollectionFactory $orderItemCollectionFactory * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\Tax\Model\Calculation $taxCalculation @@ -639,13 +582,9 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Payment\Helper\Data $paymentData, - \Magento\Sales\Helper\Data $salesData, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Config $orderConfig, \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Sales\Model\Resource\Order\Item\CollectionFactory $orderItemCollectionFactory, \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\Tax\Model\Calculation $taxCalculation, @@ -665,13 +604,10 @@ public function __construct( \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_paymentData = $paymentData; - $this->_salesData = $salesData; - $this->_scopeConfig = $scopeConfig; $this->_storeManager = $storeManager; $this->_orderConfig = $orderConfig; $this->_productFactory = $productFactory; - $this->_transportBuilder = $transportBuilder; + $this->_orderItemCollectionFactory = $orderItemCollectionFactory; $this->_productVisibility = $productVisibility; $this->_taxCalculation = $taxCalculation; @@ -1506,232 +1442,6 @@ public function getShippingMethod($asObject = false) } } - /** - * Send email with order data - * - * @return $this - */ - public function sendNewOrderEmail() - { - $storeId = $this->getStore()->getId(); - - if (!$this->_salesData->canSendNewOrderEmail($storeId)) { - return $this; - } - - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - - $paymentBlockHtml = $this->_paymentData->getInfoBlockHtml($this->getPayment(), $storeId); - - // Retrieve corresponding email template id and customer name - if ($this->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $this->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $this->getCustomerName(); - } - - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $this, - 'billing' => $this->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $this->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - - // Email copies are sent as separated emails if their copy method is 'copy' - if ($copyTo && $copyMethod == 'copy') { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $this, - 'billing' => $this->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - $this->setEmailSent(true); - $this->_getResource()->saveAttribute($this, 'email_sent'); - - return $this; - } - - /** - * Send email with order update information - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendOrderUpdateEmail($notifyCustomer = true, $comment = '') - { - $storeId = $this->getStore()->getId(); - - if (!$this->_salesData->canSendOrderCommentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - // Retrieve corresponding email template id and customer name - if ($this->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $this->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $this->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $this, - 'comment' => $comment, - 'billing' => $this->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $this->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is - // 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $this, - 'comment' => $comment, - 'billing' => $this->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - return $this; - } - - /** - * @param string $configPath - * @return array|false - */ - protected function _getEmails($configPath) - { - $data = $this->_scopeConfig->getValue( - $configPath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getStoreId() - ); - if (!empty($data)) { - return explode(',', $data); - } - return false; - } - /*********************** ADDRESSES ***************************/ /** @@ -2628,13 +2338,4 @@ public function isCanceled() { return $this->getState() === self::STATE_CANCELED; } - - /** - * Protect order delete from not admin scope - * @return $this - */ - protected function _beforeDelete() - { - return parent::_beforeDelete(); - } } diff --git a/app/code/Magento/Sales/Model/Order/Address/Validator.php b/app/code/Magento/Sales/Model/Order/Address/Validator.php new file mode 100644 index 0000000000000..13b8b8a5d1161 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Address/Validator.php @@ -0,0 +1,70 @@ +'Parent Order Id', + 'postcode' => 'Zip code', + 'lastname' => 'Last name', + 'street' => 'Street', + 'city' => 'City', + 'email' => 'Email', + 'telephone' => 'Telephone', + 'country_id' => 'Country', + 'firstname' => 'First Name', + 'address_type' => 'Address Type' + ]; + + /** + * + * @param \Magento\Sales\Model\Order\Address $address + * @return array + */ + public function validate(Address $address) + { + $warnings = []; + foreach ($this->required as $code => $label) { + if (!$address->hasData($code)) { + $warnings[] = sprintf('%s is a required field', $label); + } + } + if (!filter_var($address->getEmail(), FILTER_VALIDATE_EMAIL)) { + $warnings[] = 'Email has a wrong format'; + } + if (!filter_var(in_array($address->getAddressType(), [Address::TYPE_BILLING, Address::TYPE_SHIPPING]))) { + $warnings[] = 'Address type doesn\'t match required options'; + } + return $warnings; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index efb987cf10c71..98a0c17d3be36 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -128,30 +128,6 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel const STATE_CANCELED = 3; - const XML_PATH_EMAIL_TEMPLATE = 'sales_email/creditmemo/template'; - - const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/creditmemo/guest_template'; - - const XML_PATH_EMAIL_IDENTITY = 'sales_email/creditmemo/identity'; - - const XML_PATH_EMAIL_COPY_TO = 'sales_email/creditmemo/copy_to'; - - const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/creditmemo/copy_method'; - - const XML_PATH_EMAIL_ENABLED = 'sales_email/creditmemo/enabled'; - - const XML_PATH_UPDATE_EMAIL_TEMPLATE = 'sales_email/creditmemo_comment/template'; - - const XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE = 'sales_email/creditmemo_comment/guest_template'; - - const XML_PATH_UPDATE_EMAIL_IDENTITY = 'sales_email/creditmemo_comment/identity'; - - const XML_PATH_UPDATE_EMAIL_COPY_TO = 'sales_email/creditmemo_comment/copy_to'; - - const XML_PATH_UPDATE_EMAIL_COPY_METHOD = 'sales_email/creditmemo_comment/copy_method'; - - const XML_PATH_UPDATE_EMAIL_ENABLED = 'sales_email/creditmemo_comment/enabled'; - const REPORT_DATE_TYPE_ORDER_CREATED = 'order_created'; const REPORT_DATE_TYPE_REFUND_CREATED = 'refund_created'; @@ -198,27 +174,6 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel */ protected $_eventObject = 'creditmemo'; - /** - * Sales data - * - * @var \Magento\Sales\Helper\Data - */ - protected $_salesData; - - /** - * Payment data - * - * @var \Magento\Payment\Helper\Data - */ - protected $_paymentData; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - /** * @var \Magento\Sales\Model\Order\Creditmemo\Config */ @@ -254,19 +209,11 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel */ protected $_commentCollectionFactory; - /** - * @var \Magento\Framework\Mail\Template\TransportBuilder - */ - protected $_transportBuilder; - /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Sales\Helper\Data $salesData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Creditmemo\Config $creditmemoConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory @@ -274,7 +221,6 @@ class Creditmemo extends \Magento\Sales\Model\AbstractModel * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param Creditmemo\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -284,9 +230,6 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Payment\Helper\Data $paymentData, - \Magento\Sales\Helper\Data $salesData, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sales\Model\Order\Creditmemo\Config $creditmemoConfig, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Item\CollectionFactory $cmItemCollectionFactory, @@ -294,14 +237,10 @@ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\Order\Creditmemo\CommentFactory $commentFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Comment\CollectionFactory $commentCollectionFactory, - \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_paymentData = $paymentData; - $this->_salesData = $salesData; - $this->_scopeConfig = $scopeConfig; $this->_creditmemoConfig = $creditmemoConfig; $this->_orderFactory = $orderFactory; $this->_cmItemCollectionFactory = $cmItemCollectionFactory; @@ -309,7 +248,6 @@ public function __construct( $this->_storeManager = $storeManager; $this->_commentFactory = $commentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; - $this->_transportBuilder = $transportBuilder; parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } @@ -864,253 +802,6 @@ public function getCommentsCollection($reload = false) return $this->_comments; } - /** - * Send email with creditmemo data - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendNewCreditmemoEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - $paymentBlockHtml = $this->_paymentData->getInfoBlockHtml($order->getPayment(), $storeId); - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - $this->setEmailSent(true); - $this->_getResource()->saveAttribute($this, 'email_sent'); - - return $this; - } - - /** - * Send email with creditmemo update information - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendUpdateEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendCreditmemoCommentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'creditmemo' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'creditmemo' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - return $this; - } - - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = $this->_scopeConfig->getValue( - $configPath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getStoreId() - ); - if (!empty($data)) { - return explode(',', $data); - } - return false; - } - - /** - * @return \Magento\Framework\Model\AbstractModel - */ - protected function _beforeDelete() - { - return parent::_beforeDelete(); - } /** * After save object manipulations diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/Container.php b/app/code/Magento/Sales/Model/Order/Email/Container/Container.php new file mode 100644 index 0000000000000..af38cf08fa791 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/Container.php @@ -0,0 +1,152 @@ +scopeConfig = $scopeConfig; + $this->storeManager = $storeManager; + } + /** + * Return store configuration value + * + * @param string $path + * @param int $storeId + * @return mixed + */ + protected function getConfigValue($path, $storeId) + { + return $this->scopeConfig->getValue( + $path, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeId + ); + } + + /** + * Set current store + * + * @param Store $store + * @return void + */ + public function setStore(Store $store) + { + $this->store = $store; + } + + /** + * Return store + * + * @return Store + */ + public function getStore() + { + //current store + if ($this->store instanceof Store) { + return $this->store; + } + return $this->storeManager->getStore(); + } + + /** + * Set customer name + * + * @param string $name + * @return void + */ + public function setCustomerName($name) + { + $this->customerName = $name; + } + + /** + * Set customer email + * + * @param string $email + * @return void + */ + public function setCustomerEmail($email) + { + $this->customerEmail = $email; + } + + /** + * Return customer name + * + * @return string + */ + public function getCustomerName() + { + return $this->customerName; + } + + /** + * Return customer email + * + * @return string + */ + public function getCustomerEmail() + { + return $this->customerEmail; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php new file mode 100644 index 0000000000000..742acef50bb6b --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php @@ -0,0 +1,90 @@ +scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php new file mode 100644 index 0000000000000..b4f72a5662679 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php @@ -0,0 +1,90 @@ +scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/IdentityInterface.php b/app/code/Magento/Sales/Model/Order/Email/Container/IdentityInterface.php new file mode 100644 index 0000000000000..953fc2e4826d2 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/IdentityInterface.php @@ -0,0 +1,92 @@ +scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php new file mode 100644 index 0000000000000..74cdbaf12f23c --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php @@ -0,0 +1,90 @@ +scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php new file mode 100644 index 0000000000000..d9efb6d9d8ff5 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php @@ -0,0 +1,91 @@ +scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php new file mode 100644 index 0000000000000..88f447047f365 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php @@ -0,0 +1,103 @@ +scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * Return email copy_to list + * + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * Return copy method + * + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * Return guest template id + * + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * Return template id + * + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * Return email identity + * + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php new file mode 100644 index 0000000000000..8cbec3f6c7849 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php @@ -0,0 +1,90 @@ +scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php new file mode 100644 index 0000000000000..768109203d851 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php @@ -0,0 +1,106 @@ +scopeConfig->isSetFlag( + self::XML_PATH_EMAIL_ENABLED, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore()->getStoreId() + ); + } + + /** + * Return list of copy_to emails + * + * @return array|bool + */ + public function getEmailCopyTo() + { + $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); + if (!empty($data)) { + return explode(',', $data); + } + return false; + } + + /** + * Return email copy method + * + * @return mixed + */ + public function getCopyMethod() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_COPY_METHOD, $this->getStore()->getStoreId()); + } + + /** + * Return guest template id + * + * @return mixed + */ + public function getGuestTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * Return template id + * + * @return mixed + */ + public function getTemplateId() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_TEMPLATE, $this->getStore()->getStoreId()); + } + + /** + * Return email identity + * + * @return mixed + */ + public function getEmailIdentity() + { + return $this->getConfigValue(self::XML_PATH_EMAIL_IDENTITY, $this->getStore()->getStoreId()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/Template.php b/app/code/Magento/Sales/Model/Order/Email/Container/Template.php new file mode 100644 index 0000000000000..87ed8416bd0ef --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Container/Template.php @@ -0,0 +1,110 @@ +vars = $vars; + } + + /** + * Set email template options + * + * @param array $options + * @return void + */ + public function setTemplateOptions(array $options) + { + $this->options = $options; + } + + /** + * Get email template variables + * + * @return array + */ + public function getTemplateVars() + { + return $this->vars; + } + + /** + * Get email template options + * + * @return array + */ + public function getTemplateOptions() + { + return $this->options; + } + + /** + * Set email template id + * + * @param int $id + * @return void + */ + public function setTemplateId($id) + { + $this->id = $id; + } + + /** + * Get email template id + * + * @return int + */ + public function getTemplateId() + { + return $this->id; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/NotifySender.php b/app/code/Magento/Sales/Model/Order/Email/NotifySender.php new file mode 100644 index 0000000000000..ecb7ceaf50209 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/NotifySender.php @@ -0,0 +1,57 @@ +identityContainer->setStore($order->getStore()); + if (!$this->identityContainer->isEnabled()) { + return false; + } + $this->prepareTemplate($order); + + /** @var SenderBuilder $sender */ + $sender = $this->getSender(); + + if ($notify) { + $sender->send(); + } else { + // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified + $sender->sendCopyTo(); + } + + return true; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender.php b/app/code/Magento/Sales/Model/Order/Email/Sender.php new file mode 100644 index 0000000000000..4e9dcf9868980 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender.php @@ -0,0 +1,127 @@ +templateContainer = $templateContainer; + $this->identityContainer = $identityContainer; + $this->senderBuilderFactory = $senderBuilderFactory; + } + + /** + * @param Order $order + * @return bool + */ + protected function checkAndSend(Order $order) + { + $this->identityContainer->setStore($order->getStore()); + if (!$this->identityContainer->isEnabled()) { + return false; + } + $this->prepareTemplate($order); + + /** @var SenderBuilder $sender */ + $sender = $this->getSender(); + + $sender->send(); + $sender->sendCopyTo(); + + return true; + } + + /** + * @param Order $order + * @return void + */ + protected function prepareTemplate(Order $order) + { + $this->templateContainer->setTemplateOptions($this->getTemplateOptions()); + + if ($order->getCustomerIsGuest()) { + $templateId = $this->identityContainer->getGuestTemplateId(); + $customerName = $order->getBillingAddress()->getName(); + } else { + $templateId = $this->identityContainer->getTemplateId(); + $customerName = $order->getCustomerName(); + } + + $this->identityContainer->setCustomerName($customerName); + $this->identityContainer->setCustomerEmail($order->getCustomerEmail()); + $this->templateContainer->setTemplateId($templateId); + } + + /** + * @return Sender + */ + protected function getSender() + { + return $this->senderBuilderFactory->create( + [ + 'templateContainer' => $this->templateContainer, + 'identityContainer' => $this->identityContainer + ] + ); + } + + /** + * @return array + */ + protected function getTemplateOptions() + { + return [ + 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, + 'store' => $this->identityContainer->getStore()->getStoreId() + ]; + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSender.php new file mode 100644 index 0000000000000..87134a908bc8a --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoCommentSender.php @@ -0,0 +1,70 @@ +getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'creditmemo' => $creditmemo, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'store' => $order->getStore() + ] + ); + + return $this->checkAndSend($order, $notify); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php new file mode 100644 index 0000000000000..c06aa8b344bcb --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/CreditmemoSender.php @@ -0,0 +1,108 @@ +paymentHelper = $paymentHelper; + $this->creditmemoResource = $creditmemoResource; + } + + /** + * Send email to customer + * + * @param Creditmemo $creditmemo + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Creditmemo $creditmemo, $notify = true, $comment = '') + { + $order = $creditmemo->getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $creditmemo->getOrder(), + 'invoice' => $creditmemo, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'payment_html' => $this->getPaymentHtml($order), + 'store' => $order->getStore() + ] + ); + + $result = $this->checkAndSend($order, $notify); + if ($result) { + $creditmemo->setEmailSent(true); + $this->creditmemoResource->saveAttribute($creditmemo, 'email_sent'); + } + return $result; + } + + /** + * Return payment info block as html + * + * @param Order $order + * @return string + */ + protected function getPaymentHtml(Order $order) + { + return $this->paymentHelper->getInfoBlockHtml( + $order->getPayment(), + $this->identityContainer->getStore()->getStoreId() + ); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSender.php new file mode 100644 index 0000000000000..68b8db220778e --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceCommentSender.php @@ -0,0 +1,69 @@ +getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'invoice' => $invoice, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'store' => $order->getStore() + ] + ); + return $this->checkAndSend($order, $notify); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php new file mode 100644 index 0000000000000..f1591bd0a01e4 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php @@ -0,0 +1,107 @@ +paymentHelper = $paymentHelper; + $this->invoiceResource = $invoiceResource; + } + + /** + * Send email to customer + * + * @param Invoice $invoice + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Invoice $invoice, $notify = true, $comment = '') + { + $order = $invoice->getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'invoice' => $invoice, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'payment_html' => $this->getPaymentHtml($order), + 'store' => $order->getStore() + ] + ); + $result = $this->checkAndSend($order, $notify); + if ($result) { + $invoice->setEmailSent(true); + $this->invoiceResource->saveAttribute($invoice, 'email_sent'); + } + return $result; + } + + /** + * Return payment info block as html + * + * @param Order $order + * @return string + */ + protected function getPaymentHtml(Order $order) + { + return $this->paymentHelper->getInfoBlockHtml( + $order->getPayment(), + $this->identityContainer->getStore()->getStoreId() + ); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/OrderCommentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderCommentSender.php new file mode 100644 index 0000000000000..6521085659734 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderCommentSender.php @@ -0,0 +1,66 @@ +templateContainer->setTemplateVars( + [ + 'order' => $order, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'store' => $order->getStore() + ] + ); + return $this->checkAndSend($order, $notify); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php new file mode 100644 index 0000000000000..1e413a3a1ddaf --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php @@ -0,0 +1,112 @@ +paymentHelper = $paymentHelper; + $this->orderResource = $orderResource; + } + + /** + * Send email to customer + * + * @param Order $order + * @return bool + */ + public function send(Order $order) + { + $result = $this->checkAndSend($order); + if ($result) { + $order->setEmailSent(true); + $this->orderResource->saveAttribute($order, 'email_sent'); + } + return $result; + } + + /** + * Prepare email template with variables + * + * @param Order $order + * @return void + */ + protected function prepareTemplate(Order $order) + { + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'billing' => $order->getBillingAddress(), + 'payment_html' => $this->getPaymentHtml($order), + 'store' => $order->getStore() + ] + ); + parent::prepareTemplate($order); + } + + /** + * Get payment info block as html + * + * @param Order $order + * @return string + */ + protected function getPaymentHtml(Order $order) + { + return $this->paymentHelper->getInfoBlockHtml( + $order->getPayment(), + $this->identityContainer->getStore()->getStoreId() + ); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSender.php new file mode 100644 index 0000000000000..4409c9eee3ad9 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentCommentSender.php @@ -0,0 +1,69 @@ +getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'shipment' => $shipment, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'store' => $order->getStore() + ] + ); + return $this->checkAndSend($order, $notify); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php new file mode 100644 index 0000000000000..1b8380bef9715 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/Sender/ShipmentSender.php @@ -0,0 +1,107 @@ +paymentHelper = $paymentHelper; + $this->shipmentResource = $shipmentResource; + } + + /** + * Send email to customer + * + * @param Shipment $shipment + * @param bool $notify + * @param string $comment + * @return bool + */ + public function send(Shipment $shipment, $notify = true, $comment = '') + { + $order = $shipment->getOrder(); + $this->templateContainer->setTemplateVars( + [ + 'order' => $order, + 'shipment' => $shipment, + 'comment' => $comment, + 'billing' => $order->getBillingAddress(), + 'payment_html' => $this->getPaymentHtml($order), + 'store' => $order->getStore() + ] + ); + $result = $this->checkAndSend($order, $notify); + if ($result) { + $shipment->setEmailSent(true); + $this->shipmentResource->saveAttribute($shipment, 'email_sent'); + } + return $result; + } + + /** + * Get payment info block as html + * + * @param Order $order + * @return string + */ + protected function getPaymentHtml(Order $order) + { + return $this->paymentHelper->getInfoBlockHtml( + $order->getPayment(), + $this->identityContainer->getStore()->getStoreId() + ); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php b/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php new file mode 100644 index 0000000000000..68b02e0d0e530 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php @@ -0,0 +1,122 @@ +templateContainer = $templateContainer; + $this->identityContainer = $identityContainer; + $this->transportBuilder = $transportBuilder; + } + + /** + * Prepare and send email message + * + * @return void + */ + public function send() + { + $this->configureEmailTemplate(); + + $this->transportBuilder->addTo( + $this->identityContainer->getCustomerEmail(), + $this->identityContainer->getCustomerName() + ); + + $copyTo = $this->identityContainer->getEmailCopyTo(); + + if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'bcc') { + foreach ($copyTo as $email) { + $this->transportBuilder->addBcc($email); + } + } + + $transport = $this->transportBuilder->getTransport(); + $transport->sendMessage(); + } + + /** + * Prepare and send copy email message + * + * @return void + */ + public function sendCopyTo() + { + $copyTo = $this->identityContainer->getEmailCopyTo(); + + if (!empty($copyTo) && $this->identityContainer->getCopyMethod() == 'copy') { + foreach ($copyTo as $email) { + $this->configureEmailTemplate(); + + $this->transportBuilder->addTo($email); + + $transport = $this->transportBuilder->getTransport(); + $transport->sendMessage(); + } + } + } + + /** + * Configure email template + * + * @return void + */ + protected function configureEmailTemplate() + { + $this->transportBuilder->setTemplateIdentifier($this->templateContainer->getTemplateId()); + $this->transportBuilder->setTemplateOptions($this->templateContainer->getTemplateOptions()); + $this->transportBuilder->setTemplateVars($this->templateContainer->getTemplateVars()); + $this->transportBuilder->setFrom($this->identityContainer->getEmailIdentity()); + } +} diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index 5bdbc6842e50a..f337c6130413f 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -126,30 +126,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel const NOT_CAPTURE = 'not_capture'; - const XML_PATH_EMAIL_TEMPLATE = 'sales_email/invoice/template'; - - const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/invoice/guest_template'; - - const XML_PATH_EMAIL_IDENTITY = 'sales_email/invoice/identity'; - - const XML_PATH_EMAIL_COPY_TO = 'sales_email/invoice/copy_to'; - - const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/invoice/copy_method'; - - const XML_PATH_EMAIL_ENABLED = 'sales_email/invoice/enabled'; - - const XML_PATH_UPDATE_EMAIL_TEMPLATE = 'sales_email/invoice_comment/template'; - - const XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE = 'sales_email/invoice_comment/guest_template'; - - const XML_PATH_UPDATE_EMAIL_IDENTITY = 'sales_email/invoice_comment/identity'; - - const XML_PATH_UPDATE_EMAIL_COPY_TO = 'sales_email/invoice_comment/copy_to'; - - const XML_PATH_UPDATE_EMAIL_COPY_METHOD = 'sales_email/invoice_comment/copy_method'; - - const XML_PATH_UPDATE_EMAIL_ENABLED = 'sales_email/invoice_comment/enabled'; - const REPORT_DATE_TYPE_ORDER_CREATED = 'order_created'; const REPORT_DATE_TYPE_INVOICE_CREATED = 'invoice_created'; @@ -208,27 +184,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel */ protected $_wasPayCalled = false; - /** - * Sales data - * - * @var \Magento\Sales\Helper\Data - */ - protected $_salesData; - - /** - * Payment data - * - * @var \Magento\Payment\Helper\Data - */ - protected $_paymentData; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - /** * @var \Magento\Sales\Model\Order\Invoice\Config */ @@ -264,19 +219,11 @@ class Invoice extends \Magento\Sales\Model\AbstractModel */ protected $_commentCollectionFactory; - /** - * @var \Magento\Framework\Mail\Template\TransportBuilder - */ - protected $_transportBuilder; - /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Sales\Helper\Data $salesData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Invoice\Config $invoiceConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\OrderFactory $orderResourceFactory @@ -284,7 +231,6 @@ class Invoice extends \Magento\Sales\Model\AbstractModel * @param \Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory $invoiceItemCollectionFactory * @param Invoice\CommentFactory $invoiceCommentFactory * @param \Magento\Sales\Model\Resource\Order\Invoice\Comment\CollectionFactory $commentCollectionFactory - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -294,9 +240,6 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Payment\Helper\Data $paymentData, - \Magento\Sales\Helper\Data $salesData, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sales\Model\Order\Invoice\Config $invoiceConfig, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Resource\OrderFactory $orderResourceFactory, @@ -304,14 +247,10 @@ public function __construct( \Magento\Sales\Model\Resource\Order\Invoice\Item\CollectionFactory $invoiceItemCollectionFactory, \Magento\Sales\Model\Order\Invoice\CommentFactory $invoiceCommentFactory, \Magento\Sales\Model\Resource\Order\Invoice\Comment\CollectionFactory $commentCollectionFactory, - \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_paymentData = $paymentData; - $this->_salesData = $salesData; - $this->_scopeConfig = $scopeConfig; $this->_invoiceConfig = $invoiceConfig; $this->_orderFactory = $orderFactory; $this->_orderResourceFactory = $orderResourceFactory; @@ -319,7 +258,6 @@ public function __construct( $this->_invoiceItemCollectionFactory = $invoiceItemCollectionFactory; $this->_invoiceCommentFactory = $invoiceCommentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; - $this->_transportBuilder = $transportBuilder; parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } @@ -874,254 +812,6 @@ public function getCommentsCollection($reload = false) return $this->_comments; } - /** - * Send email with invoice data - * - * @param bool $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendNewInvoiceEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - $paymentBlockHtml = $this->_paymentData->getInfoBlockHtml($order->getPayment(), $storeId); - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - $this->setEmailSent(true); - $this->_getResource()->saveAttribute($this, 'email_sent'); - - return $this; - } - - /** - * Send email with invoice update information - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendUpdateEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendInvoiceCommentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'invoice' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - return $this; - } - - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = $this->_scopeConfig->getValue( - $configPath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getStoreId() - ); - if (!empty($data)) { - return explode(',', $data); - } - return false; - } - - /** - * @return \Magento\Framework\Model\AbstractModel - */ - protected function _beforeDelete() - { - return parent::_beforeDelete(); - } - /** * Reset invoice object * diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index eb55571b54c5e..a4f64eed4dd78 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -57,30 +57,6 @@ class Shipment extends \Magento\Sales\Model\AbstractModel { const STATUS_NEW = 1; - const XML_PATH_EMAIL_TEMPLATE = 'sales_email/shipment/template'; - - const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/shipment/guest_template'; - - const XML_PATH_EMAIL_IDENTITY = 'sales_email/shipment/identity'; - - const XML_PATH_EMAIL_COPY_TO = 'sales_email/shipment/copy_to'; - - const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/shipment/copy_method'; - - const XML_PATH_EMAIL_ENABLED = 'sales_email/shipment/enabled'; - - const XML_PATH_UPDATE_EMAIL_TEMPLATE = 'sales_email/shipment_comment/template'; - - const XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE = 'sales_email/shipment_comment/guest_template'; - - const XML_PATH_UPDATE_EMAIL_IDENTITY = 'sales_email/shipment_comment/identity'; - - const XML_PATH_UPDATE_EMAIL_COPY_TO = 'sales_email/shipment_comment/copy_to'; - - const XML_PATH_UPDATE_EMAIL_COPY_METHOD = 'sales_email/shipment_comment/copy_method'; - - const XML_PATH_UPDATE_EMAIL_ENABLED = 'sales_email/shipment_comment/enabled'; - const REPORT_DATE_TYPE_ORDER_CREATED = 'order_created'; const REPORT_DATE_TYPE_SHIPMENT_CREATED = 'shipment_created'; @@ -135,27 +111,6 @@ class Shipment extends \Magento\Sales\Model\AbstractModel */ protected $_eventObject = 'shipment'; - /** - * Sales data - * - * @var \Magento\Sales\Helper\Data - */ - protected $_salesData; - - /** - * Payment data - * - * @var \Magento\Payment\Helper\Data - */ - protected $_paymentData; - - /** - * Core store config - * - * @var \Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $_scopeConfig; - /** * @var \Magento\Sales\Model\OrderFactory */ @@ -181,25 +136,16 @@ class Shipment extends \Magento\Sales\Model\AbstractModel */ protected $_commentCollectionFactory; - /** - * @var \Magento\Framework\Mail\Template\TransportBuilder - */ - protected $_transportBuilder; - /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Sales\Helper\Data $salesData - * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Sales\Model\OrderFactory $orderFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Item\CollectionFactory $shipmentItemCollectionFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Track\CollectionFactory $trackCollectionFactory * @param Shipment\CommentFactory $commentFactory * @param \Magento\Sales\Model\Resource\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory - * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -209,28 +155,20 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Payment\Helper\Data $paymentData, - \Magento\Sales\Helper\Data $salesData, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\Resource\Order\Shipment\Item\CollectionFactory $shipmentItemCollectionFactory, \Magento\Sales\Model\Resource\Order\Shipment\Track\CollectionFactory $trackCollectionFactory, \Magento\Sales\Model\Order\Shipment\CommentFactory $commentFactory, \Magento\Sales\Model\Resource\Order\Shipment\Comment\CollectionFactory $commentCollectionFactory, - \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() ) { - $this->_paymentData = $paymentData; - $this->_salesData = $salesData; - $this->_scopeConfig = $scopeConfig; $this->_orderFactory = $orderFactory; $this->_shipmentItemCollectionFactory = $shipmentItemCollectionFactory; $this->_trackCollectionFactory = $trackCollectionFactory; $this->_commentFactory = $commentFactory; $this->_commentCollectionFactory = $commentCollectionFactory; - $this->_transportBuilder = $transportBuilder; parent::__construct($context, $registry, $localeDate, $dateTime, $resource, $resourceCollection, $data); } @@ -536,246 +474,6 @@ public function getCommentsCollection($reload = false) return $this->_comments; } - /** - * Send email with shipment data - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendNewShipmentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - $paymentBlockHtml = $this->_paymentData->getInfoBlockHtml($order->getPayment(), $storeId); - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'shipment' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'shipment' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'payment_html' => $paymentBlockHtml, - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - $this->setEmailSent(true); - $this->_getResource()->saveAttribute($this, 'email_sent'); - - return $this; - } - - /** - * Send email with shipment update information - * - * @param boolean $notifyCustomer - * @param string $comment - * @return $this - */ - public function sendUpdateEmail($notifyCustomer = true, $comment = '') - { - $order = $this->getOrder(); - $storeId = $order->getStore()->getId(); - - if (!$this->_salesData->canSendShipmentCommentEmail($storeId)) { - return $this; - } - // Get the destination email addresses to send copies to - $copyTo = $this->_getEmails(self::XML_PATH_UPDATE_EMAIL_COPY_TO); - $copyMethod = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_COPY_METHOD, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - // Check if at least one recipient is found - if (!$notifyCustomer && !$copyTo) { - return $this; - } - - // Retrieve corresponding email template id and customer name - if ($order->getCustomerIsGuest()) { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_GUEST_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getBillingAddress()->getName(); - } else { - $templateId = $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_TEMPLATE, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ); - $customerName = $order->getCustomerName(); - } - - if ($notifyCustomer) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'shipment' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $order->getCustomerEmail(), - $customerName - ); - if ($copyTo && $copyMethod == 'bcc') { - // Add bcc to customer email - foreach ($copyTo as $email) { - $this->_transportBuilder->addBcc($email); - } - } - /** @var \Magento\Framework\Mail\TransportInterface $transport */ - $transport = $this->_transportBuilder->getTransport(); - $transport->sendMessage(); - } - - // Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified - if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) { - foreach ($copyTo as $email) { - $this->_transportBuilder->setTemplateIdentifier( - $templateId - )->setTemplateOptions( - array('area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId) - )->setTemplateVars( - array( - 'order' => $order, - 'shipment' => $this, - 'comment' => $comment, - 'billing' => $order->getBillingAddress(), - 'store' => $this->getStore() - ) - )->setFrom( - $this->_scopeConfig->getValue( - self::XML_PATH_UPDATE_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $storeId - ) - )->addTo( - $email - )->getTransport()->sendMessage(); - } - } - - return $this; - } - - /** - * @param string $configPath - * @return array|bool - */ - protected function _getEmails($configPath) - { - $data = $this->_scopeConfig->getValue( - $configPath, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getStoreId() - ); - if (!empty($data)) { - return explode(',', $data); - } - return false; - } - /** * Before object save * diff --git a/app/code/Magento/Sales/Model/Order/Status/History/Validator.php b/app/code/Magento/Sales/Model/Order/Status/History/Validator.php new file mode 100644 index 0000000000000..ab9e678511835 --- /dev/null +++ b/app/code/Magento/Sales/Model/Order/Status/History/Validator.php @@ -0,0 +1,53 @@ + 'Order Id']; + + /** + * @param History $history + * @return array + */ + public function validate(History $history) + { + $warnings = []; + foreach ($this->requiredFields as $code => $label) { + if (!$history->hasData($code)) { + $warnings[] = sprintf('%s is a required field', $label); + } + } + return $warnings; + } +} diff --git a/app/code/Magento/Sales/Model/Quote/Address.php b/app/code/Magento/Sales/Model/Quote/Address.php index a638c071f1df1..7759ac6c301cd 100644 --- a/app/code/Magento/Sales/Model/Quote/Address.php +++ b/app/code/Magento/Sales/Model/Quote/Address.php @@ -250,6 +250,11 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress */ protected $_customerAdressService; + /** + * @var Address\Validator + */ + protected $validator; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -259,18 +264,19 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Sales\Model\Quote\Address\ItemFactory $addressItemFactory + * @param Address\ItemFactory $addressItemFactory * @param \Magento\Sales\Model\Resource\Quote\Address\Item\CollectionFactory $itemCollectionFactory - * @param \Magento\Sales\Model\Quote\Address\RateFactory $addressRateFactory - * @param \Magento\Sales\Model\Quote\Address\RateCollectorInterfaceFactory $rateCollector + * @param Address\RateFactory $addressRateFactory + * @param Address\RateCollectorInterfaceFactory $rateCollector * @param \Magento\Sales\Model\Resource\Quote\Address\Rate\CollectionFactory $rateCollectionFactory - * @param \Magento\Sales\Model\Quote\Address\RateRequestFactory $rateRequestFactory - * @param \Magento\Sales\Model\Quote\Address\Total\CollectorFactory $totalCollectorFactory - * @param \Magento\Sales\Model\Quote\Address\TotalFactory $addressTotalFactory + * @param Address\RateRequestFactory $rateRequestFactory + * @param Address\Total\CollectorFactory $totalCollectorFactory + * @param Address\TotalFactory $addressTotalFactory * @param \Magento\Framework\Object\Copy $objectCopyService - * @param \Magento\Sales\Model\Quote\Address\CarrierFactoryInterface $carrierFactory + * @param Address\CarrierFactoryInterface $carrierFactory * @param CustomerAddressBuilder $customerAddressBuilder * @param CustomerAddressServiceInterface $customerAddressService + * @param Address\Validator $validator * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data @@ -296,6 +302,7 @@ public function __construct( \Magento\Sales\Model\Quote\Address\CarrierFactoryInterface $carrierFactory, CustomerAddressBuilder $customerAddressBuilder, CustomerAddressServiceInterface $customerAddressService, + Address\Validator $validator, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -313,6 +320,7 @@ public function __construct( $this->_carrierFactory = $carrierFactory; $this->_customerAddressBuilder = $customerAddressBuilder; $this->_customerAdressService = $customerAddressService; + $this->validator = $validator; parent::__construct( $context, $registry, @@ -1390,4 +1398,12 @@ public function getSubtotalWithDiscount() { return $this->getSubtotal() + $this->getDiscountAmount(); } + + /** + * {@inheritdoc} + */ + protected function _getValidationRulesBeforeSave() + { + return $this->validator; + } } diff --git a/app/code/Magento/Sales/Model/Quote/Address/Validator.php b/app/code/Magento/Sales/Model/Quote/Address/Validator.php new file mode 100644 index 0000000000000..e3e5100dd19ff --- /dev/null +++ b/app/code/Magento/Sales/Model/Quote/Address/Validator.php @@ -0,0 +1,76 @@ +countryFactory = $countryFactory; + } + + /** + * Returns true if and only if $value meets the validation requirements + * + * If $value fails validation, then this method returns false, and + * getMessages() will return an array of messages that explain why the + * validation failed. + * + * @param \Magento\Sales\Model\Quote\Address $value + * @return boolean + * @throws Zend_Validate_Exception If validation of $value is impossible + */ + public function isValid($value) + { + $messages = array(); + $email = $value->getEmail(); + if (!empty($email) && !\Zend_Validate::is($email, 'EmailAddress')) { + $messages['invalid_email_format'] = 'Invalid email format'; + } + + $countryId = $value->getCountryId(); + if (!empty($countryId)) { + $country = $this->countryFactory->create(); + $country->load($countryId); + if (!$country->getId()) { + $messages['invalid_country_code'] = 'Invalid country code'; + } + } + + $this->_addMessages($messages); + + return empty($messages); + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php index dd661f198dcb5..7bb0070b82c8f 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Address.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php @@ -40,22 +40,31 @@ class Address extends AbstractOrder */ protected $_salesResourceFactory; + /** + * @var \Magento\Sales\Model\Order\Address\Validator + */ + protected $_validator; + /** * @param \Magento\Framework\App\Resource $resource * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory * @param \Magento\Sales\Model\Resource\Factory $salesResourceFactory + * @param \Magento\Sales\Model\Order\Address\Validator $validator */ public function __construct( \Magento\Framework\App\Resource $resource, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, - \Magento\Sales\Model\Resource\Factory $salesResourceFactory + \Magento\Sales\Model\Resource\Factory $salesResourceFactory, + \Magento\Sales\Model\Order\Address\Validator $validator ) { + $this->_validator = $validator; parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); $this->_salesResourceFactory = $salesResourceFactory; + } /** @@ -91,6 +100,25 @@ public function getAllAttributes() return $attributes; } + /** + * Performs validation before save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + * @throws \Magento\Framework\Model\Exception + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + parent::_beforeSave($object); + $warnings = $this->_validator->validate($object); + if (!empty($warnings)) { + throw new \Magento\Framework\Model\Exception( + __("Cannot save address") . ":\n" . implode("\n", $warnings) + ); + } + return $this; + } + /** * Update related grid table after object save * diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php index 87cc3d2f436e4..ca4f1d4c1e98e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php @@ -23,6 +23,8 @@ */ namespace Magento\Sales\Model\Resource\Order\Status; +use Magento\Sales\Model\Order\Status\History\Validator; + /** * Flat sales order status history resource * @@ -30,6 +32,29 @@ */ class History extends \Magento\Sales\Model\Resource\Order\AbstractOrder { + /** + * @var Validator + */ + protected $validator; + + /** + * @param \Magento\Framework\App\Resource $resource + * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory + * @param Validator $validator + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Eav\Model\Entity\TypeFactory $eavEntityTypeFactory, + Validator $validator + ) { + $this->validator = $validator; + parent::__construct($resource, $dateTime, $eventManager, $eavEntityTypeFactory); + } + /** * Event prefix * @@ -46,4 +71,23 @@ protected function _construct() { $this->_init('sales_flat_order_status_history', 'entity_id'); } + + /** + * Perform actions before object save + * + * @param \Magento\Framework\Model\AbstractModel $object + * @return $this + * @throws \Magento\Framework\Model\Exception + */ + protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) + { + parent::_beforeSave($object); + $warnings = $this->validator->validate($object); + if (!empty($warnings)) { + throw new \Magento\Framework\Model\Exception( + __('Cannot save comment') . ":\n" . implode("\n", $warnings) + ); + } + return $this; + } } diff --git a/app/code/Magento/Sales/Service/V1/Data/Comment.php b/app/code/Magento/Sales/Service/V1/Data/Comment.php new file mode 100644 index 0000000000000..bfe5773e92ec1 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Comment.php @@ -0,0 +1,99 @@ +_get(self::COMMENT); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns is_customer_notified + * + * @return int + */ + public function getIsCustomerNotified() + { + return $this->_get(self::IS_CUSTOMER_NOTIFIED); + } + + /** + * Returns is_visible_on_front + * + * @return int + */ + public function getIsVisibleOnFront() + { + return $this->_get(self::IS_VISIBLE_ON_FRONT); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/Creditmemo.php b/app/code/Magento/Sales/Service/V1/Data/Creditmemo.php new file mode 100644 index 0000000000000..d43bacf41c2aa --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Creditmemo.php @@ -0,0 +1,753 @@ +_get(self::ADJUSTMENT); + } + + /** + * Returns adjustment_negative + * + * @return float + */ + public function getAdjustmentNegative() + { + return $this->_get(self::ADJUSTMENT_NEGATIVE); + } + + /** + * Returns adjustment_positive + * + * @return float + */ + public function getAdjustmentPositive() + { + return $this->_get(self::ADJUSTMENT_POSITIVE); + } + + /** + * Returns base_adjustment + * + * @return float + */ + public function getBaseAdjustment() + { + return $this->_get(self::BASE_ADJUSTMENT); + } + + /** + * Returns base_adjustment_negative + * + * @return float + */ + public function getBaseAdjustmentNegative() + { + return $this->_get(self::BASE_ADJUSTMENT_NEGATIVE); + } + + /** + * Returns base_adjustment_positive + * + * @return float + */ + public function getBaseAdjustmentPositive() + { + return $this->_get(self::BASE_ADJUSTMENT_POSITIVE); + } + + /** + * Returns base_currency_code + * + * @return string + */ + public function getBaseCurrencyCode() + { + return $this->_get(self::BASE_CURRENCY_CODE); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_grand_total + * + * @return float + */ + public function getBaseGrandTotal() + { + return $this->_get(self::BASE_GRAND_TOTAL); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_shipping_amount + * + * @return float + */ + public function getBaseShippingAmount() + { + return $this->_get(self::BASE_SHIPPING_AMOUNT); + } + + /** + * Returns base_shipping_hidden_tax_amnt + * + * @return float + */ + public function getBaseShippingHiddenTaxAmnt() + { + return $this->_get(self::BASE_SHIPPING_HIDDEN_TAX_AMNT); + } + + /** + * Returns base_shipping_incl_tax + * + * @return float + */ + public function getBaseShippingInclTax() + { + return $this->_get(self::BASE_SHIPPING_INCL_TAX); + } + + /** + * Returns base_shipping_tax_amount + * + * @return float + */ + public function getBaseShippingTaxAmount() + { + return $this->_get(self::BASE_SHIPPING_TAX_AMOUNT); + } + + /** + * Returns base_subtotal + * + * @return float + */ + public function getBaseSubtotal() + { + return $this->_get(self::BASE_SUBTOTAL); + } + + /** + * Returns base_subtotal_incl_tax + * + * @return float + */ + public function getBaseSubtotalInclTax() + { + return $this->_get(self::BASE_SUBTOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_to_global_rate + * + * @return float + */ + public function getBaseToGlobalRate() + { + return $this->_get(self::BASE_TO_GLOBAL_RATE); + } + + /** + * Returns base_to_order_rate + * + * @return float + */ + public function getBaseToOrderRate() + { + return $this->_get(self::BASE_TO_ORDER_RATE); + } + + /** + * Returns billing_address_id + * + * @return int + */ + public function getBillingAddressId() + { + return $this->_get(self::BILLING_ADDRESS_ID); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns creditmemo_status + * + * @return int + */ + public function getCreditmemoStatus() + { + return $this->_get(self::CREDITMEMO_STATUS); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns discount_description + * + * @return string + */ + public function getDiscountDescription() + { + return $this->_get(self::DISCOUNT_DESCRIPTION); + } + + /** + * Returns email_sent + * + * @return int + */ + public function getEmailSent() + { + return $this->_get(self::EMAIL_SENT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns global_currency_code + * + * @return string + */ + public function getGlobalCurrencyCode() + { + return $this->_get(self::GLOBAL_CURRENCY_CODE); + } + + /** + * Returns grand_total + * + * @return float + */ + public function getGrandTotal() + { + return $this->_get(self::GRAND_TOTAL); + } + + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns increment_id + * + * @return string + */ + public function getIncrementId() + { + return $this->_get(self::INCREMENT_ID); + } + + /** + * Returns invoice_id + * + * @return int + */ + public function getInvoiceId() + { + return $this->_get(self::INVOICE_ID); + } + + /** + * Returns order_currency_code + * + * @return string + */ + public function getOrderCurrencyCode() + { + return $this->_get(self::ORDER_CURRENCY_CODE); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns shipping_address_id + * + * @return int + */ + public function getShippingAddressId() + { + return $this->_get(self::SHIPPING_ADDRESS_ID); + } + + /** + * Returns shipping_amount + * + * @return float + */ + public function getShippingAmount() + { + return $this->_get(self::SHIPPING_AMOUNT); + } + + /** + * Returns shipping_hidden_tax_amount + * + * @return float + */ + public function getShippingHiddenTaxAmount() + { + return $this->_get(self::SHIPPING_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns shipping_incl_tax + * + * @return float + */ + public function getShippingInclTax() + { + return $this->_get(self::SHIPPING_INCL_TAX); + } + + /** + * Returns shipping_tax_amount + * + * @return float + */ + public function getShippingTaxAmount() + { + return $this->_get(self::SHIPPING_TAX_AMOUNT); + } + + /** + * Returns state + * + * @return int + */ + public function getState() + { + return $this->_get(self::STATE); + } + + /** + * Returns store_currency_code + * + * @return string + */ + public function getStoreCurrencyCode() + { + return $this->_get(self::STORE_CURRENCY_CODE); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns store_to_base_rate + * + * @return float + */ + public function getStoreToBaseRate() + { + return $this->_get(self::STORE_TO_BASE_RATE); + } + + /** + * Returns store_to_order_rate + * + * @return float + */ + public function getStoreToOrderRate() + { + return $this->_get(self::STORE_TO_ORDER_RATE); + } + + /** + * Returns subtotal + * + * @return float + */ + public function getSubtotal() + { + return $this->_get(self::SUBTOTAL); + } + + /** + * Returns subtotal_incl_tax + * + * @return float + */ + public function getSubtotalInclTax() + { + return $this->_get(self::SUBTOTAL_INCL_TAX); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns transaction_id + * + * @return string + */ + public function getTransactionId() + { + return $this->_get(self::TRANSACTION_ID); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php b/app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php new file mode 100644 index 0000000000000..26e097b26e147 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/CreditmemoComment.php @@ -0,0 +1,122 @@ +_get(self::COMMENT); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns is_customer_notified + * + * @return int + */ + public function getIsCustomerNotified() + { + return $this->_get(self::IS_CUSTOMER_NOTIFIED); + } + + /** + * Returns is_visible_on_front + * + * @return int + */ + public function getIsVisibleOnFront() + { + return $this->_get(self::IS_VISIBLE_ON_FRONT); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/CreditmemoItem.php b/app/code/Magento/Sales/Service/V1/Data/CreditmemoItem.php new file mode 100644 index 0000000000000..6a4a50a1a79a7 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/CreditmemoItem.php @@ -0,0 +1,527 @@ +_get(self::ADDITIONAL_DATA); + } + + /** + * Returns base_cost + * + * @return float + */ + public function getBaseCost() + { + return $this->_get(self::BASE_COST); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_price + * + * @return float + */ + public function getBasePrice() + { + return $this->_get(self::BASE_PRICE); + } + + /** + * Returns base_price_incl_tax + * + * @return float + */ + public function getBasePriceInclTax() + { + return $this->_get(self::BASE_PRICE_INCL_TAX); + } + + /** + * Returns base_row_total + * + * @return float + */ + public function getBaseRowTotal() + { + return $this->_get(self::BASE_ROW_TOTAL); + } + + /** + * Returns base_row_total_incl_tax + * + * @return float + */ + public function getBaseRowTotalInclTax() + { + return $this->_get(self::BASE_ROW_TOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_weee_tax_applied_amount + * + * @return float + */ + public function getBaseWeeeTaxAppliedAmount() + { + return $this->_get(self::BASE_WEEE_TAX_APPLIED_AMOUNT); + } + + /** + * Returns base_weee_tax_applied_row_amnt + * + * @return float + */ + public function getBaseWeeeTaxAppliedRowAmnt() + { + return $this->_get(self::BASE_WEEE_TAX_APPLIED_ROW_AMNT); + } + + /** + * Returns base_weee_tax_disposition + * + * @return float + */ + public function getBaseWeeeTaxDisposition() + { + return $this->_get(self::BASE_WEEE_TAX_DISPOSITION); + } + + /** + * Returns base_weee_tax_row_disposition + * + * @return float + */ + public function getBaseWeeeTaxRowDisposition() + { + return $this->_get(self::BASE_WEEE_TAX_ROW_DISPOSITION); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns name + * + * @return string + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * Returns order_item_id + * + * @return int + */ + public function getOrderItemId() + { + return $this->_get(self::ORDER_ITEM_ID); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns price + * + * @return float + */ + public function getPrice() + { + return $this->_get(self::PRICE); + } + + /** + * Returns price_incl_tax + * + * @return float + */ + public function getPriceInclTax() + { + return $this->_get(self::PRICE_INCL_TAX); + } + + /** + * Returns product_id + * + * @return int + */ + public function getProductId() + { + return $this->_get(self::PRODUCT_ID); + } + + /** + * Returns qty + * + * @return float + */ + public function getQty() + { + return $this->_get(self::QTY); + } + + /** + * Returns row_total + * + * @return float + */ + public function getRowTotal() + { + return $this->_get(self::ROW_TOTAL); + } + + /** + * Returns row_total_incl_tax + * + * @return float + */ + public function getRowTotalInclTax() + { + return $this->_get(self::ROW_TOTAL_INCL_TAX); + } + + /** + * Returns sku + * + * @return string + */ + public function getSku() + { + return $this->_get(self::SKU); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns weee_tax_applied + * + * @return string + */ + public function getWeeeTaxApplied() + { + return $this->_get(self::WEEE_TAX_APPLIED); + } + + /** + * Returns weee_tax_applied_amount + * + * @return float + */ + public function getWeeeTaxAppliedAmount() + { + return $this->_get(self::WEEE_TAX_APPLIED_AMOUNT); + } + + /** + * Returns weee_tax_applied_row_amount + * + * @return float + */ + public function getWeeeTaxAppliedRowAmount() + { + return $this->_get(self::WEEE_TAX_APPLIED_ROW_AMOUNT); + } + + /** + * Returns weee_tax_disposition + * + * @return float + */ + public function getWeeeTaxDisposition() + { + return $this->_get(self::WEEE_TAX_DISPOSITION); + } + + /** + * Returns weee_tax_row_disposition + * + * @return float + */ + public function getWeeeTaxRowDisposition() + { + return $this->_get(self::WEEE_TAX_ROW_DISPOSITION); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/Invoice.php b/app/code/Magento/Sales/Service/V1/Data/Invoice.php new file mode 100644 index 0000000000000..08ed2599cf09b --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Invoice.php @@ -0,0 +1,539 @@ +_get(self::BASE_CURRENCY_CODE); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_grand_total + * + * @return float + */ + public function getBaseGrandTotal() + { + return $this->_get(self::BASE_GRAND_TOTAL); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_shipping_amount + * + * @return float + */ + public function getBaseShippingAmount() + { + return $this->_get(self::BASE_SHIPPING_AMOUNT); + } + + /** + * Returns base_shipping_hidden_tax_amnt + * + * @return float + */ + public function getBaseShippingHiddenTaxAmnt() + { + return $this->_get(self::BASE_SHIPPING_HIDDEN_TAX_AMNT); + } + + /** + * Returns base_shipping_incl_tax + * + * @return float + */ + public function getBaseShippingInclTax() + { + return $this->_get(self::BASE_SHIPPING_INCL_TAX); + } + + /** + * Returns base_shipping_tax_amount + * + * @return float + */ + public function getBaseShippingTaxAmount() + { + return $this->_get(self::BASE_SHIPPING_TAX_AMOUNT); + } + + /** + * Returns base_subtotal + * + * @return float + */ + public function getBaseSubtotal() + { + return $this->_get(self::BASE_SUBTOTAL); + } + + /** + * Returns base_subtotal_incl_tax + * + * @return float + */ + public function getBaseSubtotalInclTax() + { + return $this->_get(self::BASE_SUBTOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_total_refunded + * + * @return float + */ + public function getBaseTotalRefunded() + { + return $this->_get(self::BASE_TOTAL_REFUNDED); + } + + /** + * Returns base_to_global_rate + * + * @return float + */ + public function getBaseToGlobalRate() + { + return $this->_get(self::BASE_TO_GLOBAL_RATE); + } + + /** + * Returns base_to_order_rate + * + * @return float + */ + public function getBaseToOrderRate() + { + return $this->_get(self::BASE_TO_ORDER_RATE); + } + + /** + * Returns billing_address_id + * + * @return int + */ + public function getBillingAddressId() + { + return $this->_get(self::BILLING_ADDRESS_ID); + } + + /** + * Returns can_void_flag + * + * @return int + */ + public function getCanVoidFlag() + { + return $this->_get(self::CAN_VOID_FLAG); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns discount_description + * + * @return string + */ + public function getDiscountDescription() + { + return $this->_get(self::DISCOUNT_DESCRIPTION); + } + + /** + * Returns email_sent + * + * @return int + */ + public function getEmailSent() + { + return $this->_get(self::EMAIL_SENT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns global_currency_code + * + * @return string + */ + public function getGlobalCurrencyCode() + { + return $this->_get(self::GLOBAL_CURRENCY_CODE); + } + + /** + * Returns grand_total + * + * @return float + */ + public function getGrandTotal() + { + return $this->_get(self::GRAND_TOTAL); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns increment_id + * + * @return string + */ + public function getIncrementId() + { + return $this->_get(self::INCREMENT_ID); + } + + /** + * Returns is_used_for_refund + * + * @return int + */ + public function getIsUsedForRefund() + { + return $this->_get(self::IS_USED_FOR_REFUND); + } + + /** + * Returns order_currency_code + * + * @return string + */ + public function getOrderCurrencyCode() + { + return $this->_get(self::ORDER_CURRENCY_CODE); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns shipping_address_id + * + * @return int + */ + public function getShippingAddressId() + { + return $this->_get(self::SHIPPING_ADDRESS_ID); + } + + /** + * Returns shipping_amount + * + * @return float + */ + public function getShippingAmount() + { + return $this->_get(self::SHIPPING_AMOUNT); + } + + /** + * Returns shipping_hidden_tax_amount + * + * @return float + */ + public function getShippingHiddenTaxAmount() + { + return $this->_get(self::SHIPPING_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns shipping_incl_tax + * + * @return float + */ + public function getShippingInclTax() + { + return $this->_get(self::SHIPPING_INCL_TAX); + } + + /** + * Returns shipping_tax_amount + * + * @return float + */ + public function getShippingTaxAmount() + { + return $this->_get(self::SHIPPING_TAX_AMOUNT); + } + + /** + * Returns state + * + * @return int + */ + public function getState() + { + return $this->_get(self::STATE); + } + + /** + * Returns store_currency_code + * + * @return string + */ + public function getStoreCurrencyCode() + { + return $this->_get(self::STORE_CURRENCY_CODE); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns store_to_base_rate + * + * @return float + */ + public function getStoreToBaseRate() + { + return $this->_get(self::STORE_TO_BASE_RATE); + } + + /** + * Returns store_to_order_rate + * + * @return float + */ + public function getStoreToOrderRate() + { + return $this->_get(self::STORE_TO_ORDER_RATE); + } + + /** + * Returns subtotal + * + * @return float + */ + public function getSubtotal() + { + return $this->_get(self::SUBTOTAL); + } + + /** + * Returns subtotal_incl_tax + * + * @return float + */ + public function getSubtotalInclTax() + { + return $this->_get(self::SUBTOTAL_INCL_TAX); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns total_qty + * + * @return float + */ + public function getTotalQty() + { + return $this->_get(self::TOTAL_QTY); + } + + /** + * Returns transaction_id + * + * @return string + */ + public function getTransactionId() + { + return $this->_get(self::TRANSACTION_ID); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } + + /** + * Returns invoice items + * + * @return InvoiceItem[] + */ + public function getItems() + { + return $this->_get(self::ITEMS); + } + + /** + * Return invoice comments + * + * @return Comment[] + */ + public function getComments() + { + return $this->_get(self::COMMENTS); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php b/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php new file mode 100644 index 0000000000000..dd3865fe5b9d3 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/InvoiceItem.php @@ -0,0 +1,392 @@ +_get(self::ADDITIONAL_DATA); + } + + /** + * Returns base_cost + * + * @return float + */ + public function getBaseCost() + { + return $this->_get(self::BASE_COST); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_price + * + * @return float + */ + public function getBasePrice() + { + return $this->_get(self::BASE_PRICE); + } + + /** + * Returns base_price_incl_tax + * + * @return float + */ + public function getBasePriceInclTax() + { + return $this->_get(self::BASE_PRICE_INCL_TAX); + } + + /** + * Returns base_row_total + * + * @return float + */ + public function getBaseRowTotal() + { + return $this->_get(self::BASE_ROW_TOTAL); + } + + /** + * Returns base_row_total_incl_tax + * + * @return float + */ + public function getBaseRowTotalInclTax() + { + return $this->_get(self::BASE_ROW_TOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns name + * + * @return string + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * Returns order_item_id + * + * @return int + */ + public function getOrderItemId() + { + return $this->_get(self::ORDER_ITEM_ID); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns price + * + * @return float + */ + public function getPrice() + { + return $this->_get(self::PRICE); + } + + /** + * Returns price_incl_tax + * + * @return float + */ + public function getPriceInclTax() + { + return $this->_get(self::PRICE_INCL_TAX); + } + + /** + * Returns product_id + * + * @return int + */ + public function getProductId() + { + return $this->_get(self::PRODUCT_ID); + } + + /** + * Returns qty + * + * @return float + */ + public function getQty() + { + return $this->_get(self::QTY); + } + + /** + * Returns row_total + * + * @return float + */ + public function getRowTotal() + { + return $this->_get(self::ROW_TOTAL); + } + + /** + * Returns row_total_incl_tax + * + * @return float + */ + public function getRowTotalInclTax() + { + return $this->_get(self::ROW_TOTAL_INCL_TAX); + } + + /** + * Returns sku + * + * @return string + */ + public function getSku() + { + return $this->_get(self::SKU); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/Order.php b/app/code/Magento/Sales/Service/V1/Data/Order.php new file mode 100644 index 0000000000000..7205f8c661897 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Order.php @@ -0,0 +1,1542 @@ +_get(self::ADJUSTMENT_NEGATIVE); + } + + /** + * Returns adjustment_positive + * + * @return float + */ + public function getAdjustmentPositive() + { + return $this->_get(self::ADJUSTMENT_POSITIVE); + } + + /** + * Returns applied_rule_ids + * + * @return string + */ + public function getAppliedRuleIds() + { + return $this->_get(self::APPLIED_RULE_IDS); + } + + /** + * Returns base_adjustment_negative + * + * @return float + */ + public function getBaseAdjustmentNegative() + { + return $this->_get(self::BASE_ADJUSTMENT_NEGATIVE); + } + + /** + * Returns base_adjustment_positive + * + * @return float + */ + public function getBaseAdjustmentPositive() + { + return $this->_get(self::BASE_ADJUSTMENT_POSITIVE); + } + + /** + * Returns base_currency_code + * + * @return string + */ + public function getBaseCurrencyCode() + { + return $this->_get(self::BASE_CURRENCY_CODE); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_discount_canceled + * + * @return float + */ + public function getBaseDiscountCanceled() + { + return $this->_get(self::BASE_DISCOUNT_CANCELED); + } + + /** + * Returns base_discount_invoiced + * + * @return float + */ + public function getBaseDiscountInvoiced() + { + return $this->_get(self::BASE_DISCOUNT_INVOICED); + } + + /** + * Returns base_discount_refunded + * + * @return float + */ + public function getBaseDiscountRefunded() + { + return $this->_get(self::BASE_DISCOUNT_REFUNDED); + } + + /** + * Returns base_grand_total + * + * @return float + */ + public function getBaseGrandTotal() + { + return $this->_get(self::BASE_GRAND_TOTAL); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_hidden_tax_invoiced + * + * @return float + */ + public function getBaseHiddenTaxInvoiced() + { + return $this->_get(self::BASE_HIDDEN_TAX_INVOICED); + } + + /** + * Returns base_hidden_tax_refunded + * + * @return float + */ + public function getBaseHiddenTaxRefunded() + { + return $this->_get(self::BASE_HIDDEN_TAX_REFUNDED); + } + + /** + * Returns base_shipping_amount + * + * @return float + */ + public function getBaseShippingAmount() + { + return $this->_get(self::BASE_SHIPPING_AMOUNT); + } + + /** + * Returns base_shipping_canceled + * + * @return float + */ + public function getBaseShippingCanceled() + { + return $this->_get(self::BASE_SHIPPING_CANCELED); + } + + /** + * Returns base_shipping_discount_amount + * + * @return float + */ + public function getBaseShippingDiscountAmount() + { + return $this->_get(self::BASE_SHIPPING_DISCOUNT_AMOUNT); + } + + /** + * Returns base_shipping_hidden_tax_amnt + * + * @return float + */ + public function getBaseShippingHiddenTaxAmnt() + { + return $this->_get(self::BASE_SHIPPING_HIDDEN_TAX_AMNT); + } + + /** + * Returns base_shipping_incl_tax + * + * @return float + */ + public function getBaseShippingInclTax() + { + return $this->_get(self::BASE_SHIPPING_INCL_TAX); + } + + /** + * Returns base_shipping_invoiced + * + * @return float + */ + public function getBaseShippingInvoiced() + { + return $this->_get(self::BASE_SHIPPING_INVOICED); + } + + /** + * Returns base_shipping_refunded + * + * @return float + */ + public function getBaseShippingRefunded() + { + return $this->_get(self::BASE_SHIPPING_REFUNDED); + } + + /** + * Returns base_shipping_tax_amount + * + * @return float + */ + public function getBaseShippingTaxAmount() + { + return $this->_get(self::BASE_SHIPPING_TAX_AMOUNT); + } + + /** + * Returns base_shipping_tax_refunded + * + * @return float + */ + public function getBaseShippingTaxRefunded() + { + return $this->_get(self::BASE_SHIPPING_TAX_REFUNDED); + } + + /** + * Returns base_subtotal + * + * @return float + */ + public function getBaseSubtotal() + { + return $this->_get(self::BASE_SUBTOTAL); + } + + /** + * Returns base_subtotal_canceled + * + * @return float + */ + public function getBaseSubtotalCanceled() + { + return $this->_get(self::BASE_SUBTOTAL_CANCELED); + } + + /** + * Returns base_subtotal_incl_tax + * + * @return float + */ + public function getBaseSubtotalInclTax() + { + return $this->_get(self::BASE_SUBTOTAL_INCL_TAX); + } + + /** + * Returns base_subtotal_invoiced + * + * @return float + */ + public function getBaseSubtotalInvoiced() + { + return $this->_get(self::BASE_SUBTOTAL_INVOICED); + } + + /** + * Returns base_subtotal_refunded + * + * @return float + */ + public function getBaseSubtotalRefunded() + { + return $this->_get(self::BASE_SUBTOTAL_REFUNDED); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_tax_canceled + * + * @return float + */ + public function getBaseTaxCanceled() + { + return $this->_get(self::BASE_TAX_CANCELED); + } + + /** + * Returns base_tax_invoiced + * + * @return float + */ + public function getBaseTaxInvoiced() + { + return $this->_get(self::BASE_TAX_INVOICED); + } + + /** + * Returns base_tax_refunded + * + * @return float + */ + public function getBaseTaxRefunded() + { + return $this->_get(self::BASE_TAX_REFUNDED); + } + + /** + * Returns base_total_canceled + * + * @return float + */ + public function getBaseTotalCanceled() + { + return $this->_get(self::BASE_TOTAL_CANCELED); + } + + /** + * Returns base_total_due + * + * @return float + */ + public function getBaseTotalDue() + { + return $this->_get(self::BASE_TOTAL_DUE); + } + + /** + * Returns base_total_invoiced + * + * @return float + */ + public function getBaseTotalInvoiced() + { + return $this->_get(self::BASE_TOTAL_INVOICED); + } + + /** + * Returns base_total_invoiced_cost + * + * @return float + */ + public function getBaseTotalInvoicedCost() + { + return $this->_get(self::BASE_TOTAL_INVOICED_COST); + } + + /** + * Returns base_total_offline_refunded + * + * @return float + */ + public function getBaseTotalOfflineRefunded() + { + return $this->_get(self::BASE_TOTAL_OFFLINE_REFUNDED); + } + + /** + * Returns base_total_online_refunded + * + * @return float + */ + public function getBaseTotalOnlineRefunded() + { + return $this->_get(self::BASE_TOTAL_ONLINE_REFUNDED); + } + + /** + * Returns base_total_paid + * + * @return float + */ + public function getBaseTotalPaid() + { + return $this->_get(self::BASE_TOTAL_PAID); + } + + /** + * Returns base_total_qty_ordered + * + * @return float + */ + public function getBaseTotalQtyOrdered() + { + return $this->_get(self::BASE_TOTAL_QTY_ORDERED); + } + + /** + * Returns base_total_refunded + * + * @return float + */ + public function getBaseTotalRefunded() + { + return $this->_get(self::BASE_TOTAL_REFUNDED); + } + + /** + * Returns base_to_global_rate + * + * @return float + */ + public function getBaseToGlobalRate() + { + return $this->_get(self::BASE_TO_GLOBAL_RATE); + } + + /** + * Returns base_to_order_rate + * + * @return float + */ + public function getBaseToOrderRate() + { + return $this->_get(self::BASE_TO_ORDER_RATE); + } + + /** + * Returns billing_address_id + * + * @return int + */ + public function getBillingAddressId() + { + return $this->_get(self::BILLING_ADDRESS_ID); + } + + /** + * Returns can_ship_partially + * + * @return int + */ + public function getCanShipPartially() + { + return $this->_get(self::CAN_SHIP_PARTIALLY); + } + + /** + * Returns can_ship_partially_item + * + * @return int + */ + public function getCanShipPartiallyItem() + { + return $this->_get(self::CAN_SHIP_PARTIALLY_ITEM); + } + + /** + * Returns coupon_code + * + * @return string + */ + public function getCouponCode() + { + return $this->_get(self::COUPON_CODE); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns customer_dob + * + * @return string + */ + public function getCustomerDob() + { + return $this->_get(self::CUSTOMER_DOB); + } + + /** + * Returns customer_email + * + * @return string + */ + public function getCustomerEmail() + { + return $this->_get(self::CUSTOMER_EMAIL); + } + + /** + * Returns customer_firstname + * + * @return string + */ + public function getCustomerFirstname() + { + return $this->_get(self::CUSTOMER_FIRSTNAME); + } + + /** + * Returns customer_gender + * + * @return int + */ + public function getCustomerGender() + { + return $this->_get(self::CUSTOMER_GENDER); + } + + /** + * Returns customer_group_id + * + * @return int + */ + public function getCustomerGroupId() + { + return $this->_get(self::CUSTOMER_GROUP_ID); + } + + /** + * Returns customer_id + * + * @return int + */ + public function getCustomerId() + { + return $this->_get(self::CUSTOMER_ID); + } + + /** + * Returns customer_is_guest + * + * @return int + */ + public function getCustomerIsGuest() + { + return $this->_get(self::CUSTOMER_IS_GUEST); + } + + /** + * Returns customer_lastname + * + * @return string + */ + public function getCustomerLastname() + { + return $this->_get(self::CUSTOMER_LASTNAME); + } + + /** + * Returns customer_middlename + * + * @return string + */ + public function getCustomerMiddlename() + { + return $this->_get(self::CUSTOMER_MIDDLENAME); + } + + /** + * Returns customer_note + * + * @return string + */ + public function getCustomerNote() + { + return $this->_get(self::CUSTOMER_NOTE); + } + + /** + * Returns customer_note_notify + * + * @return int + */ + public function getCustomerNoteNotify() + { + return $this->_get(self::CUSTOMER_NOTE_NOTIFY); + } + + /** + * Returns customer_prefix + * + * @return string + */ + public function getCustomerPrefix() + { + return $this->_get(self::CUSTOMER_PREFIX); + } + + /** + * Returns customer_suffix + * + * @return string + */ + public function getCustomerSuffix() + { + return $this->_get(self::CUSTOMER_SUFFIX); + } + + /** + * Returns customer_taxvat + * + * @return string + */ + public function getCustomerTaxvat() + { + return $this->_get(self::CUSTOMER_TAXVAT); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns discount_canceled + * + * @return float + */ + public function getDiscountCanceled() + { + return $this->_get(self::DISCOUNT_CANCELED); + } + + /** + * Returns discount_description + * + * @return string + */ + public function getDiscountDescription() + { + return $this->_get(self::DISCOUNT_DESCRIPTION); + } + + /** + * Returns discount_invoiced + * + * @return float + */ + public function getDiscountInvoiced() + { + return $this->_get(self::DISCOUNT_INVOICED); + } + + /** + * Returns discount_refunded + * + * @return float + */ + public function getDiscountRefunded() + { + return $this->_get(self::DISCOUNT_REFUNDED); + } + + /** + * Returns edit_increment + * + * @return int + */ + public function getEditIncrement() + { + return $this->_get(self::EDIT_INCREMENT); + } + + /** + * Returns email_sent + * + * @return int + */ + public function getEmailSent() + { + return $this->_get(self::EMAIL_SENT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns ext_customer_id + * + * @return string + */ + public function getExtCustomerId() + { + return $this->_get(self::EXT_CUSTOMER_ID); + } + + /** + * Returns ext_order_id + * + * @return string + */ + public function getExtOrderId() + { + return $this->_get(self::EXT_ORDER_ID); + } + + /** + * Returns forced_shipment_with_invoice + * + * @return int + */ + public function getForcedShipmentWithInvoice() + { + return $this->_get(self::FORCED_SHIPMENT_WITH_INVOICE); + } + + /** + * Returns global_currency_code + * + * @return string + */ + public function getGlobalCurrencyCode() + { + return $this->_get(self::GLOBAL_CURRENCY_CODE); + } + + /** + * Returns grand_total + * + * @return float + */ + public function getGrandTotal() + { + return $this->_get(self::GRAND_TOTAL); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns hidden_tax_invoiced + * + * @return float + */ + public function getHiddenTaxInvoiced() + { + return $this->_get(self::HIDDEN_TAX_INVOICED); + } + + /** + * Returns hidden_tax_refunded + * + * @return float + */ + public function getHiddenTaxRefunded() + { + return $this->_get(self::HIDDEN_TAX_REFUNDED); + } + + /** + * Returns hold_before_state + * + * @return string + */ + public function getHoldBeforeState() + { + return $this->_get(self::HOLD_BEFORE_STATE); + } + + /** + * Returns hold_before_status + * + * @return string + */ + public function getHoldBeforeStatus() + { + return $this->_get(self::HOLD_BEFORE_STATUS); + } + + /** + * Returns increment_id + * + * @return string + */ + public function getIncrementId() + { + return $this->_get(self::INCREMENT_ID); + } + + /** + * Returns is_virtual + * + * @return int + */ + public function getIsVirtual() + { + return $this->_get(self::IS_VIRTUAL); + } + + /** + * Returns order_currency_code + * + * @return string + */ + public function getOrderCurrencyCode() + { + return $this->_get(self::ORDER_CURRENCY_CODE); + } + + /** + * Returns original_increment_id + * + * @return string + */ + public function getOriginalIncrementId() + { + return $this->_get(self::ORIGINAL_INCREMENT_ID); + } + + /** + * Returns payment_authorization_amount + * + * @return float + */ + public function getPaymentAuthorizationAmount() + { + return $this->_get(self::PAYMENT_AUTHORIZATION_AMOUNT); + } + + /** + * Returns payment_auth_expiration + * + * @return int + */ + public function getPaymentAuthExpiration() + { + return $this->_get(self::PAYMENT_AUTH_EXPIRATION); + } + + /** + * Returns protect_code + * + * @return string + */ + public function getProtectCode() + { + return $this->_get(self::PROTECT_CODE); + } + + /** + * Returns quote_address_id + * + * @return int + */ + public function getQuoteAddressId() + { + return $this->_get(self::QUOTE_ADDRESS_ID); + } + + /** + * Returns quote_id + * + * @return int + */ + public function getQuoteId() + { + return $this->_get(self::QUOTE_ID); + } + + /** + * Returns relation_child_id + * + * @return string + */ + public function getRelationChildId() + { + return $this->_get(self::RELATION_CHILD_ID); + } + + /** + * Returns relation_child_real_id + * + * @return string + */ + public function getRelationChildRealId() + { + return $this->_get(self::RELATION_CHILD_REAL_ID); + } + + /** + * Returns relation_parent_id + * + * @return string + */ + public function getRelationParentId() + { + return $this->_get(self::RELATION_PARENT_ID); + } + + /** + * Returns relation_parent_real_id + * + * @return string + */ + public function getRelationParentRealId() + { + return $this->_get(self::RELATION_PARENT_REAL_ID); + } + + /** + * Returns remote_ip + * + * @return string + */ + public function getRemoteIp() + { + return $this->_get(self::REMOTE_IP); + } + + /** + * Returns shipping_address_id + * + * @return int + */ + public function getShippingAddressId() + { + return $this->_get(self::SHIPPING_ADDRESS_ID); + } + + /** + * Returns shipping_amount + * + * @return float + */ + public function getShippingAmount() + { + return $this->_get(self::SHIPPING_AMOUNT); + } + + /** + * Returns shipping_canceled + * + * @return float + */ + public function getShippingCanceled() + { + return $this->_get(self::SHIPPING_CANCELED); + } + + /** + * Returns shipping_description + * + * @return string + */ + public function getShippingDescription() + { + return $this->_get(self::SHIPPING_DESCRIPTION); + } + + /** + * Returns shipping_discount_amount + * + * @return float + */ + public function getShippingDiscountAmount() + { + return $this->_get(self::SHIPPING_DISCOUNT_AMOUNT); + } + + /** + * Returns shipping_hidden_tax_amount + * + * @return float + */ + public function getShippingHiddenTaxAmount() + { + return $this->_get(self::SHIPPING_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns shipping_incl_tax + * + * @return float + */ + public function getShippingInclTax() + { + return $this->_get(self::SHIPPING_INCL_TAX); + } + + /** + * Returns shipping_invoiced + * + * @return float + */ + public function getShippingInvoiced() + { + return $this->_get(self::SHIPPING_INVOICED); + } + + /** + * Returns shipping_method + * + * @return string + */ + public function getShippingMethod() + { + return $this->_get(self::SHIPPING_METHOD); + } + + /** + * Returns shipping_refunded + * + * @return float + */ + public function getShippingRefunded() + { + return $this->_get(self::SHIPPING_REFUNDED); + } + + /** + * Returns shipping_tax_amount + * + * @return float + */ + public function getShippingTaxAmount() + { + return $this->_get(self::SHIPPING_TAX_AMOUNT); + } + + /** + * Returns shipping_tax_refunded + * + * @return float + */ + public function getShippingTaxRefunded() + { + return $this->_get(self::SHIPPING_TAX_REFUNDED); + } + + /** + * Returns state + * + * @return string + */ + public function getState() + { + return $this->_get(self::STATE); + } + + /** + * Returns status + * + * @return string + */ + public function getStatus() + { + return $this->_get(self::STATUS); + } + + /** + * Returns store_currency_code + * + * @return string + */ + public function getStoreCurrencyCode() + { + return $this->_get(self::STORE_CURRENCY_CODE); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns store_name + * + * @return string + */ + public function getStoreName() + { + return $this->_get(self::STORE_NAME); + } + + /** + * Returns store_to_base_rate + * + * @return float + */ + public function getStoreToBaseRate() + { + return $this->_get(self::STORE_TO_BASE_RATE); + } + + /** + * Returns store_to_order_rate + * + * @return float + */ + public function getStoreToOrderRate() + { + return $this->_get(self::STORE_TO_ORDER_RATE); + } + + /** + * Returns subtotal + * + * @return float + */ + public function getSubtotal() + { + return $this->_get(self::SUBTOTAL); + } + + /** + * Returns subtotal_canceled + * + * @return float + */ + public function getSubtotalCanceled() + { + return $this->_get(self::SUBTOTAL_CANCELED); + } + + /** + * Returns subtotal_incl_tax + * + * @return float + */ + public function getSubtotalInclTax() + { + return $this->_get(self::SUBTOTAL_INCL_TAX); + } + + /** + * Returns subtotal_invoiced + * + * @return float + */ + public function getSubtotalInvoiced() + { + return $this->_get(self::SUBTOTAL_INVOICED); + } + + /** + * Returns subtotal_refunded + * + * @return float + */ + public function getSubtotalRefunded() + { + return $this->_get(self::SUBTOTAL_REFUNDED); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns tax_canceled + * + * @return float + */ + public function getTaxCanceled() + { + return $this->_get(self::TAX_CANCELED); + } + + /** + * Returns tax_invoiced + * + * @return float + */ + public function getTaxInvoiced() + { + return $this->_get(self::TAX_INVOICED); + } + + /** + * Returns tax_refunded + * + * @return float + */ + public function getTaxRefunded() + { + return $this->_get(self::TAX_REFUNDED); + } + + /** + * Returns total_canceled + * + * @return float + */ + public function getTotalCanceled() + { + return $this->_get(self::TOTAL_CANCELED); + } + + /** + * Returns total_due + * + * @return float + */ + public function getTotalDue() + { + return $this->_get(self::TOTAL_DUE); + } + + /** + * Returns total_invoiced + * + * @return float + */ + public function getTotalInvoiced() + { + return $this->_get(self::TOTAL_INVOICED); + } + + /** + * Returns total_item_count + * + * @return int + */ + public function getTotalItemCount() + { + return $this->_get(self::TOTAL_ITEM_COUNT); + } + + /** + * Returns total_offline_refunded + * + * @return float + */ + public function getTotalOfflineRefunded() + { + return $this->_get(self::TOTAL_OFFLINE_REFUNDED); + } + + /** + * Returns total_online_refunded + * + * @return float + */ + public function getTotalOnlineRefunded() + { + return $this->_get(self::TOTAL_ONLINE_REFUNDED); + } + + /** + * Returns total_paid + * + * @return float + */ + public function getTotalPaid() + { + return $this->_get(self::TOTAL_PAID); + } + + /** + * Returns total_qty_ordered + * + * @return float + */ + public function getTotalQtyOrdered() + { + return $this->_get(self::TOTAL_QTY_ORDERED); + } + + /** + * Returns total_refunded + * + * @return float + */ + public function getTotalRefunded() + { + return $this->_get(self::TOTAL_REFUNDED); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } + + /** + * Returns weight + * + * @return float + */ + public function getWeight() + { + return $this->_get(self::WEIGHT); + } + + /** + * Returns x_forwarded_for + * + * @return string + */ + public function getXForwardedFor() + { + return $this->_get(self::X_FORWARDED_FOR); + } + + /** + * @return \Magento\Sales\Service\V1\Data\OrderItem[] + */ + public function getItems() + { + return $this->_get(self::ITEMS); + } + + /** + * @return \Magento\Sales\Service\V1\Data\OrderAddress + */ + public function getBillingAddress() + { + return $this->_get(self::BILLING_ADDRESS); + } + + /** + * @return \Magento\Sales\Service\V1\Data\OrderAddress + */ + public function getShippingAddress() + { + return $this->_get(self::SHIPPING_ADDRESS); + } + + /** + * @return \Magento\Sales\Service\V1\Data\OrderPayment[] + */ + public function getPayments() + { + return $this->_get(self::PAYMENTS); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php b/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php new file mode 100644 index 0000000000000..34d413993fd4b --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderAddress.php @@ -0,0 +1,422 @@ +_get(self::ADDRESS_TYPE); + } + + /** + * Returns city + * + * @return string + */ + public function getCity() + { + return $this->_get(self::CITY); + } + + /** + * Returns company + * + * @return string + */ + public function getCompany() + { + return $this->_get(self::COMPANY); + } + + /** + * Returns country_id + * + * @return string + */ + public function getCountryId() + { + return $this->_get(self::COUNTRY_ID); + } + + /** + * Returns customer_address_id + * + * @return int + */ + public function getCustomerAddressId() + { + return $this->_get(self::CUSTOMER_ADDRESS_ID); + } + + /** + * Returns customer_id + * + * @return int + */ + public function getCustomerId() + { + return $this->_get(self::CUSTOMER_ID); + } + + /** + * Returns email + * + * @return string + */ + public function getEmail() + { + return $this->_get(self::EMAIL); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns fax + * + * @return string + */ + public function getFax() + { + return $this->_get(self::FAX); + } + + /** + * Returns firstname + * + * @return string + */ + public function getFirstname() + { + return $this->_get(self::FIRSTNAME); + } + + /** + * Returns lastname + * + * @return string + */ + public function getLastname() + { + return $this->_get(self::LASTNAME); + } + + /** + * Returns middlename + * + * @return string + */ + public function getMiddlename() + { + return $this->_get(self::MIDDLENAME); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns postcode + * + * @return string + */ + public function getPostcode() + { + return $this->_get(self::POSTCODE); + } + + /** + * Returns prefix + * + * @return string + */ + public function getPrefix() + { + return $this->_get(self::PREFIX); + } + + /** + * Returns quote_address_id + * + * @return int + */ + public function getQuoteAddressId() + { + return $this->_get(self::QUOTE_ADDRESS_ID); + } + + /** + * Returns region + * + * @return string + */ + public function getRegion() + { + return $this->_get(self::REGION); + } + + /** + * Returns region_id + * + * @return int + */ + public function getRegionId() + { + return $this->_get(self::REGION_ID); + } + + /** + * Returns street + * + * @return string + */ + public function getStreet() + { + return $this->_get(self::STREET); + } + + /** + * Returns suffix + * + * @return string + */ + public function getSuffix() + { + return $this->_get(self::SUFFIX); + } + + /** + * Returns telephone + * + * @return string + */ + public function getTelephone() + { + return $this->_get(self::TELEPHONE); + } + + /** + * Returns vat_id + * + * @return string + */ + public function getVatId() + { + return $this->_get(self::VAT_ID); + } + + /** + * Returns vat_is_valid + * + * @return int + */ + public function getVatIsValid() + { + return $this->_get(self::VAT_IS_VALID); + } + + /** + * Returns vat_request_date + * + * @return string + */ + public function getVatRequestDate() + { + return $this->_get(self::VAT_REQUEST_DATE); + } + + /** + * Returns vat_request_id + * + * @return string + */ + public function getVatRequestId() + { + return $this->_get(self::VAT_REQUEST_ID); + } + + /** + * Returns vat_request_success + * + * @return int + */ + public function getVatRequestSuccess() + { + return $this->_get(self::VAT_REQUEST_SUCCESS); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderItem.php b/app/code/Magento/Sales/Service/V1/Data/OrderItem.php new file mode 100644 index 0000000000000..7969c2e17b2c6 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderItem.php @@ -0,0 +1,1167 @@ +_get(self::ADDITIONAL_DATA); + } + + /** + * Returns amount_refunded + * + * @return float + */ + public function getAmountRefunded() + { + return $this->_get(self::AMOUNT_REFUNDED); + } + + /** + * Returns applied_rule_ids + * + * @return string + */ + public function getAppliedRuleIds() + { + return $this->_get(self::APPLIED_RULE_IDS); + } + + /** + * Returns base_amount_refunded + * + * @return float + */ + public function getBaseAmountRefunded() + { + return $this->_get(self::BASE_AMOUNT_REFUNDED); + } + + /** + * Returns base_cost + * + * @return float + */ + public function getBaseCost() + { + return $this->_get(self::BASE_COST); + } + + /** + * Returns base_discount_amount + * + * @return float + */ + public function getBaseDiscountAmount() + { + return $this->_get(self::BASE_DISCOUNT_AMOUNT); + } + + /** + * Returns base_discount_invoiced + * + * @return float + */ + public function getBaseDiscountInvoiced() + { + return $this->_get(self::BASE_DISCOUNT_INVOICED); + } + + /** + * Returns base_discount_refunded + * + * @return float + */ + public function getBaseDiscountRefunded() + { + return $this->_get(self::BASE_DISCOUNT_REFUNDED); + } + + /** + * Returns base_hidden_tax_amount + * + * @return float + */ + public function getBaseHiddenTaxAmount() + { + return $this->_get(self::BASE_HIDDEN_TAX_AMOUNT); + } + + /** + * Returns base_hidden_tax_invoiced + * + * @return float + */ + public function getBaseHiddenTaxInvoiced() + { + return $this->_get(self::BASE_HIDDEN_TAX_INVOICED); + } + + /** + * Returns base_hidden_tax_refunded + * + * @return float + */ + public function getBaseHiddenTaxRefunded() + { + return $this->_get(self::BASE_HIDDEN_TAX_REFUNDED); + } + + /** + * Returns base_original_price + * + * @return float + */ + public function getBaseOriginalPrice() + { + return $this->_get(self::BASE_ORIGINAL_PRICE); + } + + /** + * Returns base_price + * + * @return float + */ + public function getBasePrice() + { + return $this->_get(self::BASE_PRICE); + } + + /** + * Returns base_price_incl_tax + * + * @return float + */ + public function getBasePriceInclTax() + { + return $this->_get(self::BASE_PRICE_INCL_TAX); + } + + /** + * Returns base_row_invoiced + * + * @return float + */ + public function getBaseRowInvoiced() + { + return $this->_get(self::BASE_ROW_INVOICED); + } + + /** + * Returns base_row_total + * + * @return float + */ + public function getBaseRowTotal() + { + return $this->_get(self::BASE_ROW_TOTAL); + } + + /** + * Returns base_row_total_incl_tax + * + * @return float + */ + public function getBaseRowTotalInclTax() + { + return $this->_get(self::BASE_ROW_TOTAL_INCL_TAX); + } + + /** + * Returns base_tax_amount + * + * @return float + */ + public function getBaseTaxAmount() + { + return $this->_get(self::BASE_TAX_AMOUNT); + } + + /** + * Returns base_tax_before_discount + * + * @return float + */ + public function getBaseTaxBeforeDiscount() + { + return $this->_get(self::BASE_TAX_BEFORE_DISCOUNT); + } + + /** + * Returns base_tax_invoiced + * + * @return float + */ + public function getBaseTaxInvoiced() + { + return $this->_get(self::BASE_TAX_INVOICED); + } + + /** + * Returns base_tax_refunded + * + * @return float + */ + public function getBaseTaxRefunded() + { + return $this->_get(self::BASE_TAX_REFUNDED); + } + + /** + * Returns base_weee_tax_applied_amount + * + * @return float + */ + public function getBaseWeeeTaxAppliedAmount() + { + return $this->_get(self::BASE_WEEE_TAX_APPLIED_AMOUNT); + } + + /** + * Returns base_weee_tax_applied_row_amnt + * + * @return float + */ + public function getBaseWeeeTaxAppliedRowAmnt() + { + return $this->_get(self::BASE_WEEE_TAX_APPLIED_ROW_AMNT); + } + + /** + * Returns base_weee_tax_disposition + * + * @return float + */ + public function getBaseWeeeTaxDisposition() + { + return $this->_get(self::BASE_WEEE_TAX_DISPOSITION); + } + + /** + * Returns base_weee_tax_row_disposition + * + * @return float + */ + public function getBaseWeeeTaxRowDisposition() + { + return $this->_get(self::BASE_WEEE_TAX_ROW_DISPOSITION); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns discount_amount + * + * @return float + */ + public function getDiscountAmount() + { + return $this->_get(self::DISCOUNT_AMOUNT); + } + + /** + * Returns discount_invoiced + * + * @return float + */ + public function getDiscountInvoiced() + { + return $this->_get(self::DISCOUNT_INVOICED); + } + + /** + * Returns discount_percent + * + * @return float + */ + public function getDiscountPercent() + { + return $this->_get(self::DISCOUNT_PERCENT); + } + + /** + * Returns discount_refunded + * + * @return float + */ + public function getDiscountRefunded() + { + return $this->_get(self::DISCOUNT_REFUNDED); + } + + /** + * Returns event_id + * + * @return int + */ + public function getEventId() + { + return $this->_get(self::EVENT_ID); + } + + /** + * Returns ext_order_item_id + * + * @return string + */ + public function getExtOrderItemId() + { + return $this->_get(self::EXT_ORDER_ITEM_ID); + } + + /** + * Returns free_shipping + * + * @return int + */ + public function getFreeShipping() + { + return $this->_get(self::FREE_SHIPPING); + } + + /** + * Returns gw_base_price + * + * @return float + */ + public function getGwBasePrice() + { + return $this->_get(self::GW_BASE_PRICE); + } + + /** + * Returns gw_base_price_invoiced + * + * @return float + */ + public function getGwBasePriceInvoiced() + { + return $this->_get(self::GW_BASE_PRICE_INVOICED); + } + + /** + * Returns gw_base_price_refunded + * + * @return float + */ + public function getGwBasePriceRefunded() + { + return $this->_get(self::GW_BASE_PRICE_REFUNDED); + } + + /** + * Returns gw_base_tax_amount + * + * @return float + */ + public function getGwBaseTaxAmount() + { + return $this->_get(self::GW_BASE_TAX_AMOUNT); + } + + /** + * Returns gw_base_tax_amount_invoiced + * + * @return float + */ + public function getGwBaseTaxAmountInvoiced() + { + return $this->_get(self::GW_BASE_TAX_AMOUNT_INVOICED); + } + + /** + * Returns gw_base_tax_amount_refunded + * + * @return float + */ + public function getGwBaseTaxAmountRefunded() + { + return $this->_get(self::GW_BASE_TAX_AMOUNT_REFUNDED); + } + + /** + * Returns gw_id + * + * @return int + */ + public function getGwId() + { + return $this->_get(self::GW_ID); + } + + /** + * Returns gw_price + * + * @return float + */ + public function getGwPrice() + { + return $this->_get(self::GW_PRICE); + } + + /** + * Returns gw_price_invoiced + * + * @return float + */ + public function getGwPriceInvoiced() + { + return $this->_get(self::GW_PRICE_INVOICED); + } + + /** + * Returns gw_price_refunded + * + * @return float + */ + public function getGwPriceRefunded() + { + return $this->_get(self::GW_PRICE_REFUNDED); + } + + /** + * Returns gw_tax_amount + * + * @return float + */ + public function getGwTaxAmount() + { + return $this->_get(self::GW_TAX_AMOUNT); + } + + /** + * Returns gw_tax_amount_invoiced + * + * @return float + */ + public function getGwTaxAmountInvoiced() + { + return $this->_get(self::GW_TAX_AMOUNT_INVOICED); + } + + /** + * Returns gw_tax_amount_refunded + * + * @return float + */ + public function getGwTaxAmountRefunded() + { + return $this->_get(self::GW_TAX_AMOUNT_REFUNDED); + } + + /** + * Returns hidden_tax_amount + * + * @return float + */ + public function getHiddenTaxAmount() + { + return $this->_get(self::HIDDEN_TAX_AMOUNT); + } + + /** + * Returns hidden_tax_canceled + * + * @return float + */ + public function getHiddenTaxCanceled() + { + return $this->_get(self::HIDDEN_TAX_CANCELED); + } + + /** + * Returns hidden_tax_invoiced + * + * @return float + */ + public function getHiddenTaxInvoiced() + { + return $this->_get(self::HIDDEN_TAX_INVOICED); + } + + /** + * Returns hidden_tax_refunded + * + * @return float + */ + public function getHiddenTaxRefunded() + { + return $this->_get(self::HIDDEN_TAX_REFUNDED); + } + + /** + * Returns is_nominal + * + * @return int + */ + public function getIsNominal() + { + return $this->_get(self::IS_NOMINAL); + } + + /** + * Returns is_qty_decimal + * + * @return int + */ + public function getIsQtyDecimal() + { + return $this->_get(self::IS_QTY_DECIMAL); + } + + /** + * Returns is_virtual + * + * @return int + */ + public function getIsVirtual() + { + return $this->_get(self::IS_VIRTUAL); + } + + /** + * Returns item_id + * + * @return int + */ + public function getItemId() + { + return $this->_get(self::ITEM_ID); + } + + /** + * Returns locked_do_invoice + * + * @return int + */ + public function getLockedDoInvoice() + { + return $this->_get(self::LOCKED_DO_INVOICE); + } + + /** + * Returns locked_do_ship + * + * @return int + */ + public function getLockedDoShip() + { + return $this->_get(self::LOCKED_DO_SHIP); + } + + /** + * Returns name + * + * @return string + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * Returns no_discount + * + * @return int + */ + public function getNoDiscount() + { + return $this->_get(self::NO_DISCOUNT); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns original_price + * + * @return float + */ + public function getOriginalPrice() + { + return $this->_get(self::ORIGINAL_PRICE); + } + + /** + * Returns parent_item_id + * + * @return int + */ + public function getParentItemId() + { + return $this->_get(self::PARENT_ITEM_ID); + } + + /** + * Returns price + * + * @return float + */ + public function getPrice() + { + return $this->_get(self::PRICE); + } + + /** + * Returns price_incl_tax + * + * @return float + */ + public function getPriceInclTax() + { + return $this->_get(self::PRICE_INCL_TAX); + } + + /** + * Returns product_id + * + * @return int + */ + public function getProductId() + { + return $this->_get(self::PRODUCT_ID); + } + + /** + * Returns product_options + * + * @return string + */ + public function getProductOptions() + { + return $this->_get(self::PRODUCT_OPTIONS); + } + + /** + * Returns product_type + * + * @return string + */ + public function getProductType() + { + return $this->_get(self::PRODUCT_TYPE); + } + + /** + * Returns qty_backordered + * + * @return float + */ + public function getQtyBackordered() + { + return $this->_get(self::QTY_BACKORDERED); + } + + /** + * Returns qty_canceled + * + * @return float + */ + public function getQtyCanceled() + { + return $this->_get(self::QTY_CANCELED); + } + + /** + * Returns qty_invoiced + * + * @return float + */ + public function getQtyInvoiced() + { + return $this->_get(self::QTY_INVOICED); + } + + /** + * Returns qty_ordered + * + * @return float + */ + public function getQtyOrdered() + { + return $this->_get(self::QTY_ORDERED); + } + + /** + * Returns qty_refunded + * + * @return float + */ + public function getQtyRefunded() + { + return $this->_get(self::QTY_REFUNDED); + } + + /** + * Returns qty_returned + * + * @return float + */ + public function getQtyReturned() + { + return $this->_get(self::QTY_RETURNED); + } + + /** + * Returns qty_shipped + * + * @return float + */ + public function getQtyShipped() + { + return $this->_get(self::QTY_SHIPPED); + } + + /** + * Returns quote_item_id + * + * @return int + */ + public function getQuoteItemId() + { + return $this->_get(self::QUOTE_ITEM_ID); + } + + /** + * Returns row_invoiced + * + * @return float + */ + public function getRowInvoiced() + { + return $this->_get(self::ROW_INVOICED); + } + + /** + * Returns row_total + * + * @return float + */ + public function getRowTotal() + { + return $this->_get(self::ROW_TOTAL); + } + + /** + * Returns row_total_incl_tax + * + * @return float + */ + public function getRowTotalInclTax() + { + return $this->_get(self::ROW_TOTAL_INCL_TAX); + } + + /** + * Returns row_weight + * + * @return float + */ + public function getRowWeight() + { + return $this->_get(self::ROW_WEIGHT); + } + + /** + * Returns sku + * + * @return string + */ + public function getSku() + { + return $this->_get(self::SKU); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns tax_amount + * + * @return float + */ + public function getTaxAmount() + { + return $this->_get(self::TAX_AMOUNT); + } + + /** + * Returns tax_before_discount + * + * @return float + */ + public function getTaxBeforeDiscount() + { + return $this->_get(self::TAX_BEFORE_DISCOUNT); + } + + /** + * Returns tax_canceled + * + * @return float + */ + public function getTaxCanceled() + { + return $this->_get(self::TAX_CANCELED); + } + + /** + * Returns tax_invoiced + * + * @return float + */ + public function getTaxInvoiced() + { + return $this->_get(self::TAX_INVOICED); + } + + /** + * Returns tax_percent + * + * @return float + */ + public function getTaxPercent() + { + return $this->_get(self::TAX_PERCENT); + } + + /** + * Returns tax_refunded + * + * @return float + */ + public function getTaxRefunded() + { + return $this->_get(self::TAX_REFUNDED); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } + + /** + * Returns weee_tax_applied + * + * @return string + */ + public function getWeeeTaxApplied() + { + return $this->_get(self::WEEE_TAX_APPLIED); + } + + /** + * Returns weee_tax_applied_amount + * + * @return float + */ + public function getWeeeTaxAppliedAmount() + { + return $this->_get(self::WEEE_TAX_APPLIED_AMOUNT); + } + + /** + * Returns weee_tax_applied_row_amount + * + * @return float + */ + public function getWeeeTaxAppliedRowAmount() + { + return $this->_get(self::WEEE_TAX_APPLIED_ROW_AMOUNT); + } + + /** + * Returns weee_tax_disposition + * + * @return float + */ + public function getWeeeTaxDisposition() + { + return $this->_get(self::WEEE_TAX_DISPOSITION); + } + + /** + * Returns weee_tax_row_disposition + * + * @return float + */ + public function getWeeeTaxRowDisposition() + { + return $this->_get(self::WEEE_TAX_ROW_DISPOSITION); + } + + /** + * Returns weight + * + * @return float + */ + public function getWeight() + { + return $this->_get(self::WEIGHT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderMapper.php b/app/code/Magento/Sales/Service/V1/Data/OrderMapper.php new file mode 100644 index 0000000000000..38a6e49d4f32b --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderMapper.php @@ -0,0 +1,144 @@ +orderBuilder = $orderBuilder; + $this->orderItemMapper = $orderItemMapper; + $this->orderPaymentMapper = $orderPaymentMapper; + $this->orderAddressMapper = $orderAddressMapper; + } + + /** + * Returns array of items + * + * @param \Magento\Sales\Model\Order $object + * @return OrderItem[] + */ + protected function getItems(\Magento\Sales\Model\Order $object) + { + $items = []; + foreach ($object->getItemsCollection() as $item) { + $items[] = $this->orderItemMapper->extractDto($item); + } + return $items; + } + + /** + * Returns array of payments + * + * @param \Magento\Sales\Model\Order $object + * @return OrderPayment[] + */ + protected function getPayments(\Magento\Sales\Model\Order $object) + { + $payments = []; + foreach ($object->getPaymentsCollection() as $payment) { + $payments[] = $this->orderPaymentMapper->extractDto($payment); + } + return $payments; + } + + /** + * Return billing address + * + * @param \Magento\Sales\Model\Order $object + * @return OrderAddress|null + */ + protected function getBillingAddress(\Magento\Sales\Model\Order $object) + { + $billingAddress = null; + if ($object->getBillingAddress()) { + $billingAddress = $this->orderAddressMapper->extractDto($object->getBillingAddress()); + } + return $billingAddress; + } + + /** + * Returns shipping address + * + * @param \Magento\Sales\Model\Order $object + * @return OrderAddress|null + */ + protected function getShippingAddress(\Magento\Sales\Model\Order $object) + { + $shippingAddress = null; + if ($object->getShippingAddress()) { + $shippingAddress = $this->orderAddressMapper->extractDto($object->getShippingAddress()); + } + return $shippingAddress; + } + + /** + * @param \Magento\Sales\Model\Order $object + * @return \Magento\Framework\Service\Data\AbstractObject + */ + public function extractDto(\Magento\Sales\Model\Order $object) + { + $this->orderBuilder->populateWithArray($object->getData()); + $this->orderBuilder->setItems($this->getItems($object)); + $this->orderBuilder->setPayments($this->getPayments($object)); + $this->orderBuilder->setBillingAddress($this->getBillingAddress($object)); + $this->orderBuilder->setShippingAddress($this->getShippingAddress($object)); + return $this->orderBuilder->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php b/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php new file mode 100644 index 0000000000000..a076f2ab30e7c --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderPayment.php @@ -0,0 +1,842 @@ +_get(self::ACCOUNT_STATUS); + } + + /** + * Returns additional_data + * + * @return string + */ + public function getAdditionalData() + { + return $this->_get(self::ADDITIONAL_DATA); + } + + /** + * Returns additional_information + * + * @return string + */ + public function getAdditionalInformation() + { + return $this->_get(self::ADDITIONAL_INFORMATION); + } + + /** + * Returns address_status + * + * @return string + */ + public function getAddressStatus() + { + return $this->_get(self::ADDRESS_STATUS); + } + + /** + * Returns amount_authorized + * + * @return float + */ + public function getAmountAuthorized() + { + return $this->_get(self::AMOUNT_AUTHORIZED); + } + + /** + * Returns amount_canceled + * + * @return float + */ + public function getAmountCanceled() + { + return $this->_get(self::AMOUNT_CANCELED); + } + + /** + * Returns amount_ordered + * + * @return float + */ + public function getAmountOrdered() + { + return $this->_get(self::AMOUNT_ORDERED); + } + + /** + * Returns amount_paid + * + * @return float + */ + public function getAmountPaid() + { + return $this->_get(self::AMOUNT_PAID); + } + + /** + * Returns amount_refunded + * + * @return float + */ + public function getAmountRefunded() + { + return $this->_get(self::AMOUNT_REFUNDED); + } + + /** + * Returns anet_trans_method + * + * @return string + */ + public function getAnetTransMethod() + { + return $this->_get(self::ANET_TRANS_METHOD); + } + + /** + * Returns base_amount_authorized + * + * @return float + */ + public function getBaseAmountAuthorized() + { + return $this->_get(self::BASE_AMOUNT_AUTHORIZED); + } + + /** + * Returns base_amount_canceled + * + * @return float + */ + public function getBaseAmountCanceled() + { + return $this->_get(self::BASE_AMOUNT_CANCELED); + } + + /** + * Returns base_amount_ordered + * + * @return float + */ + public function getBaseAmountOrdered() + { + return $this->_get(self::BASE_AMOUNT_ORDERED); + } + + /** + * Returns base_amount_paid + * + * @return float + */ + public function getBaseAmountPaid() + { + return $this->_get(self::BASE_AMOUNT_PAID); + } + + /** + * Returns base_amount_paid_online + * + * @return float + */ + public function getBaseAmountPaidOnline() + { + return $this->_get(self::BASE_AMOUNT_PAID_ONLINE); + } + + /** + * Returns base_amount_refunded + * + * @return float + */ + public function getBaseAmountRefunded() + { + return $this->_get(self::BASE_AMOUNT_REFUNDED); + } + + /** + * Returns base_amount_refunded_online + * + * @return float + */ + public function getBaseAmountRefundedOnline() + { + return $this->_get(self::BASE_AMOUNT_REFUNDED_ONLINE); + } + + /** + * Returns base_shipping_amount + * + * @return float + */ + public function getBaseShippingAmount() + { + return $this->_get(self::BASE_SHIPPING_AMOUNT); + } + + /** + * Returns base_shipping_captured + * + * @return float + */ + public function getBaseShippingCaptured() + { + return $this->_get(self::BASE_SHIPPING_CAPTURED); + } + + /** + * Returns base_shipping_refunded + * + * @return float + */ + public function getBaseShippingRefunded() + { + return $this->_get(self::BASE_SHIPPING_REFUNDED); + } + + /** + * Returns cc_approval + * + * @return string + */ + public function getCcApproval() + { + return $this->_get(self::CC_APPROVAL); + } + + /** + * Returns cc_avs_status + * + * @return string + */ + public function getCcAvsStatus() + { + return $this->_get(self::CC_AVS_STATUS); + } + + /** + * Returns cc_cid_status + * + * @return string + */ + public function getCcCidStatus() + { + return $this->_get(self::CC_CID_STATUS); + } + + /** + * Returns cc_debug_request_body + * + * @return string + */ + public function getCcDebugRequestBody() + { + return $this->_get(self::CC_DEBUG_REQUEST_BODY); + } + + /** + * Returns cc_debug_response_body + * + * @return string + */ + public function getCcDebugResponseBody() + { + return $this->_get(self::CC_DEBUG_RESPONSE_BODY); + } + + /** + * Returns cc_debug_response_serialized + * + * @return string + */ + public function getCcDebugResponseSerialized() + { + return $this->_get(self::CC_DEBUG_RESPONSE_SERIALIZED); + } + + /** + * Returns cc_exp_month + * + * @return string + */ + public function getCcExpMonth() + { + return $this->_get(self::CC_EXP_MONTH); + } + + /** + * Returns cc_exp_year + * + * @return string + */ + public function getCcExpYear() + { + return $this->_get(self::CC_EXP_YEAR); + } + + /** + * Returns cc_last4 + * + * @return string + */ + public function getCcLast4() + { + return $this->_get(self::CC_LAST4); + } + + /** + * Returns cc_number_enc + * + * @return string + */ + public function getCcNumberEnc() + { + return $this->_get(self::CC_NUMBER_ENC); + } + + /** + * Returns cc_owner + * + * @return string + */ + public function getCcOwner() + { + return $this->_get(self::CC_OWNER); + } + + /** + * Returns cc_secure_verify + * + * @return string + */ + public function getCcSecureVerify() + { + return $this->_get(self::CC_SECURE_VERIFY); + } + + /** + * Returns cc_ss_issue + * + * @return string + */ + public function getCcSsIssue() + { + return $this->_get(self::CC_SS_ISSUE); + } + + /** + * Returns cc_ss_start_month + * + * @return string + */ + public function getCcSsStartMonth() + { + return $this->_get(self::CC_SS_START_MONTH); + } + + /** + * Returns cc_ss_start_year + * + * @return string + */ + public function getCcSsStartYear() + { + return $this->_get(self::CC_SS_START_YEAR); + } + + /** + * Returns cc_status + * + * @return string + */ + public function getCcStatus() + { + return $this->_get(self::CC_STATUS); + } + + /** + * Returns cc_status_description + * + * @return string + */ + public function getCcStatusDescription() + { + return $this->_get(self::CC_STATUS_DESCRIPTION); + } + + /** + * Returns cc_trans_id + * + * @return string + */ + public function getCcTransId() + { + return $this->_get(self::CC_TRANS_ID); + } + + /** + * Returns cc_type + * + * @return string + */ + public function getCcType() + { + return $this->_get(self::CC_TYPE); + } + + /** + * Returns echeck_account_name + * + * @return string + */ + public function getEcheckAccountName() + { + return $this->_get(self::ECHECK_ACCOUNT_NAME); + } + + /** + * Returns echeck_account_type + * + * @return string + */ + public function getEcheckAccountType() + { + return $this->_get(self::ECHECK_ACCOUNT_TYPE); + } + + /** + * Returns echeck_bank_name + * + * @return string + */ + public function getEcheckBankName() + { + return $this->_get(self::ECHECK_BANK_NAME); + } + + /** + * Returns echeck_routing_number + * + * @return string + */ + public function getEcheckRoutingNumber() + { + return $this->_get(self::ECHECK_ROUTING_NUMBER); + } + + /** + * Returns echeck_type + * + * @return string + */ + public function getEcheckType() + { + return $this->_get(self::ECHECK_TYPE); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns last_trans_id + * + * @return string + */ + public function getLastTransId() + { + return $this->_get(self::LAST_TRANS_ID); + } + + /** + * Returns method + * + * @return string + */ + public function getMethod() + { + return $this->_get(self::METHOD); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns po_number + * + * @return string + */ + public function getPoNumber() + { + return $this->_get(self::PO_NUMBER); + } + + /** + * Returns protection_eligibility + * + * @return string + */ + public function getProtectionEligibility() + { + return $this->_get(self::PROTECTION_ELIGIBILITY); + } + + /** + * Returns quote_payment_id + * + * @return int + */ + public function getQuotePaymentId() + { + return $this->_get(self::QUOTE_PAYMENT_ID); + } + + /** + * Returns shipping_amount + * + * @return float + */ + public function getShippingAmount() + { + return $this->_get(self::SHIPPING_AMOUNT); + } + + /** + * Returns shipping_captured + * + * @return float + */ + public function getShippingCaptured() + { + return $this->_get(self::SHIPPING_CAPTURED); + } + + /** + * Returns shipping_refunded + * + * @return float + */ + public function getShippingRefunded() + { + return $this->_get(self::SHIPPING_REFUNDED); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/OrderStatusHistory.php b/app/code/Magento/Sales/Service/V1/Data/OrderStatusHistory.php new file mode 100644 index 0000000000000..4e22c6f7bf335 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/OrderStatusHistory.php @@ -0,0 +1,121 @@ +_get(self::COMMENT); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns entity_name + * + * @return string + */ + public function getEntityName() + { + return $this->_get(self::ENTITY_NAME); + } + + /** + * Returns is_customer_notified + * + * @return int + */ + public function getIsCustomerNotified() + { + return $this->_get(self::IS_CUSTOMER_NOTIFIED); + } + + /** + * Returns is_visible_on_front + * + * @return int + */ + public function getIsVisibleOnFront() + { + return $this->_get(self::IS_VISIBLE_ON_FRONT); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns status + * + * @return string + */ + public function getStatus() + { + return $this->_get(self::STATUS); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/Shipment.php b/app/code/Magento/Sales/Service/V1/Data/Shipment.php new file mode 100644 index 0000000000000..814b6472c937b --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/Shipment.php @@ -0,0 +1,257 @@ +_get(self::BILLING_ADDRESS_ID); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns customer_id + * + * @return int + */ + public function getCustomerId() + { + return $this->_get(self::CUSTOMER_ID); + } + + /** + * Returns email_sent + * + * @return int + */ + public function getEmailSent() + { + return $this->_get(self::EMAIL_SENT); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns increment_id + * + * @return string + */ + public function getIncrementId() + { + return $this->_get(self::INCREMENT_ID); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns packages + * + * @return string + */ + public function getPackages() + { + return $this->_get(self::PACKAGES); + } + + /** + * Returns shipment_status + * + * @return int + */ + public function getShipmentStatus() + { + return $this->_get(self::SHIPMENT_STATUS); + } + + /** + * Returns shipping_address_id + * + * @return int + */ + public function getShippingAddressId() + { + return $this->_get(self::SHIPPING_ADDRESS_ID); + } + + /** + * Returns shipping_label + * + * @return string + */ + public function getShippingLabel() + { + return $this->_get(self::SHIPPING_LABEL); + } + + /** + * Returns store_id + * + * @return int + */ + public function getStoreId() + { + return $this->_get(self::STORE_ID); + } + + /** + * Returns total_qty + * + * @return float + */ + public function getTotalQty() + { + return $this->_get(self::TOTAL_QTY); + } + + /** + * Returns total_weight + * + * @return float + */ + public function getTotalWeight() + { + return $this->_get(self::TOTAL_WEIGHT); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php b/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php new file mode 100644 index 0000000000000..4c5eb9f556ab8 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/ShipmentItem.php @@ -0,0 +1,213 @@ +_get(self::ADDITIONAL_DATA); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns name + * + * @return string + */ + public function getName() + { + return $this->_get(self::NAME); + } + + /** + * Returns order_item_id + * + * @return int + */ + public function getOrderItemId() + { + return $this->_get(self::ORDER_ITEM_ID); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns price + * + * @return float + */ + public function getPrice() + { + return $this->_get(self::PRICE); + } + + /** + * Returns product_id + * + * @return int + */ + public function getProductId() + { + return $this->_get(self::PRODUCT_ID); + } + + /** + * Returns qty + * + * @return float + */ + public function getQty() + { + return $this->_get(self::QTY); + } + + /** + * Returns row_total + * + * @return float + */ + public function getRowTotal() + { + return $this->_get(self::ROW_TOTAL); + } + + /** + * Returns sku + * + * @return string + */ + public function getSku() + { + return $this->_get(self::SKU); + } + + /** + * Returns weight + * + * @return float + */ + public function getWeight() + { + return $this->_get(self::WEIGHT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php b/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php new file mode 100644 index 0000000000000..5038db1869f8b --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/Data/ShipmentTrack.php @@ -0,0 +1,198 @@ +_get(self::CARRIER_CODE); + } + + /** + * Returns created_at + * + * @return string + */ + public function getCreatedAt() + { + return $this->_get(self::CREATED_AT); + } + + /** + * Returns description + * + * @return string + */ + public function getDescription() + { + return $this->_get(self::DESCRIPTION); + } + + /** + * Returns entity_id + * + * @return int + */ + public function getEntityId() + { + return $this->_get(self::ENTITY_ID); + } + + /** + * Returns order_id + * + * @return int + */ + public function getOrderId() + { + return $this->_get(self::ORDER_ID); + } + + /** + * Returns parent_id + * + * @return int + */ + public function getParentId() + { + return $this->_get(self::PARENT_ID); + } + + /** + * Returns qty + * + * @return float + */ + public function getQty() + { + return $this->_get(self::QTY); + } + + /** + * Returns title + * + * @return string + */ + public function getTitle() + { + return $this->_get(self::TITLE); + } + + /** + * Returns track_number + * + * @return string + */ + public function getTrackNumber() + { + return $this->_get(self::TRACK_NUMBER); + } + + /** + * Returns updated_at + * + * @return string + */ + public function getUpdatedAt() + { + return $this->_get(self::UPDATED_AT); + } + + /** + * Returns weight + * + * @return float + */ + public function getWeight() + { + return $this->_get(self::WEIGHT); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderAddressUpdate.php b/app/code/Magento/Sales/Service/V1/OrderAddressUpdate.php new file mode 100644 index 0000000000000..0ee239faf420a --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderAddressUpdate.php @@ -0,0 +1,59 @@ +addressConverter = $addressConverter; + } + + /** + * Invoke order address update service + * + * @param \Magento\Sales\Service\V1\Data\OrderAddress $orderAddress + * @return bool + */ + public function invoke(OrderAddress $orderAddress) + { + $orderAddressModel = $this->addressConverter->getModel($orderAddress); + return (bool)$orderAddressModel->save(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php b/app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php new file mode 100644 index 0000000000000..16237cbe85e5a --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderAddressUpdateInterface.php @@ -0,0 +1,40 @@ +orderRepository = $orderRepository; + } + + /** + * Invoke getOrder service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return (bool)$this->orderRepository->get($id)->cancel(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderCancelInterface.php b/app/code/Magento/Sales/Service/V1/OrderCancelInterface.php new file mode 100644 index 0000000000000..6fcdae3e1477b --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderCancelInterface.php @@ -0,0 +1,39 @@ +historyRepository = $historyRepository; + $this->historyMapper = $historyMapper; + $this->criteriaBuilder = $criteriaBuilder; + $this->filterBuilder = $filterBuilder; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke OrderCommentsList service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\OrderStatusHistorySearchResults + */ + public function invoke($id) + { + $this->criteriaBuilder->addFilter( + ['eq' => $this->filterBuilder->setField('parent_id')->setValue($id)->create()] + ); + $criteria = $this->criteriaBuilder->create(); + $comments = []; + foreach ($this->historyRepository->find($criteria) as $comment) { + $comments[] = $this->historyMapper->extractDto($comment); + } + return $this->searchResultsBuilder->setItems($comments) + ->setSearchCriteria($criteria) + ->setTotalCount(count($comments)) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php b/app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php new file mode 100644 index 0000000000000..64de1d900671a --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderCommentsListInterface.php @@ -0,0 +1,38 @@ +orderRepository = $orderRepository; + $this->orderMapper = $orderMapper; + } + + /** + * Invoke getOrder service + * + * @param int $id + * @return \Magento\Sales\Service\V1\Data\Order + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + $order = $this->orderRepository->get($id); + return $this->orderMapper->extractDto($order); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderGetInterface.php b/app/code/Magento/Sales/Service/V1/OrderGetInterface.php new file mode 100644 index 0000000000000..edc166d4782f6 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderGetInterface.php @@ -0,0 +1,39 @@ +_connections = array('read' => new MysqlStub(), 'write' => new MysqlStub()); - } + protected $orderRepository; /** - * Save option value price data - * - * @param \Magento\Framework\Model\AbstractModel $object + * @param OrderRepository $orderRepository */ - public function saveValueTitles(\Magento\Framework\Model\AbstractModel $object) + public function __construct(OrderRepository $orderRepository) { - $this->_saveValueTitles($object); + $this->orderRepository = $orderRepository; } /** - * We should stub to not use db + * Retrieve order status by id * - * @param string $tableName + * @param int $id * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function getTable($tableName) + public function invoke($id) { - return $tableName; + return $this->orderRepository->get($id)->getStatus(); } } diff --git a/app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php b/app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php new file mode 100644 index 0000000000000..821a64129ae24 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderGetStatusInterface.php @@ -0,0 +1,40 @@ +orderRepository = $orderRepository; + } + + /** + * Invoke orderHold service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return (bool)$this->orderRepository->get($id)->hold(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderHoldInterface.php b/app/code/Magento/Sales/Service/V1/OrderHoldInterface.php new file mode 100644 index 0000000000000..0ba9ba3733c12 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderHoldInterface.php @@ -0,0 +1,39 @@ +orderRepository = $orderRepository; + $this->orderMapper = $orderMapper; + $this->searchResultsBuilder = $searchResultsBuilder; + } + + /** + * Invoke OrderList service + * + * @param SearchCriteria $searchCriteria + * @return \Magento\Framework\Service\V1\Data\SearchResults + */ + public function invoke(SearchCriteria $searchCriteria) + { + $orders = []; + foreach ($this->orderRepository->find($searchCriteria) as $order) { + $orders[] = $this->orderMapper->extractDto($order); + } + return $this->searchResultsBuilder->setItems($orders) + ->setTotalCount(count($order)) + ->setSearchCriteria($searchCriteria) + ->create(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderListInterface.php b/app/code/Magento/Sales/Service/V1/OrderListInterface.php new file mode 100644 index 0000000000000..508fd35e1f543 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderListInterface.php @@ -0,0 +1,40 @@ +session = $session; + $this->orderRepository = $orderRepository; + $this->notifier = $notifier; } /** - * Initiate a session for unregistered users. Send back the session id. + * Invoke notifyUser service * - * @return void + * @param int $id + * @return bool */ - public function execute() + public function invoke($id) { - $this->session->start('frontend'); - $this->session->setUserId(0); - $this->session->setUserType(UserIdentifier::USER_TYPE_GUEST); - $this->session->regenerateId(true); + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->orderRepository->get($id); + return $this->notifier->notify($order); } } diff --git a/app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php b/app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php new file mode 100644 index 0000000000000..2ed67edf6cc91 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderNotifyUserInterface.php @@ -0,0 +1,38 @@ +orderRepository = $orderRepository; + $this->historyConverter = $historyConverter; + } + + /** + * Invoke service + * + * @param int $id + * @param \Magento\Sales\Service\V1\Data\OrderStatusHistory $statusHistory + * @return bool + */ + public function invoke($id, OrderStatusHistory $statusHistory) + { + $order = $this->orderRepository->get($id); + $order->addStatusHistory($this->historyConverter->getModel($statusHistory)); + $order->save(); + return true; + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php b/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php new file mode 100644 index 0000000000000..d02279df3f8c0 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderStatusHistoryAddInterface.php @@ -0,0 +1,42 @@ +orderRepository = $orderRepository; + } + + /** + * Invoke orderUnHold service + * + * @param int $id + * @return bool + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + public function invoke($id) + { + return (bool)$this->orderRepository->get($id)->unhold(); + } +} diff --git a/app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php b/app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php new file mode 100644 index 0000000000000..720df5f28b4c7 --- /dev/null +++ b/app/code/Magento/Sales/Service/V1/OrderUnHoldInterface.php @@ -0,0 +1,39 @@ + - + diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index 3dbae800e8d08..991b5f78ecf13 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -24,7 +24,17 @@ */ --> - + + + + + + + + + + + pdf.xml diff --git a/app/code/Magento/Sales/etc/webapi.xml b/app/code/Magento/Sales/etc/webapi.xml new file mode 100644 index 0000000000000..fa435cb99b524 --- /dev/null +++ b/app/code/Magento/Sales/etc/webapi.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form.phtml index 6682724403385..cc6aec52007fb 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form.phtml @@ -21,8 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ +/** @var \Magento\Sales\Block\Adminhtml\Order\Create\Form $this */ ?> - + getBlockHtml('formkey')?>
    getChildHtml('message') ?> diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js b/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js index b833d6459ae78..9edde1d0be67d 100644 --- a/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js +++ b/app/code/Magento/Sales/view/adminhtml/web/order/create/form.js @@ -35,7 +35,7 @@ define([ return; } - config = $el.data('order-config'), + config = $el.data('order-config'); baseUrl = $el.data('load-base-url'); order = new AdminOrder(config); diff --git a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml index ef58807040549..ea69f6635dd6d 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml @@ -25,9 +25,6 @@ getOrders(); ?> getChildHtml('info');?> getSize()): ?> - getPagerHtml()): ?> -
    getPagerHtml(); ?>
    -
    diff --git a/app/code/Magento/SalesRule/composer.json b/app/code/Magento/SalesRule/composer.json index 5881306da23dd..5c5e2f7a78711 100644 --- a/app/code/Magento/SalesRule/composer.json +++ b/app/code/Magento/SalesRule/composer.json @@ -2,28 +2,28 @@ "name": "magento/module-sales-rule", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-rule": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-shipping": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-reports": "0.1.0-alpha89", - "magento/module-catalog-rule": "0.1.0-alpha89", - "magento/module-widget": "0.1.0-alpha89", - "magento/module-cron": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-rule": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-shipping": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-reports": "0.1.0-alpha90", + "magento/module-catalog-rule": "0.1.0-alpha90", + "magento/module-widget": "0.1.0-alpha90", + "magento/module-cron": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/SalesRule/etc/adminhtml/acl.xml b/app/code/Magento/SalesRule/etc/acl.xml similarity index 95% rename from app/code/Magento/SalesRule/etc/adminhtml/acl.xml rename to app/code/Magento/SalesRule/etc/acl.xml index b23b3d35206e5..f11abdd737192 100644 --- a/app/code/Magento/SalesRule/etc/adminhtml/acl.xml +++ b/app/code/Magento/SalesRule/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Sendfriend/composer.json b/app/code/Magento/Sendfriend/composer.json index ce7c55ff29479..2f7f51b67ec1f 100644 --- a/app/code/Magento/Sendfriend/composer.json +++ b/app/code/Magento/Sendfriend/composer.json @@ -2,17 +2,17 @@ "name": "magento/module-sendfriend", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-theme": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-theme": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php index d69935e42ce1f..6807412a6a51e 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddComment.php @@ -25,6 +25,7 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use Magento\Backend\App\Action; +use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; class AddComment extends \Magento\Backend\App\Action { @@ -33,15 +34,23 @@ class AddComment extends \Magento\Backend\App\Action */ protected $shipmentLoader; + /** + * @var ShipmentSender + */ + protected $shipmentSender; + /** * @param Action\Context $context * @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader + * @param ShipmentSender $shipmentSender */ public function __construct( Action\Context $context, - \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader + \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader, + ShipmentSender $shipmentSender ) { $this->shipmentLoader = $shipmentLoader; + $this->shipmentSender = $shipmentSender; parent::__construct($context); } @@ -73,7 +82,8 @@ public function execute() isset($data['is_customer_notified']), isset($data['is_visible_on_front']) ); - $shipment->sendUpdateEmail(!empty($data['is_customer_notified']), $data['comment']); + + $this->shipmentSender->send($shipment, !empty($data['is_customer_notified']), $data['comment']); $shipment->save(); $this->_view->loadLayout(false); diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php index 13365a2692152..62af1f588270d 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Email.php @@ -25,6 +25,7 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use \Magento\Backend\App\Action; +use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; class Email extends \Magento\Backend\App\Action { @@ -33,15 +34,23 @@ class Email extends \Magento\Backend\App\Action */ protected $shipmentLoader; + /** + * @var ShipmentSender + */ + protected $shipmentSender; + /** * @param Action\Context $context * @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader + * @param ShipmentSender $shipmentSender */ public function __construct( Action\Context $context, - \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader + \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader, + ShipmentSender $shipmentSender ) { $this->shipmentLoader = $shipmentLoader; + $this->shipmentSender = $shipmentSender; parent::__construct($context); } @@ -63,7 +72,9 @@ public function execute() try { $shipment = $this->shipmentLoader->load($this->_request); if ($shipment) { - $shipment->sendEmail(true)->setEmailSent(true)->save(); + $this->shipmentSender->send($shipment, true); + $shipment->save(); + $historyItem = $this->_objectManager->create( 'Magento\Sales\Model\Resource\Order\Status\History\Collection' )->getUnnotifiedForInstance( diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php index a8e1ef0036758..8bdd3ed7fca4d 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php @@ -25,6 +25,7 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use \Magento\Backend\App\Action; +use \Magento\Sales\Model\Order\Email\Sender\ShipmentSender; class Save extends \Magento\Backend\App\Action { @@ -38,18 +39,26 @@ class Save extends \Magento\Backend\App\Action */ protected $labelGenerator; + /** + * @var ShipmentSender + */ + protected $shipmentSender; + /** * @param Action\Context $context * @param \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader * @param \Magento\Shipping\Model\Shipping\LabelGenerator $labelGenerator + * @param ShipmentSender $shipmentSender */ public function __construct( Action\Context $context, \Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader $shipmentLoader, - \Magento\Shipping\Model\Shipping\LabelGenerator $labelGenerator + \Magento\Shipping\Model\Shipping\LabelGenerator $labelGenerator, + ShipmentSender $shipmentSender ) { $this->shipmentLoader = $shipmentLoader; $this->labelGenerator = $labelGenerator; + $this->shipmentSender = $shipmentSender; parent::__construct($context); } @@ -128,7 +137,7 @@ public function execute() $this->_saveShipment($shipment); - $shipment->sendEmail(!empty($data['send_email']), $comment); + $this->shipmentSender->send($shipment, !empty($data['send_email']), $comment); $shipmentCreatedMessage = __('The shipment has been created.'); $labelCreatedMessage = __('You created the shipping label.'); diff --git a/app/code/Magento/Shipping/composer.json b/app/code/Magento/Shipping/composer.json index 6e53c76cf9ddb..fc4e89cab74e3 100644 --- a/app/code/Magento/Shipping/composer.json +++ b/app/code/Magento/Shipping/composer.json @@ -2,24 +2,24 @@ "name": "magento/module-shipping", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-sales": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-contact": "0.1.0-alpha89", - "magento/module-customer": "0.1.0-alpha89", - "magento/module-payment": "0.1.0-alpha89", - "magento/module-tax": "0.1.0-alpha89", - "magento/module-catalog-inventory": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-sales": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-contact": "0.1.0-alpha90", + "magento/module-customer": "0.1.0-alpha90", + "magento/module-payment": "0.1.0-alpha90", + "magento/module-tax": "0.1.0-alpha90", + "magento/module-catalog-inventory": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "ext-gd": "*", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Shipping/etc/adminhtml/acl.xml b/app/code/Magento/Shipping/etc/acl.xml similarity index 94% rename from app/code/Magento/Shipping/etc/adminhtml/acl.xml rename to app/code/Magento/Shipping/etc/acl.xml index 277cd0ce9f79c..fd54affe77eae 100644 --- a/app/code/Magento/Shipping/etc/adminhtml/acl.xml +++ b/app/code/Magento/Shipping/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Sitemap/composer.json b/app/code/Magento/Sitemap/composer.json index 8e78eedc06c55..11958116c049b 100644 --- a/app/code/Magento/Sitemap/composer.json +++ b/app/code/Magento/Sitemap/composer.json @@ -2,18 +2,18 @@ "name": "magento/module-sitemap", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-store": "0.1.0-alpha89", - "magento/module-catalog": "0.1.0-alpha89", - "magento/module-core": "0.1.0-alpha89", - "magento/module-eav": "0.1.0-alpha89", - "magento/module-cms": "0.1.0-alpha89", - "magento/module-backend": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-store": "0.1.0-alpha90", + "magento/module-catalog": "0.1.0-alpha90", + "magento/module-core": "0.1.0-alpha90", + "magento/module-eav": "0.1.0-alpha90", + "magento/module-cms": "0.1.0-alpha90", + "magento/module-backend": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Sitemap/etc/adminhtml/acl.xml b/app/code/Magento/Sitemap/etc/acl.xml similarity index 95% rename from app/code/Magento/Sitemap/etc/adminhtml/acl.xml rename to app/code/Magento/Sitemap/etc/acl.xml index 5d5c2b7c7c979..b4684b3649690 100644 --- a/app/code/Magento/Sitemap/etc/adminhtml/acl.xml +++ b/app/code/Magento/Sitemap/etc/acl.xml @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - + diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index aa8356e9d1a78..47e2308ae586d 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -2,15 +2,15 @@ "name": "magento/module-store", "description": "N/A", "require": { - "php": "5.4.*|5.5.*", - "magento/module-core": "0.1.0-alpha89", - "magento/module-directory": "0.1.0-alpha89", - "magento/module-index": "0.1.0-alpha89", - "magento/framework": "0.1.0-alpha89", + "php": "~5.4.11|~5.5.0", + "magento/module-core": "0.1.0-alpha90", + "magento/module-directory": "0.1.0-alpha90", + "magento/module-index": "0.1.0-alpha90", + "magento/framework": "0.1.0-alpha90", "magento/magento-composer-installer": "*" }, "type": "magento2-module", - "version": "0.1.0-alpha89", + "version": "0.1.0-alpha90", "extra": { "map": [ [ diff --git a/app/code/Magento/Store/view/frontend/templates/switch/languages.phtml b/app/code/Magento/Store/view/frontend/templates/switch/languages.phtml index e076840edbc49..19a91b1044d8b 100644 --- a/app/code/Magento/Store/view/frontend/templates/switch/languages.phtml +++ b/app/code/Magento/Store/view/frontend/templates/switch/languages.phtml @@ -29,19 +29,26 @@ ?> getStores())>1): ?> -
    - -