Web Development

get all products with php in Woocommerce WordPress

Get all products with php in Woocommerce WordPress require_once(‘../wp-load.php’); global $wpdb; // Get 10 most recent product IDs in date descending order. $query = new WC_Product_Query( array( ‘limit’ => -1 , ‘status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ) ); $products = $query->get_products(); foreach ( $products as $product ){ //print_r($products); //$pro_id = $product->get_id(); […]

WooCommerce Products Export to CSV via PHP

WooCommerce Products Export to CSV via PHP <?php require_once(‘../wp-load.php’); global $wpdb;   // Get 10 most recent product IDs in date descending order. $query = new WC_Product_Query( array( ‘limit’ => -1 , ‘status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ ) ); $products = $query->get_products(); //print_r($products); // while ( $products->have_posts() ) : $products->the_post(); // […]

Export to CSV via PHP

Export to CSV via PHP Use the following command <?php $list = array ( array(‘aaa’, ‘bbb’, ‘ccc’, ‘dddd’), array(‘123’, ‘456’, ‘789’), array(‘”aaa”‘, ‘”bbb”‘) ); $fp = fopen(‘file.csv’, ‘w’); foreach ($list as $fields) { fputcsv($fp, $fields); } fclose($fp); ?> Source: Export to CSV via PHP

Magento command for site with different version of PHP on aaPanel

Magento command for site with different version of PHP on aaPanel If default php version is 7.3 on aaPanel and your website is running on 7.2 use the following way to run commands /www/server/php/72/bin/php bin/magento setup:upgrade /www/server/php/72/bin/php bin/magento setup:di:compile /www/server/php/72/bin/php bin/magento setup:static-content:deploy

How To Create a Blurry Background Image with CSS

Create a Blurry Background Image with CSS /* The image used */ background-image: url(“photographer.jpg”); /* Add the blur effect */ filter: blur(8px); -webkit-filter: blur(8px); /* Full height */ height: 100%; /* Center and scale the image nicely */ background-position: center; background-repeat: no-repeat; background-size: cover;

Enable template-hints directly from the terminal using a command in Magento 2

Enable template-hints with command in Magento 2 php bin/magento dev:template-hints:enable php bin/magento dev:template-hints:disable  Remove Cache chmod -R 777 var/ pub/ generated/ php bin/magento cache:clean php bin/magento cache:flush rm -rf var/generation/ var/view_preprocessed/ pub/static/frontend/ pub/static/_requirejs/ var/cache var/di var/page_cache pub/static/_cache  

Magento 2 Migration : Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

Magento 2 Migration Error #Start elastic on the server sudo -i service elasticsearch start If Elasticsearch is not installed, then install it the following way – #use the following. If you are using default php then just use php instead of “/www/server/php/74/bin/php“. /www/server/php/74/bin/php -d memory_limit=-1 bin/magento setup:upgrade /www/server/php/74/bin/php -d memory_limit=-1 bin/magento cache:clean /www/server/php/74/bin/php -d memory_limit=-1 […]

Calling a Custom phtml file in another phtml file, cms block, cms page, and XML layout in Magento 2

Calling a Custom phtml file in Magento 2 Calling in phtml file <?php include ($block->getTemplateFile(‘Magento_Theme::extra/test-view.phtml’)); ?> Calling in CMS page and block {{block class=”Magento\Framework\View\Element\Template” name=”test_view” template=”Magento_Theme::extra/test-view.phtml”}} Calling in XML layout <block class=”Magento\Framework\View\Element\Template” name=”test_view” template=”Magento_Theme::extra/test-view.phtml”/> Source: magento.stackexchange.com/questions/212207/calling-a-custom-phtml-file-in-another-phtml-file-cms-block-cms-page-and-xml

Magento 2 Create Admin User via Command Line

Magento 2 Create Admin User php bin/magento admin:user:create –admin-user=mageplaza –admin-password=WeLoveMagento123 –admin-email=hi@mageplaza.com –admin-firstname=Mageplaza –admin-lastname=Family Source: https://www.mageplaza.com/devdocs/magento-2-add-admin-user-command-line.html#how-to-create-admin-user-via-command-line-in-magento-2

Magento 2 Installation Guide

Magento 2 Installation Guide Install Elasticsearch before installing Adobe Commerce or Magento Open Source 2.4.0 Get the metapackage composer create-project –repository-url=https://repo.magento.com/ magento/project-community-edition <install-directory-name> Set file permissions cd /var/www/html/<magento install directory> find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + find var generated vendor pub/static pub/media app/etc -type d -exec chmod […]

How to Install ‘Varnish’ (HTTP Accelerator)

Install ‘Varnish’ On Debian and Ubuntu aptitude update && aptitude install varnish On RHEL, CentOS and Fedora yum update && yum install varnish Enter the following command to display the version of Varnish you are running varnishd -V Enable it to start on boot On Debian, Ubuntu service varnish start service varnish status chkconfig –level […]

How to add background image in CSS

You can use the following to add background image in CSS <style type=”text/css”> body { background-image: url(“paper.gif”); background-color: #cccccc; } /* or */ body { background: lightblue url(“img_tree.gif”) no-repeat fixed center; } </style> Sources: https://www.w3schools.com/cssref/css3_pr_background.asp