How to use insertFromSelect query in database Magento 2 with best practice?

You can use INSERT IGNORE INTO mysql query with the help of insertFromSelect() method in Magento 2 with use of magento best standard in your module.

Lets we have a query that use the insertFromSelect method to run a query.

Raw SQL Query to add an entry to the small_image attribute from the image attribute value. Continue reading “How to use insertFromSelect query in database Magento 2 with best practice?”

How to check is database table exists or not by Magento 2?

You can verify the given database table available in the database with the help of isTableExists() method by use of Magento\Framework\App\ResourceConnection class.

This method is useful when you are dealing with a database query and want to run your query on the safe side to check whether the first given table exists or not before firing the SQL query. Continue reading “How to check is database table exists or not by Magento 2?”

How to fix Magento custom patch throws an error while patch applied?

Magento applies a custom patch with a command line, composer -v install throws an error,

[TypeError]                                                                                                                 
  Composer\Util\RemoteFilesystem::copy(): Argument #1 ($originUrl) must be of type string, null given, called in /var/www/ht  
  ml/vendor/cweagans/composer-patches/src/Patches.php on line 388    
  
          "Patch Call to a member function getCustomer() on null fix": "patches/vendor/rbj/module-customer-feature/Model/Rule/Condition/Customer.patch" IN the class name typo issue.

Here you can’t able to apply the patch and throw an error as mentioned above. Continue reading “How to fix Magento custom patch throws an error while patch applied?”