From 072db47d0c2c036da488582956fbc51467d9d7ed Mon Sep 17 00:00:00 2001 From: Andriy Nasinnyk <anasinnyk@ebay.com> Date: Fri, 23 Oct 2015 15:43:17 +0300 Subject: [PATCH] MAGETWO-44307: Unable to add Bundle product to Order from Recently Viewed block --- .../Block/Adminhtml/Order/Create/Sidebar.php | 51 +++++++++++++++++++ .../Magento/Bundle/Model/Product/Type.php | 5 ++ app/code/Magento/Bundle/etc/adminhtml/di.xml | 3 ++ 3 files changed, 59 insertions(+) create mode 100644 app/code/Magento/Bundle/Block/Adminhtml/Order/Create/Sidebar.php diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Order/Create/Sidebar.php b/app/code/Magento/Bundle/Block/Adminhtml/Order/Create/Sidebar.php new file mode 100644 index 00000000000..12a3d48d20c --- /dev/null +++ b/app/code/Magento/Bundle/Block/Adminhtml/Order/Create/Sidebar.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Bundle\Block\Adminhtml\Order\Create; + +class Sidebar +{ + /** + * Get item qty + * + * @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject + * @param callable $proceed + * @param \Magento\Framework\DataObject $item + * + * @return string + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundGetItemQty( + \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject, + \Closure $proceed, + \Magento\Framework\DataObject $item + ) { + if ($item->getProduct()->getTypeId() == \Magento\Bundle\Model\Product\Type::TYPE_CODE) { + return ''; + } + return $proceed($item); + } + + /** + * Check whether product configuration is required before adding to order + * + * @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject + * @param callable $proceed + * @param string $productType + * + * @return bool + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundIsConfigurationRequired( + \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject, + \Closure $proceed, + $productType + ) { + if ($productType == \Magento\Bundle\Model\Product\Type::TYPE_CODE) { + return true; + } + return $proceed($productType); + } +} diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index 65742f76f26..2270f6cb149 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -19,6 +19,11 @@ use Magento\Framework\Pricing\PriceCurrencyInterface; */ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType { + /** + * Product type + */ + const TYPE_CODE = 'bundle'; + /** * Product is composite * diff --git a/app/code/Magento/Bundle/etc/adminhtml/di.xml b/app/code/Magento/Bundle/etc/adminhtml/di.xml index 0270ff9164b..91970a4cdd9 100644 --- a/app/code/Magento/Bundle/etc/adminhtml/di.xml +++ b/app/code/Magento/Bundle/etc/adminhtml/di.xml @@ -9,6 +9,9 @@ <type name="Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper"> <plugin name="Bundle" type="Magento\Bundle\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Bundle" sortOrder="60" /> </type> + <type name="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar"> + <plugin name="Bundle" type="Magento\Bundle\Block\Adminhtml\Order\Create\Sidebar" sortOrder="200"/> + </type> <type name="Magento\Catalog\Model\Product\CopyConstructor\Composite"> <arguments> <argument name="constructors" xsi:type="array"> -- GitLab