Prepare the attribute options data: Create an array of attribute options data that you want to import. Each option should include the necessary information such as the option label, swatch value (for visual swatch), and any other relevant details. For example: php Copy code $attributeOptions = [ [ ‘label’ => ‘Red’, ‘value’ => ‘red’, ‘swatch_value’… Continue reading Add Magento 2 Visual Swatch and Text Swatch Attribute Options Programmatically
Category: Magento
How can I modify the code echo $block->escapeHtml($item->getRowTotal()); to display the value with two digits after the decimal point?
To display the value with two digits after the decimal point, you can modify the code as follows: echo $block->escapeHtml(number_format($item->getRowTotal(), 2)); The number_format()the function is used to format a number with grouped thousands and a specified number of decimal places. By passing $item->getRowTotal()as the first parameter and 2 as the second parameter, it will format… Continue reading How can I modify the code echo $block->escapeHtml($item->getRowTotal()); to display the value with two digits after the decimal point?
How to Create Custom Payment Method in Magento 2?
There are following files will have to create:- 1 – Create Test/Testpayment/registration.php for register your module. 2- Create Test/Testpayment/etc/module.xml for define module name. 3- Create Test/Testpayment/etc/config.xml for define your payment method. 4- Create Test/Testpayment/etc/adminhtml/system.xml for display payment method in backend. In this file mentioned only one field for enable/disable method.You can add field accordingly your need. 5- Create… Continue reading How to Create Custom Payment Method in Magento 2?
How to disable and enable the scroll in website(Java Script)
In this section we can see how we can disable and enable scrolling option in an ecommerce website using javascript function. First of all we have to set up a block of code in the respective page. // PREVENT DEFAULT HANDLERfunction preventDefault(e) { e = e || window.event; if (e.preventDefault) { e.preventDefault(); } e.returnValue =… Continue reading How to disable and enable the scroll in website(Java Script)
A Complete List of all events in Magento 2
Magento 2 Complete guide to the list of available events that will be used in daily routine as a Magento developer to trigger event-specific tasks at a time of Development. You can use any required events from the Core module to accomplish your requirements. Define events in the events.xml file, Create an observer.php file to… Continue reading A Complete List of all events in Magento 2
How to create an additional field in the Payment section of the Magento backend?
Added a new payment method by creating a new custom module in the app/code folder and named as Payment. Created files as follows etc->adminhtml and inside that system.xml Code: After this we need to delete the folder in setup module in our database, And after that; php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento s:s:d… Continue reading How to create an additional field in the Payment section of the Magento backend?
How to create an additional field in the customer section of the Magento backend?
Written the below code in the existing module customfield->setup->InstallData.phpCode: After this we need to delete the folder in setup module in our database, And after that; php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento s:s:d -f en_US –theme Swissup/argento-marketplace sudo chmod 777 -R /var/www/html/Szco_Supplies_Magento_Nestuite_website/ After this, it will be as shown in the screenshot below.… Continue reading How to create an additional field in the customer section of the Magento backend?
Fatal error: Call to a member function getSource() on boolean
fatal error: Call to a member function getSource() on boolean in C:\xampp\htdocs\my_store\app\code\core\Mage\Catalog\Model\Product.php on line 1390 Fatal error: Call to a member function getSource () on non-object products In Line 1390 file product.php To fix this error open the file: Code: /home/public_html/app/code/core/Mage/Catalog/Model/Product.php Find the lines: Code: public function getAttributeText($attributeCode) { return $this->getResource() ->getAttribute($attributeCode) ->getSource() ->getOptionText($this->getData($attributeCode)); }… Continue reading Fatal error: Call to a member function getSource() on boolean
Add Custom Field in customer registration frontend side form
To add address and country fields on the frontend custom form Add the below code in your customer_account_create.xml file. This Will add all Address Fields in the Registration Form in the frontend only
How to set the category layout for a product in Magento using the backend?
Log in to your Magento admin panel. Navigate to the “Catalog” menu and select “Categories” from the dropdown. Find and select the category for which you want to set the layout. In the “General Information” tab, scroll down to the “Custom Design” section. Expand the “Page Layout” dropdown and choose the desired layout option for… Continue reading How to set the category layout for a product in Magento using the backend?