Query to get the top buyers in Magento 2

SELECT `sales_order`.`customer_id`, `email`, `firstname`, `lastname`, `telephone`, `street`, `city`, `region`, `company`, SUM(subtotal_invoiced) FROM (`sales_order` LEFT JOIN `sales_order_address` ON `sales_order`.`entity_id` = `sales_order_address`.`parent_id` AND `sales_order_address`.`address_type` = "billing") WHERE state = "complete" AND store_id = 1 GROUP BY customer_email ORDER BY SUM(subtotal_invoiced) DESC LIMIT 100   Note: Guest users have customer_id NULL.

Standalone function get increment_id using order id

private static function getIncrementIDfromOrderID($orderID) { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of object manager $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); $connection = $resource->getConnection(); $tableName = $resource->getTableName('sales_order'); //gives table name with prefix //Select Data from table $result = $connection->fetchAll("SELECT increment_id FROM " . $tableName . " WHERE entity_id = " . $orderID); if (count($result)) { return $result[0]['increment_id']; } return 0; … Read more

Fix Gravity Forms & Magento 2 WordPress Integration confliction

Fatal error: Uncaught Error: Call to a member function get() on null in /magento/dir/vendor/magento/framework/Code/Generator.php:242 Stack trace: #0 /magento/dir/vendor/magento/framework/Code/Generator.php(120): Magento\Framework\Code\Generator->shouldSkipGeneration('logger', 'K', 'KLogger') #1 /wordpress/dir/wp-content/plugins/m2wp/include/classes/M2I_Mage_Autoloader.php(27): Magento\Framework\Code\Generator->generateClass('KLogger') #2 [internal function]: M2I_Mage_Autoloader->load('KLogger') #3 [internal function]: spl_autoload_call('KLogger') #4 /wordpress/dir/wp-content/plugins/gravityforms/includes/logging/logging.php(653): class_exists('KLogger') #5 /wordpress/dir/wp-content/plugins/gravityforms/common.php(4513): GFLogging::include_logger() #6 /wordpress/dir/wp-content/plugins/gravityforms/includes/class-gf-upgrade.php(230): GFCommon::log_debug('GF_Upgrade::set…') #7 /wordpress/dir/wp-content/plugins/gravityforms/includes/cl in /magento/dir/vendor/magento/framework/Code/Generator.php on line 242 This is a very uncommon issue, the … Read more

Magento 2.3.2 File was not uploaded

The problem Recently I fixed a bug relating to “file uploading” function. The situation: Magento 2.3.2 PHP 7.2.20 Files permission is correct The var/log/exception.log doesn’t show the error detail The only clue that I have is the warning: File was not uploaded. After check this Github issue, I figure out that the file’s “mime-type” may … Read more

Notes about Let’s Encrypt

1. Use Certbot docker to generates the certs Let’s Encrypt Wildcard SSL with Certbot docker Example of Nginx configuration: server { listen 80; listen 443 ssl; ssl_certificate /etc/letsencrypt/live/example.com/cert.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; … } 2. Auto-renew with Certbot docker https://medium.com/@pentacent/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71