Skip to content

Could not apply patch! Skipping

Facing a strange issue when applying patch with composer install (I have added correct patch file path in composer.json).

When running “composer install” it is throwing error “Could not apply patch! Skipping.”

But when applying patch using git apply then it is working fine without any error.

Don’t know what is the issue. If you have face such issue then please let me know the solution.

My patch file is below:-

Index: It solved error on cart page when admin disabled a product which is inside cart
==========================================================================================
diff --git a/vendor/affirm/magento2/Plugin/RestrictPaymentMethods.php b/vendor/affirm/magento2/Plugin/RestrictPaymentMethods.php
--- a/vendor/affirm/magento2/Plugin/RestrictPaymentMethods.php
+++ b/vendor/affirm/magento2/Plugin/RestrictPaymentMethods.php
@@ -17,21 +17,25 @@
     public function afterGetActiveList(MagentoPaymentModelPaymentMethodList $subject, $result)
     {
         $methods = $result;
-
-        $om = MagentoFrameworkAppObjectManager::getInstance();
-        $checkoutsession = $om->get('MagentoCheckoutModelSession');
-        $quote = $checkoutsession->getQuote();
+        try {
+            $om = MagentoFrameworkAppObjectManager::getInstance();
+            $checkoutsession = $om->get('MagentoCheckoutModelSession');
+            $quote = $checkoutsession->getQuote();

-        $address = $quote->getShippingAddress();
-        foreach ($methods as $k => $method) {
-            foreach ($this->getRules($address) as $rule) {
-                if ($rule->restrict($method)) {
-                    if ($rule->validate($address)) {
-                        unset($methods[$k]);
+            $address = $quote->getShippingAddress();
+            foreach ($methods as $k => $method) {
+                foreach ($this->getRules($address) as $rule) {
+                    if ($rule->restrict($method)) {
+                        if ($rule->validate($address)) {
+                            unset($methods[$k]);
+                        }
                     }
                 }
             }
         }
+        catch (Exception $e){
+
+        }

         return $methods;