Page 2 - Blog
- 
                    - February 23, 2024You can create a Plugin for the method SavePaymentInformation() in Magento 2 to add your logic before or after Payment information is saved. The method will be called after a click on the Place order button from the second step of the Checkout page. Original Class to create plugin: 
 Magento\Checkout\Model\PaymentInformationManagementYou can create a before or after plugin as per your requirement. Create a global scope di.xml file, <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Checkout\Model\PaymentInformationManagement"> <plugin name="set_payment_data_before_save" type="Samdoit\SavePayment\Plugin\Model\SavePaymentPlugin" sortOrder="10"/> </type> </config>Create a Plugin Class for the Before saves payment information, We have used Before Plugin type, <?php namespace Samdoit\SavePayment\Plugin\Model; use Magento\Quote\Api\Data\AddressInterface;
- 
                    - February 20, 2024As Magento 2 store owner, you may want to treat logged in and non-logged in customers differently. For example, you may want to offer exclusive features or discounts to logged in customers only. To implement this, you first need to confirm whether a Magento 2 customer is logged in or not? Methods To Check If A Customer Is Logged-In In Magento 2There are 2 ways you can check this. By injecting class and by using object manager. Although the 2nd method (object manager) is not recommended, it’s still used as an alternative. Method 1: By Injecting Class (Dependency Injection)In this method, first, you need to inject the following class in the constructor method: /Magento/Customer/Model/Sessionprotected $_session; public function __construct( ... \Magento\Customer\Model\Session $session, ... ) { ... $this->_session = $session; ... }Then in your class, use the following code in any function to check if the customer is logged in or not: if ($this->_session->isLoggedIn()) { // Customer is logged
- 
                    - February 18, 2024With Advanced Content Manager for Magento 2, it’s possible to index and make your content searchable. The default catalog search layout is overridden by our extension, in order to add our results to the search. 
 The extension is adding a Result Search Block into the Catalog Search Result page layout:Samdoit/ContentManager/view/frontend/layout/catalogsearch_result_index.xml<page xmlns:xsi="..." layout="2columns-left" xsi:noNamespaceSchemaLocation="..."> <body> <referenceContainer name="content"> <block class="Samdoit\ContentManager\Block\Search\Result" name="search.content.result" after="search.result" template="Samdoit_ContentManager::content/search/result.phtml" cacheable="false"> <referenceContainer> <body> <page>The Result Block retrieves the current query and create the search filter. The block will load a ContentList Collection from the ids retrieved in the results. This block has the following child: <block class="Samdoit\ContentManager\Block\Content\Widget\ContentList" name="search_content_result_list"
- 
                    - February 16, 2024With the support of seamless customization and integrations, Magento 2 e-commerce stores can serve excellent experiences to customers. In many cases, the store owners are willing to allow the shoppers to add the product to the cart with a custom price. Frequently, the store owner is prepared to set a fixed product pricing even if the consumer selects various options/add-ons from the front end for all or some specific products. Instead of manually changing all store products, we’ll need to manually code to override all store product prices with your preferred custom price. In this article, I will instruct you to set a custom price of the product when adding the product to the cart by using Observe. Let’s explore two straightforward steps below! Step 1: Create Events/xml FileFirstly, you need to create events/xmlin the folderMageplaza/HelloWord/etc/frontendand use eventcheckout_cart_product_add_after<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- 
                    - February 16, 2024This article shows how to get shopping cart items/products, subtotal and grand total of cart, and shipping and billing address entered while doing checkout in Magento 2. I will be using both Dependency Injection (DI) and Object Manager in the below example code. Using Object Manager – Get products id, name, price, quantity, etc. present in your cart. 
 – Get number of items in cart and total quantity in cart.
 – Get base total price and grand total price of items in cart.
 – Get billing and shipping addresses entered during checkout.Get all items information in cart $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cart = $objectManager->get('\Magento\Checkout\Model\Cart'); // retrieve quote items collection $itemsCollection = $cart->getQuote()->getItemsCollection(); // get array of all items what can be display directly $itemsVisible = $cart->getQuote()->getAllVisibleItems(); // retrieve quote items array $items = $cart->getQuote()->getAllItems(); foreach($items as $item)
- 
                    - February 13, 2024The most likely cause for the vTiger error “Sorry! Attempt to access restricted file.” is the $root_directory value in the ‘config.inc.php’ is incorrect or misspelled. In order to correct it follow the steps below: - Go to your vTigerCRM directory
- Open “config.inc.php” with your favorite text editor
 
- 
                    - June 08, 2023Unable to install php-zip on server with Amazon Linux 2023 as well as unable to find. 
- 
                    - September 18, 2022The default MySQL 8 auth plugin is auth_socket, which causes the error "SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client" when an application is attempting to log in to the database with a password. Let's go through the steps to fix this.Step 1Login to the mysqlserver in sudo mode as the root user and supply any required passwords.sudo mysql -u root -pStep 2Now run the following ALTER USERcommand, replacing root with your database user and password if your password.ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';Now run: FLUSH PRIVILEGES;Now exit the MySQL server: exit;Step 3You may need to restart the mysql services for the changes to take effect: sudo service mysql restart
- 
                    - June 22, 2022ProblemI am working with Magento 2.3. Recently I've configured the xdebug in my local to identify some process flow. But it does not help me to check the flow. Then I hit the website in local, I am facing the Uncaught Error: Call to undefined function xdebug_disable() in vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_bootstrap.php on line 73 SolutionOpen the file vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/_bootstrap.phpFrom :- if (!(bool)$debugMode && extension_loaded('xdebug')) { xdebug_disable(); }To:- if (!(bool)$debugMode && extension_loaded('xdebug')) { if (function_exists('xdebug_disable')) { xdebug_disable(); } }
- 
                    - June 15, 2021How can I select a random row using Eloquent or Fluent in the Laravel framework? I know that by using SQL, you can do order by RAND(). However, I would like to get the random row without doing a count on the number of records prior to the initial query. 
 
