|
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
|
|
|
$order = $observer->getEvent()->getOrder(); |
|
|
|
|
|
|
45
|
|
|
if ($quoteData->getCustomerId()) { |
|
46
|
|
|
$customerRepoData = $this->customerRepository->getById($quoteData->getCustomerId()); |
|
47
|
|
|
$quoteDataReplace = $this->quoteFactory->create(); |
|
48
|
|
|
$quoteDataReplace->load($quoteData->getBuyNowId()); |
|
49
|
|
|
if ($quoteDataReplace->hasData()) { |
|
50
|
|
|
|
|
51
|
|
|
$quoteDataReplace->assignCustomer($customerRepoData); |
|
52
|
|
|
$quoteDataReplace->setBuyNowId(0); |
|
53
|
|
|
$quoteDataReplace->setIsActive(1); |
|
54
|
|
|
$quoteDataReplace->save(); |
|
55
|
|
|
|
|
56
|
|
|
/* Update buynow cart Value */ |
|
57
|
|
|
if ($observer->getEvent()->getUpdateData()) { |
|
58
|
|
|
$quoteData->setBuyNowId(0); |
|
59
|
|
|
$quoteDataReplace->setIsActive(0); |
|
60
|
|
|
$quoteData->save(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) { |
|
|
|
|
|
|
68
|
|
|
$flage = 0; |
|
|
|
|
|
|
69
|
|
|
} catch (\Magento\Framework\Exception\LocalizedException $e) { |
|
|
|
|
|
|
70
|
|
|
$flage = 0; |
|
71
|
|
|
} catch (\Exception $e) { |
|
72
|
|
|
$flage = 0; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
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