Skip to main content

Posts

Sync prices in Magento from ERP system

Price synchronization is a critical aspect of e-commerce applications, and its importance cannot be understated. Price synchronization in e-commerce applications is essential for maintaining consistency, competitiveness, and customer trust. It also streamlines operations, reduces errors, and enables businesses to adapt to market changes, ultimately leading to better customer experiences and increased revenue. So it's important to have a fast and efficient synchronization process for syncing prices from another application to Magento. Let's see how we can achieve this. This is the main function that needs to be called for importing the price. In this, we can see we have imported the price for a multiwebsite setup. If you have a system with a single website, you can remove the loop and use the rest of the code. public function execute() { $prices = []; $websites = $this->systemConfig->getWebsites(); foreach ($websites as $website) { if (...

A Comprehensive Guide to Magento 2 Store Configuration

In the ever-evolving world of e-commerce, Magento 2 stands as a powerful platform that empowers businesses to create and manage their online stores effectively. One of the critical aspects of setting up a successful store is configuring it correctly. In this guide, we'll walk through the essential store settings and configurations in Magento 2. Whether you're a Business Analyst, Product Analyst, Tester, or anyone involved in the e-commerce landscape, this blog will help you understand the vital actions, settings, and configurations needed to optimize your Magento 2 store. Before getting into configuration, we need to understand the multi-website & multi-store & multi-lingual concepts that are supported by Magento. Since this blog series is about configuration, I just want to mention that all configurations are based on stores & websites. In a simple way, we can have different configurations for differe...

Disable Hover on main menu and make it work on click

The main menu in an eCommerce website holds significant importance as it serves as the primary navigational tool for users to explore and access various sections, products, and features of the online store. The main menu helps users discover products, services, and content they might not have been aware of. By presenting various categories and sections prominently, the menu can drive users to explore different parts of the website, increasing the chances of making a sale. The style and layout of the main menu contribute to the website's overall aesthetic & attractiveness. Magento essentially makes use of a jQuery menu widget to deliver all of its default features. By default, the menu appears when you mouse over it. I had a requirement in which I needed to open the menu only when the customer clicked. Because we were using Megamenu, and when it opened, it took up half of the screen. And this might be annoying for customers at times.  So to solve this, I have created a JS ...

Layout Processing Priority

While working in Magento, theme developers need to override the layouts from the core modules. And then the developers using those themes may need to customize them according to their requirements.  Magento always recommends, to ensure stability and secure your customizations from being deleted during the upgrade, not change out-of-the-box module and theme layouts. To make the necessary changes, create extending and overriding layout files in your custom theme or module. When multiple copies of the same layouts are available in a project, developers get confused about the layout's execution. So to understand how the layouts are being processed by the application, see the points below: Layouts from the module's base directory. Then layouts from the module's area directory. If the same layout is customized in multiple modules, then they are merged based on the sequence of modules in the app/etc/config.xml file. Then layouts from the theme's design/frontend/Namespace_Modul...

How to add new cart item attribute in SalesRule Conditions?

Promotions play a crucial role in the success of an eCommerce business. They are essential for attracting customers, increasing sales, building brand loyalty, and staying competitive in the online marketplace. Managing promotions in Magento 2 can be done through the built-in promotional tools and features. Magento 2 offers a flexible and powerful promotion system to create various types of promotions like discounts, coupons, free shipping, etc. But there is always a scope for change in the business requirement for creating a promotion, and we are going to discuss more on this requirement. Currently, Magento provides the below conditions on which you can create your promotion rules. But by following the below steps you can manage and learn to add more options to the cart price rule. Step 1: First, we need to add a plugin for class Magento\SalesRule\Model\Rule\Condition\Product. <?xml version="1.0" ?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...

Magento 2 - Product Feed

If you operate an online store and want to sell your products, you surely want your offer to be displayed accurately and in the best way possible. Because, in today's competitive market, when customers receive various discounts and offers across all e-commerce platforms, your potential customers, regardless of where you sell, demand exact, complete, and up-to-date product information. As a result, e-commerce sites must create and optimize product feeds. What is Product Feed? The product feed is the most important part of the eCommerce business as it allows the owner to grow their business and marketers to advertise their company's product.  In basic terms, a product feed is a data feed that comprises all of the attributes of a product. Product feed files can be generated in a variety of file formats depending on the system to which the products will be pushed. The most used file formats are XML and CSV. The content of the product feed may vary, but the fundamental goal of the p...

"Asymmetric transaction rollback" in DataPatch

I was working on one of the needs in which I needed to add some new data to the catalog_eav_attribute table. And for that, I've created an update query that will be executed from DataPatch, and the query will be executed to update data in the database when the code is deployed to the server. So I have added below code: public function apply() { $this->moduleDataSetup->getConnection()->startSetup(); $connection = $this->resourceConnection->getConnection(); try { if ($connection->tableColumnExists('catalog_eav_attribute', 'used_in_feed') === true) { foreach ($this->attributes as $attribute) { $query = "UPDATE catalog_eav_attribute SET used_in_feed = 1 WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = 4 AND attribute_code = '" . $attribute . "')"; $connection->query($query); ...