1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* MagePrince |
5
|
|
|
* Copyright (C) 2020 Mageprince <[email protected]> |
6
|
|
|
* |
7
|
|
|
* @package Mageprince_BuyNow |
8
|
|
|
* @copyright Copyright (c) 2020 Mageprince (http://www.mageprince.com/) |
9
|
|
|
* @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License,version 3 (GPL-3.0) |
10
|
|
|
* @author MagePrince <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Mageprince\BuyNow\Observer; |
14
|
|
|
|
15
|
|
|
use Magento\Checkout\Model\Cart as CustomerCart; |
|
|
|
|
16
|
|
|
|
17
|
|
|
class AddRemainingProduct implements \Magento\Framework\Event\ObserverInterface |
|
|
|
|
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param \Magento\Quote\Model\QuoteFactory $quoteFactory |
22
|
|
|
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository |
23
|
|
|
* @param CustomerCart $cart |
24
|
|
|
*/ |
25
|
|
|
public function __construct( |
26
|
|
|
\Magento\Quote\Model\QuoteFactory $quoteFactory, |
|
|
|
|
27
|
|
|
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, |
|
|
|
|
28
|
|
|
CustomerCart $cart |
29
|
|
|
) { |
30
|
|
|
$this->quoteFactory = $quoteFactory; |
|
|
|
|
31
|
|
|
$this->customerRepository = $customerRepository; |
|
|
|
|
32
|
|
|
$this->cart = $cart; |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function execute(\Magento\Framework\Event\Observer $observer) |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
$flage = 1; |
38
|
|
|
try { |
39
|
|
|
$order = $observer->getEvent()->getOrder(); |
40
|
|
|
$quoteData = $this->quoteFactory->create(); |
41
|
|
|
$quoteData->load($order->getQuoteId()); |
42
|
|
|
if ($quoteData->hasData()) { |
43
|
|
|
if ($quoteData->getBuyNowId()) { |
44
|
|
|
if ($quoteData->getCustomerId()) { |
45
|
|
|
$customerRepoData = $this->customerRepository->getById($quoteData->getCustomerId()); |
46
|
|
|
$quoteDataReplace = $this->quoteFactory->create(); |
47
|
|
|
$quoteDataReplace->load($quoteData->getBuyNowId()); |
48
|
|
|
if ($quoteDataReplace->hasData()) { |
49
|
|
|
|
50
|
|
|
$quoteDataReplace->assignCustomer($customerRepoData); |
51
|
|
|
$quoteDataReplace->setBuyNowId(0); |
52
|
|
|
$quoteDataReplace->setIsActive(1); |
53
|
|
|
$quoteDataReplace->save(); |
54
|
|
|
|
55
|
|
|
/* Update buynow cart Value */ |
56
|
|
|
if ($observer->getEvent()->getUpdateData()) { |
57
|
|
|
$quoteData->setBuyNowId(0); |
58
|
|
|
$quoteDataReplace->setIsActive(0); |
59
|
|
|
$quoteData->save(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) { |
|
|
|
|
67
|
|
|
$flage = 0; |
|
|
|
|
68
|
|
|
} catch (\Magento\Framework\Exception\LocalizedException $e) { |
|
|
|
|
69
|
|
|
$flage = 0; |
70
|
|
|
} catch (\Exception $e) { |
71
|
|
|
$flage = 0; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths