<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Magento2 - Tag Vibe</title>
	<atom:link href="https://www.tagvibe.com/category/magento2/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.tagvibe.com</link>
	<description>Connect. Create. Conquer.</description>
	<lastBuildDate>Thu, 26 Jun 2025 04:39:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://www.tagvibe.com/wp-content/uploads/2024/05/cropped-cropped-logo-tagvibe-1-32x32.png</url>
	<title>Magento2 - Tag Vibe</title>
	<link>https://www.tagvibe.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Unlocking Unprecedented Flexibility and Performance for Your E-commerce in 2025</title>
		<link>https://www.tagvibe.com/unlocking-unprecedented-flexibility-and-performance-for-your-e-commerce-in-2025/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 26 Jun 2025 04:39:00 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<guid isPermaLink="false">https://www.tagvibe.com/?p=1832</guid>

					<description><![CDATA[<p>Headless Magento Explained: Unlocking Unprecedented Flexibility and Performance for Your E-commerce in 2025 The e-commerce landscape in 2025 is a crucible of innovation. Customers, armed with smartphones and insatiable appetites for instant gratification, demand blazing-fast load times, hyper-personalized experiences, and seamless interactions across every digital touchpoint. Businesses, in turn, are scrambling to keep pace, struggling with the limitations of traditional monolithic platforms that often impede agility and restrict creative freedom. Enter Headless Commerce, a revolutionary architectural approach that&#8217;s reshaping how online businesses are built. And at the forefront of this revolution, leveraging its robust backend capabilities, stands Magento (Adobe Commerce). No longer just a conventional e-commerce platform, Headless Magento is emerging as the strategic choice for enterprises and ambitious brands seeking to unlock unprecedented flexibility, unleash superior performance, and truly future-proof their online presence. This comprehensive guide will demystify Headless Magento. We&#8217;ll explore what it means to go headless, why this architecture is rapidly becoming the standard for leading brands, how it works under the hood, its profound advantages, and the considerations you need to keep in mind before making the leap. What Exactly is Headless Commerce? The Analogy To understand headless commerce, let&#8217;s first picture a traditional e-commerce platform – often called a &#8220;monolith.&#8221; In a monolithic setup, the frontend (what your customers see and interact with, like your website&#8217;s design, product pages, checkout flow) and the backend (the engine that handles product data, orders, customer information, inventory, and payment processing) are tightly coupled. They are built and deployed as a single, interdependent unit. Any change to the frontend might require adjustments to the backend, and vice-versa, making updates slow and complex. Now, imagine a headless system. Think of it like this: Your e-commerce backend (powered by Magento) is like a highly efficient, well-organized kitchen. It stores all the ingredients (product data), manages the recipes (business logic for pricing, inventory, orders), and handles the payment terminal. The frontend is like the restaurant&#8217;s dining area – the décor, the tables, the menus. But crucially, it’s detached from the kitchen. Instead of the kitchen dictating the dining area&#8217;s design, the dining area (your website, mobile app, smart display, voice assistant) simply sends orders to the kitchen through a standardized &#8220;waiter&#8221; – the API (Application Programming Interface). The kitchen (Magento backend) processes the order and sends the requested &#8220;dish&#8221; (data) back to the dining area. This decoupling of the frontend from the backend is the essence of headless commerce. Why Go Headless with Magento? The Core Drivers in 2025 The shift to headless isn&#8217;t just a technical trend; it&#8217;s a strategic imperative driven by evolving customer expectations and business needs: Blazing-Fast Performance: In India, where mobile penetration is incredibly high and internet speeds can vary, customers expect instantaneous load times. Every second counts. Headless storefronts, often built with modern JavaScript frameworks, load significantly faster than traditional monolithic sites, directly impacting bounce rates, conversion rates, and SEO. Unmatched Flexibility and Creative Freedom: Brands are constantly striving for unique online experiences that reflect their identity. Headless allows designers and frontend developers complete creative control, enabling pixel-perfect custom designs, dynamic content, and unique user journeys without being constrained by the backend&#8217;s templating system. Omnichannel Imperative: Modern consumers interact with brands across countless touchpoints: websites, mobile apps, social media, in-store kiosks, voice assistants, smart mirrors, and IoT devices. A single Magento backend can now power all these diverse &#8220;heads,&#8221; ensuring a consistent brand experience and centralized data management across every channel. This is particularly vital for brands targeting the diverse consumer habits across India. Agility and Faster Time-to-Market: With decoupled architectures, frontend developers can iterate rapidly, deploy new features, or update designs without needing to touch the backend. This accelerates development cycles, allowing businesses to respond quickly to market trends, run A/B tests, and launch new campaigns with unprecedented speed. Enhanced Scalability: The frontend and backend can be scaled independently. A surge in traffic to your website won&#8217;t necessarily overload your backend, and vice versa. This elasticity ensures your store remains performant even during peak sales events (like Diwali or festive sales). Future-Proofing Your Investment: Technology evolves at a dizzying pace. By decoupling, you future-proof your e-commerce platform. If a new, superior frontend technology emerges five years from now, you can simply swap out your current frontend &#8220;head&#8221; without rebuilding your entire commerce engine. Improved Developer Experience: Frontend developers can use their preferred tools and frameworks (React, Vue.js, Angular, Next.js), leading to higher productivity and access to a broader talent pool. How Headless Magento Works: The Architecture Unpacked At its core, a Headless Magento setup involves three key layers: The Magento Backend (The Commerce Engine): This remains the heart of your e-commerce operation. It manages all the essential commerce functionalities: Product Information Management (PIM): Product catalogs, pricing, inventory. Order Management System (OMS): Order processing, fulfillment, returns. Customer Relationship Management (CRM): Customer accounts, history, loyalty. Promotions &#38; Discounts: Rules, coupons, segmentation. Payment Gateway Integrations: Secure payment processing. All these operations are exposed via APIs. The API Layer (The Communication Bridge): This is the crucial link between your frontend and backend. Magento provides robust APIs for this communication: REST (Representational State Transfer) APIs: The traditional, widely used API style, offering a comprehensive set of endpoints for various e-commerce operations. GraphQL APIs: Gaining significant popularity for headless commerce. GraphQL allows the frontend to request exactly the data it needs in a single query, reducing over-fetching or under-fetching of data. This leads to more efficient data transfer and faster load times, especially beneficial for complex product pages or dynamic content. The Frontend Layer (The &#8220;Head&#8221;): This is entirely separate from the Magento backend and built using modern web technologies. Popular choices include: Modern JavaScript Frameworks: React.js, Vue.js, Angular. Server-Side Rendering (SSR) Frameworks: Next.js (for React), Nuxt.js (for Vue.js), which are crucial for SEO and initial page load speed. Progressive Web App (PWA) Frameworks: Magento PWA Studio: Adobe&#8217;s official toolkit specifically designed for building blazing-fast PWAs on top of Magento. It provides pre-built components (like Venia, a reference storefront), developer</p>
<p>The post <a href="https://www.tagvibe.com/unlocking-unprecedented-flexibility-and-performance-for-your-e-commerce-in-2025/">Unlocking Unprecedented Flexibility and Performance for Your E-commerce in 2025</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<h2 class="gtfy-1 gtfy-2">Headless Magento Explained: Unlocking Unprecedented Flexibility and Performance for Your E-commerce in 2025</h2>
<p>The e-commerce landscape in 2025 is a crucible of innovation. Customers, armed with smartphones and insatiable appetites for instant gratification, demand blazing-fast load times, hyper-personalized experiences, and seamless interactions across every digital touchpoint. Businesses, in turn, are scrambling to keep pace, struggling with the limitations of traditional monolithic platforms that often impede agility and restrict creative freedom.</p>
<p>Enter <b>Headless Commerce</b>, a revolutionary architectural approach that&#8217;s reshaping how online businesses are built. And at the forefront of this revolution, leveraging its robust backend capabilities, stands <b>Magento (Adobe Commerce)</b>. No longer just a conventional e-commerce platform, Headless Magento is emerging as the strategic choice for enterprises and ambitious brands seeking to unlock unprecedented flexibility, unleash superior performance, and truly future-proof their online presence.</p>
<p>This comprehensive guide will demystify Headless Magento. We&#8217;ll explore what it means to go headless, why this architecture is rapidly becoming the standard for leading brands, how it works under the hood, its profound advantages, and the considerations you need to keep in mind before making the leap.</p>
<h3>What Exactly is Headless Commerce? The Analogy</h3>
<p>To understand headless commerce, let&#8217;s first picture a traditional e-commerce platform – often called a &#8220;monolith.&#8221; In a monolithic setup, the frontend (what your customers see and interact with, like your website&#8217;s design, product pages, checkout flow) and the backend (the engine that handles product data, orders, customer information, inventory, and payment processing) are tightly coupled. They are built and deployed as a single, interdependent unit. Any change to the frontend might require adjustments to the backend, and vice-versa, making updates slow and complex.</p>
<p>Now, imagine a headless system. Think of it like this: Your e-commerce backend (powered by Magento) is like a highly efficient, well-organized kitchen. It stores all the ingredients (product data), manages the recipes (business logic for pricing, inventory, orders), and handles the payment terminal.</p>
<p>The frontend is like the restaurant&#8217;s dining area – the décor, the tables, the menus. But crucially, <b>it’s detached from the kitchen.</b> Instead of the kitchen dictating the dining area&#8217;s design, the dining area (your website, mobile app, smart display, voice assistant) simply sends orders to the kitchen through a standardized &#8220;waiter&#8221; – the <b>API (Application Programming Interface)</b>. The kitchen (Magento backend) processes the order and sends the requested &#8220;dish&#8221; (data) back to the dining area.</p>
<p>This <b>decoupling</b> of the frontend from the backend is the essence of headless commerce.</p>
<h3>Why Go Headless with Magento? The Core Drivers in 2025</h3>
<p>The shift to headless isn&#8217;t just a technical trend; it&#8217;s a strategic imperative driven by evolving customer expectations and business needs:</p>
<ol start="1">
<li><b>Blazing-Fast Performance:</b> In India, where mobile penetration is incredibly high and internet speeds can vary, customers expect instantaneous load times. Every second counts. Headless storefronts, often built with modern JavaScript frameworks, load significantly faster than traditional monolithic sites, directly impacting bounce rates, conversion rates, and SEO.</li>
<li><b>Unmatched Flexibility and Creative Freedom:</b> Brands are constantly striving for unique online experiences that reflect their identity. Headless allows designers and frontend developers complete creative control, enabling pixel-perfect custom designs, dynamic content, and unique user journeys without being constrained by the backend&#8217;s templating system.</li>
<li><b>Omnichannel Imperative:</b> Modern consumers interact with brands across countless touchpoints: websites, mobile apps, social media, in-store kiosks, voice assistants, smart mirrors, and IoT devices. A single Magento backend can now power all these diverse &#8220;heads,&#8221; ensuring a consistent brand experience and centralized data management across every channel. This is particularly vital for brands targeting the diverse consumer habits across India.</li>
<li><b>Agility and Faster Time-to-Market:</b> With decoupled architectures, frontend developers can iterate rapidly, deploy new features, or update designs without needing to touch the backend. This accelerates development cycles, allowing businesses to respond quickly to market trends, run A/B tests, and launch new campaigns with unprecedented speed.</li>
<li><b>Enhanced Scalability:</b> The frontend and backend can be scaled independently. A surge in traffic to your website won&#8217;t necessarily overload your backend, and vice versa. This elasticity ensures your store remains performant even during peak sales events (like Diwali or festive sales).</li>
<li><b>Future-Proofing Your Investment:</b> Technology evolves at a dizzying pace. By decoupling, you future-proof your e-commerce platform. If a new, superior frontend technology emerges five years from now, you can simply swap out your current frontend &#8220;head&#8221; without rebuilding your entire commerce engine.</li>
<li><b>Improved Developer Experience:</b> Frontend developers can use their preferred tools and frameworks (React, Vue.js, Angular, Next.js), leading to higher productivity and access to a broader talent pool.</li>
</ol>
<h3>How Headless Magento Works: The Architecture Unpacked</h3>
<p>At its core, a Headless Magento setup involves three key layers:</p>
<ol start="1">
<li><b>The Magento Backend (The Commerce Engine):</b>
<ul>
<li>This remains the heart of your e-commerce operation. It manages all the essential commerce functionalities:
<ul>
<li><b>Product Information Management (PIM):</b> Product catalogs, pricing, inventory.</li>
<li><b>Order Management System (OMS):</b> Order processing, fulfillment, returns.</li>
<li><b>Customer Relationship Management (CRM):</b> Customer accounts, history, loyalty.</li>
<li><b>Promotions &amp; Discounts:</b> Rules, coupons, segmentation.</li>
<li><b>Payment Gateway Integrations:</b> Secure payment processing.</li>
</ul>
</li>
<li>All these operations are exposed via APIs.</li>
</ul>
</li>
<li><b>The API Layer (The Communication Bridge):</b>
<ul>
<li>This is the crucial link between your frontend and backend. Magento provides robust APIs for this communication:
<ul>
<li><b>REST (Representational State Transfer) APIs:</b> The traditional, widely used API style, offering a comprehensive set of endpoints for various e-commerce operations.</li>
<li><b>GraphQL APIs:</b> Gaining significant popularity for headless commerce. GraphQL allows the frontend to request <i>exactly</i> the data it needs in a single query, reducing over-fetching or under-fetching of data. This leads to more efficient data transfer and faster load times, especially beneficial for complex product pages or dynamic content.</li>
</ul>
</li>
</ul>
</li>
<li><b>The Frontend Layer (The &#8220;Head&#8221;):</b>
<ul>
<li>This is entirely separate from the Magento backend and built using modern web technologies. Popular choices include:
<ul>
<li><b>Modern JavaScript Frameworks:</b> React.js, Vue.js, Angular.</li>
<li><b>Server-Side Rendering (SSR) Frameworks:</b> Next.js (for React), Nuxt.js (for Vue.js), which are crucial for SEO and initial page load speed.</li>
<li><b>Progressive Web App (PWA) Frameworks:</b>
<ul>
<li><b>Magento PWA Studio:</b> Adobe&#8217;s official toolkit specifically designed for building blazing-fast PWAs on top of Magento. It provides pre-built components (like Venia, a reference storefront), developer tools, and best practices.</li>
<li><b>Vue Storefront:</b> A popular open-source, vendor-agnostic PWA framework that can connect to Magento and other e-commerce platforms.</li>
<li><b>ScandiPWA:</b> A Magento-specific PWA theme that offers a comprehensive headless solution.</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ol>
<p><b>The Data Flow:</b> When a user interacts with your headless store:</p>
<ol start="1">
<li>The frontend (e.g., your PWA) sends a request to the Magento backend via its REST or GraphQL APIs (e.g., &#8220;fetch product details for SKU X&#8221;).</li>
<li>The Magento backend processes the request, retrieves the necessary data from its database, and performs any business logic.</li>
<li>The backend sends the requested data back to the frontend via the API.</li>
<li>The frontend receives the data and renders the user interface dynamically, providing a seamless and instant experience.</li>
</ol>
<h3>Unprecedented Flexibility: Deeper Dive</h3>
<ul>
<li><b>Complete Creative Control:</b> Break free from templating limitations. Designers have a blank canvas to create bespoke, pixel-perfect user interfaces, custom animations, and unique brand storytelling, resulting in a truly distinctive online presence.</li>
<li><b>Technology Agnosticism:</b> You&#8217;re not locked into a specific frontend technology. Your team can choose the best framework for their skills and project needs, leading to more efficient development and access to a wider talent pool.</li>
<li><b>Omnichannel Reach (Revisited):</b>
<ul>
<li><b>Web:</b> A super-fast PWA or traditional website.</li>
<li><b>Mobile Apps:</b> Power native iOS and Android apps with the same backend.</li>
<li><b>In-Store Experiences:</b> Connect digital kiosks, smart mirrors, or interactive displays.</li>
<li><b>Voice Commerce:</b> Integrate with voice assistants like Alexa or Google Assistant.</li>
<li><b>IoT Devices:</b> Enable smart appliances or wearables to interact with your commerce engine. This creates a unified commerce experience, where all channels are synchronized with your Magento backend, providing consistent customer data and inventory.</li>
</ul>
</li>
<li><b>Microservices Integration:</b> Headless architecture naturally lends itself to integrating other specialized microservices for search (e.g., Algolia), content (e.g., Contentful), personalization (e.g., Klevu), or payments, creating a &#8220;best-of-breed&#8221; e-commerce ecosystem.</li>
</ul>
<h3>Unlocking Superior Performance: Deeper Dive</h3>
<ul>
<li><b>Blazing-Fast Load Times:</b> Frontend frameworks are built for speed. By rendering content on the client side (or with SSR), they significantly reduce the time-to-first-byte and overall page load times. This is vital for customer satisfaction and directly impacts your Google SEO rankings.</li>
<li><b>Improved Core Web Vitals:</b> Headless setups inherently excel at achieving high scores for Google&#8217;s Core Web Vitals (Largest Contentful Paint, First Input Delay, Cumulative Layout Shift), which are critical ranking factors for mobile-first indexing.</li>
<li><b>Efficient Caching:</b> Frontend frameworks can implement aggressive caching strategies, storing more data client-side and reducing the number of requests to the backend, leading to an even snappier user experience.</li>
<li><b>Independent Scaling:</b> Your frontend and backend can scale independently. If your marketing campaign drives a massive surge in website traffic, you can scale your frontend servers without necessarily needing to scale your entire Magento backend. This optimizes resource allocation and cost.</li>
<li><b>True App-like Experiences with PWAs:</b>
<ul>
<li><b>Offline Capabilities:</b> PWAs can cache content, allowing users to browse products even when they have no internet connection (e.g., in remote areas or during transit).</li>
<li><b>Push Notifications:</b> Re-engage users directly on their devices with personalized alerts for sales, abandoned carts, or new arrivals.</li>
<li><b>&#8220;Add to Home Screen&#8221; Prompts:</b> Encourage users to &#8220;install&#8221; your PWA like a native app, increasing direct access and repeat visits.</li>
<li><b>Smooth Navigation &amp; Animations:</b> Modern frontend frameworks provide fluid transitions and responsive interactions, mimicking the feel of a native mobile application.</li>
</ul>
</li>
</ul>
<h3>When to Consider Headless Magento for Your Business</h3>
<p>While incredibly powerful, headless commerce isn&#8217;t for every business. It&#8217;s a strategic investment that yields significant returns for specific scenarios:</p>
<ul>
<li><b>You Have Complex E-commerce Needs:</b> If your business requires a highly customized user experience, unique checkout flows, or integrates with numerous third-party systems that traditional themes struggle with.</li>
<li><b>Performance is Paramount:</b> If every millisecond of page load time directly translates to significant revenue gains or losses (e.g., high-traffic flash sales sites, competitive retail).</li>
<li><b>You&#8217;re Implementing an Omnichannel Strategy:</b> If you need to deliver a consistent brand experience across multiple touchpoints beyond just a standard website (e.g., native mobile apps, in-store digital screens, IoT).</li>
<li><b>You are a Large-Scale B2C or B2B Operation:</b> Businesses with extensive product catalogs, high transaction volumes, or complex customer segmentation benefit immensely from the scalability and flexibility.</li>
<li><b>You Have Existing Native Mobile Apps:</b> If you already have iOS and Android apps, headless allows you to unify their backend logic with your web store, streamlining data and management.</li>
<li><b>You Have a Strong Frontend Development Team:</b> Headless requires expertise in modern JavaScript frameworks and API integration.</li>
<li><b>You Operate in a Highly Competitive Market:</b> Headless provides the cutting-edge UX and performance needed to stand out and capture market share.</li>
<li><b>You are in India:</b> Given the country&#8217;s mobile-first user base, varying internet connectivity, and demand for personalized digital experiences, headless Magento with a strong PWA frontend is an ideal solution for Indian businesses looking for a competitive edge.</li>
</ul>
<h3>Challenges &amp; Considerations</h3>
<p>While the benefits are immense, it&#8217;s crucial to be aware of the challenges:</p>
<ul>
<li><b>Increased Complexity:</b> A headless setup involves more moving parts. This means more initial development effort, more components to manage, and potentially more complex debugging.</li>
<li><b>Higher Initial Cost:</b> Building a custom frontend from scratch can be more expensive upfront than implementing a pre-built theme. However, this is often offset by long-term flexibility and performance gains.</li>
<li><b>SEO Nuances:</b> While PWAs are SEO-friendly, proper implementation of Server-Side Rendering (SSR) or Static Site Generation (SSG) is crucial to ensure search engine crawlers can index your content effectively.</li>
<li><b>Extension Compatibility:</b> Not all existing Magento extensions are &#8220;headless-ready.&#8221; Some may require custom API development or alternative solutions to integrate with a decoupled frontend.</li>
<li><b>Deployment &amp; Management:</b> Managing separate frontend and backend deployments, along with API gateways and potentially multiple hosting environments, requires more sophisticated DevOps practices.</li>
</ul>
<h3>Conclusion: Your Gateway to Future-Proof E-commerce</h3>
<p>In 2025, Headless Magento is more than just a buzzword; it&#8217;s a strategic architectural shift that empowers businesses to deliver the next generation of e-commerce experiences. By decoupling the frontend from the powerful Magento backend, you unlock a realm of unprecedented flexibility in design, achieve lightning-fast performance, and enable a truly unified omnichannel presence.</p>
<p>While it demands a higher initial investment in development and a more sophisticated technical approach, the long-term benefits in terms of user experience, agility, scalability, and future-proofing your e-commerce investment are invaluable. If your business is ready to move beyond the limitations of traditional e-commerce and truly dominate the digital landscape, embracing Headless Magento could be the most strategic decision you make this year. It&#8217;s time to unleash the full potential of your online store and build a platform that&#8217;s ready for anything the future of commerce throws at it.</p><p>The post <a href="https://www.tagvibe.com/unlocking-unprecedented-flexibility-and-performance-for-your-e-commerce-in-2025/">Unlocking Unprecedented Flexibility and Performance for Your E-commerce in 2025</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Android App Development A Complete Guide for 2025</title>
		<link>https://www.tagvibe.com/android-app-development-a-complete-guide-for-2025/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 26 Jun 2025 02:21:55 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<guid isPermaLink="false">https://www.tagvibe.com/?p=1790</guid>

					<description><![CDATA[<p>Android app development has transformed how we interact with technology. With more than 3 billion active Android devices worldwide, building an Android app is no longer a luxury—it&#8217;s a necessity for businesses, entrepreneurs, and developers aiming for a global audience. In 2025, Android continues to lead the mobile OS market due to its open-source nature, wide device range, and the power of the Google Play ecosystem. Whether you’re a beginner looking to create your first app or a business owner exploring app-based growth, understanding Android development is your first step. This comprehensive guide covers everything you need to know about Android app development—from tools, languages, and frameworks to monetization and publishing strategies. 1. Why Choose Android App Development? 📱 Global Reach Android powers 70%+ of global smartphones. Available in over 190 countries and thousands of devices. 💰 Cost-Effective Lower entry barriers compared to iOS. No need for Mac devices for development. 🔄 Open Source &#38; Customizable Android SDK is free. Developers can customize UI and functionalities more freely. 💡 Fast Innovation Frequent updates from Google. Access to emerging technologies like AI, ARCore, and Wear OS. 2. Essential Skills for Android Developers To start building Android apps, you need both technical and problem-solving skills: 🔧 Programming Languages: Kotlin (official language) – Recommended by Google for Android. Java – Still widely used and supported. Optional: C++, Dart (Flutter) for cross-platform. 🧠 Core Concepts: Object-Oriented Programming (OOP) XML for UI layout Android Lifecycle RESTful APIs &#38; JSON UI/UX Design Principles ⚙️ Development Tools: Android Studio Firebase Git &#38; GitHub Gradle (build automation) 3. Android App Development Tools 📦 Android Studio Official IDE by Google with: Code editor &#38; emulator Debugging tools App testing environment 🔥 Firebase (by Google) Real-time database Authentication (Google, Facebook, Email) Push notifications Analytics 🎨 Figma / Adobe XD For wireframing and UI/UX prototyping 🧪 Testing Tools Espresso (UI testing) JUnit (unit testing) Firebase Test Lab 4. Understanding the Android Architecture Knowing how Android apps work behind the scenes is critical. Android Architecture Components: Activities &#38; Fragments – Manage UI screens ViewModel – Retains UI data during config changes LiveData – Observes data changes Room Database – Local SQLite storage Repositories – Handle data operations (API, local DB) Navigation Component – Manages app flow 🧠 MVVM Pattern: Helps separate UI (View) from business logic (ViewModel), improving scalability. 5. Steps to Build an Android App Let’s walk through the actual development process: 1. Plan Your App Define the problem Identify the target audience List core features Sketch a wireframe 2. Set Up Android Studio Install SDK tools Create a new project using Kotlin 3. Design the UI Use XML or Jetpack Compose (recommended) Implement responsive layouts for different devices 4. Implement Features Use ViewModel for data management Use Retrofit or Volley for API calls Store data using Room DB 5. Test the App Use emulators or real Android devices Perform unit, UI, and integration tests 6. Publish on Google Play Store Create developer account Prepare app icons, descriptions, screenshots Generate signed APK/AAB file Submit for review 6. Android UI/UX Design Best Practices An Android app isn’t just about features—design matters. 🧑‍🎨 Guidelines: Follow Material Design principles Ensure consistency in colors and fonts Use native components (buttons, sliders, etc.) Prioritize touch-friendly layouts ✨ Tips: Keep UI clean and uncluttered Use animations wisely (MotionLayout, Lottie) Ensure fast loading and offline availability 7. Testing and Debugging Testing ensures your app runs smoothly across devices. Types of Tests: Unit Testing – JUnit for business logic UI Testing – Espresso for user interface End-to-End Testing – Firebase Test Lab Debugging Tools: Logcat Breakpoints Android Profiler (memory, CPU, network) Tip: Always test on different screen sizes and Android versions. 8. Android App Monetization Strategies Want to earn revenue from your app? Here are top strategies: 💰 1. In-App Ads Integrate AdMob or Facebook Audience Network 💳 2. In-App Purchases (IAP) Sell premium content, features, or virtual goods 🔐 3. Freemium Model Offer a free version with optional paid upgrades 💼 4. Subscription Model Recurring income for premium services (e.g., Spotify, Netflix) 🛒 5. E-commerce Integration Sell physical or digital products through the app 9. Cross-Platform vs Native Development Not sure whether to go Android-only or cross-platform? Aspect Native Android Cross-Platform (Flutter/React Native) Performance Best Good UI Customization Full control Limited customization Development Time Longer Faster Cost Higher Lower Maintenance Separate codebases One codebase for both platforms Verdict: Go native if performance is your priority. Choose Flutter or React Native for faster MVPs. 10. Publishing Your App to Google Play Store 📤 Steps: Sign up for Google Play Developer account ($25 one-time fee) Prepare your app bundle (AAB format) Add store listing info: App name, description, screenshots Category, tags, contact info Upload assets (logo, banner) Set pricing and distribution Submit and wait for approval (usually within 7 days) Tip: Use Play Console analytics to track installs, crashes, and user behavior. 11. Best Android Libraries &#38; Frameworks (2025) Speed up development with pre-built libraries: 🧩 UI/UX: Glide / Coil (image loading) Lottie (animations) Material Components 📡 Networking: Retrofit (API requests) OkHttp (HTTP client) Gson/Moshi (JSON parsing) 🔐 Security: Biometric API EncryptedSharedPreferences 🔧 Architecture: Hilt / Dagger (dependency injection) Coroutines / Flow (asynchronous code) Jetpack Compose (modern UI toolkit) 12. Career Opportunities in Android Development 👨‍💻 Job Roles: Android Developer Mobile App Engineer Full Stack Mobile Developer Flutter Developer (cross-platform) 🏢 Industries Hiring: E-commerce Healthcare EdTech FinTech Travel 💼 Freelancing: Platforms: Upwork, Toptal, Fiverr Ideal for remote developers and small projects Expected Salary (India, 2025): ₹5L–₹18L+ per annum depending on skill level Conclusion (150–200 words) Android app development is one of the most rewarding and in-demand skills of the digital age. Whether you&#8217;re building apps for your business or developing software for clients, the opportunities are endless. With tools like Android Studio, languages like Kotlin, and platforms like Firebase, it’s easier than ever to build powerful, scalable, and modern apps. Remember: Start with the right tools and structure. Focus on performance, UI/UX, and clean code. Test your app rigorously</p>
<p>The post <a href="https://www.tagvibe.com/android-app-development-a-complete-guide-for-2025/">Android App Development A Complete Guide for 2025</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="gtfy-3 gtfy-4" data-start="236" data-end="510">Android app development has transformed how we interact with technology. With more than <strong data-start="324" data-end="370">3 billion active Android devices worldwide</strong>, building an Android app is no longer a luxury—it&#8217;s a necessity for businesses, entrepreneurs, and developers aiming for a global audience.</p>
<p data-start="512" data-end="822">In 2025, Android continues to lead the mobile OS market due to its open-source nature, wide device range, and the power of the Google Play ecosystem. Whether you’re a beginner looking to create your first app or a business owner exploring app-based growth, understanding Android development is your first step.</p>
<p data-start="824" data-end="994">This comprehensive guide covers everything you need to know about Android app development—from tools, languages, and frameworks to monetization and publishing strategies.</p>
<hr data-start="996" data-end="999" />
<h2 data-start="1001" data-end="1046"><strong data-start="1004" data-end="1046">1. Why Choose Android App Development?</strong></h2>
<h3 data-start="1048" data-end="1067"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4f1.png" alt="📱" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Global Reach</h3>
<ul data-start="1068" data-end="1176">
<li data-start="1068" data-end="1116">
<p data-start="1070" data-end="1116">Android powers <strong data-start="1085" data-end="1115">70%+ of global smartphones</strong>.</p>
</li>
<li data-start="1117" data-end="1176">
<p data-start="1119" data-end="1176">Available in over 190 countries and thousands of devices.</p>
</li>
</ul>
<h3 data-start="1178" data-end="1199"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4b0.png" alt="💰" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Cost-Effective</h3>
<ul data-start="1200" data-end="1282">
<li data-start="1200" data-end="1239">
<p data-start="1202" data-end="1239">Lower entry barriers compared to iOS.</p>
</li>
<li data-start="1240" data-end="1282">
<p data-start="1242" data-end="1282">No need for Mac devices for development.</p>
</li>
</ul>
<h3 data-start="1284" data-end="1317"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f504.png" alt="🔄" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Open Source &amp; Customizable</h3>
<ul data-start="1318" data-end="1403">
<li data-start="1318" data-end="1340">
<p data-start="1320" data-end="1340">Android SDK is free.</p>
</li>
<li data-start="1341" data-end="1403">
<p data-start="1343" data-end="1403">Developers can customize UI and functionalities more freely.</p>
</li>
</ul>
<h3 data-start="1405" data-end="1427"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Fast Innovation</h3>
<ul data-start="1428" data-end="1523">
<li data-start="1428" data-end="1459">
<p data-start="1430" data-end="1459">Frequent updates from Google.</p>
</li>
<li data-start="1460" data-end="1523">
<p data-start="1462" data-end="1523">Access to emerging technologies like AI, ARCore, and Wear OS.</p>
</li>
</ul>
<hr data-start="1525" data-end="1528" />
<h2 data-start="1530" data-end="1579"><strong data-start="1533" data-end="1579">2. Essential Skills for Android Developers</strong></h2>
<p data-start="1581" data-end="1672">To start building Android apps, you need both <strong data-start="1627" data-end="1640">technical</strong> and <strong data-start="1645" data-end="1664">problem-solving</strong> skills:</p>
<h3 data-start="1674" data-end="1703"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f527.png" alt="🔧" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Programming Languages:</h3>
<ul data-start="1704" data-end="1881">
<li data-start="1704" data-end="1775">
<p data-start="1706" data-end="1775"><strong data-start="1706" data-end="1716">Kotlin</strong> <em data-start="1717" data-end="1738">(official language)</em> – Recommended by Google for Android.</p>
</li>
<li data-start="1776" data-end="1821">
<p data-start="1778" data-end="1821"><strong data-start="1778" data-end="1786">Java</strong> – Still widely used and supported.</p>
</li>
<li data-start="1822" data-end="1881">
<p data-start="1824" data-end="1881">Optional: <strong data-start="1834" data-end="1841">C++</strong>, <strong data-start="1843" data-end="1861">Dart (Flutter)</strong> for cross-platform.</p>
</li>
</ul>
<h3 data-start="1883" data-end="1904"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f9e0.png" alt="🧠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Core Concepts:</h3>
<ul data-start="1905" data-end="2028">
<li data-start="1905" data-end="1940">
<p data-start="1907" data-end="1940">Object-Oriented Programming (OOP)</p>
</li>
<li data-start="1941" data-end="1960">
<p data-start="1943" data-end="1960">XML for UI layout</p>
</li>
<li data-start="1961" data-end="1980">
<p data-start="1963" data-end="1980">Android Lifecycle</p>
</li>
<li data-start="1981" data-end="2002">
<p data-start="1983" data-end="2002">RESTful APIs &amp; JSON</p>
</li>
<li data-start="2003" data-end="2028">
<p data-start="2005" data-end="2028">UI/UX Design Principles</p>
</li>
</ul>
<h3 data-start="2030" data-end="2055"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/2699.png" alt="⚙" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Development Tools:</h3>
<ul data-start="2056" data-end="2126">
<li data-start="2056" data-end="2072">
<p data-start="2058" data-end="2072">Android Studio</p>
</li>
<li data-start="2073" data-end="2083">
<p data-start="2075" data-end="2083">Firebase</p>
</li>
<li data-start="2084" data-end="2098">
<p data-start="2086" data-end="2098">Git &amp; GitHub</p>
</li>
<li data-start="2099" data-end="2126">
<p data-start="2101" data-end="2126">Gradle (build automation)</p>
</li>
</ul>
<hr data-start="2128" data-end="2131" />
<h2 data-start="2133" data-end="2172"><strong data-start="2136" data-end="2172">3. Android App Development Tools</strong></h2>
<h3 data-start="2174" data-end="2195"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4e6.png" alt="📦" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Android Studio</h3>
<p data-start="2196" data-end="2224">Official IDE by Google with:</p>
<ul data-start="2225" data-end="2293">
<li data-start="2225" data-end="2249">
<p data-start="2227" data-end="2249">Code editor &amp; emulator</p>
</li>
<li data-start="2250" data-end="2267">
<p data-start="2252" data-end="2267">Debugging tools</p>
</li>
<li data-start="2268" data-end="2293">
<p data-start="2270" data-end="2293">App testing environment</p>
</li>
</ul>
<h3 data-start="2295" data-end="2322"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f525.png" alt="🔥" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Firebase (by Google)</h3>
<ul data-start="2323" data-end="2419">
<li data-start="2323" data-end="2343">
<p data-start="2325" data-end="2343">Real-time database</p>
</li>
<li data-start="2344" data-end="2386">
<p data-start="2346" data-end="2386">Authentication (Google, Facebook, Email)</p>
</li>
<li data-start="2387" data-end="2407">
<p data-start="2389" data-end="2407">Push notifications</p>
</li>
<li data-start="2408" data-end="2419">
<p data-start="2410" data-end="2419">Analytics</p>
</li>
</ul>
<h3 data-start="2421" data-end="2444"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f3a8.png" alt="🎨" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Figma / Adobe XD</h3>
<ul data-start="2445" data-end="2484">
<li data-start="2445" data-end="2484">
<p data-start="2447" data-end="2484">For wireframing and UI/UX prototyping</p>
</li>
</ul>
<h3 data-start="2486" data-end="2506"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f9ea.png" alt="🧪" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Testing Tools</h3>
<ul data-start="2507" data-end="2573">
<li data-start="2507" data-end="2530">
<p data-start="2509" data-end="2530">Espresso (UI testing)</p>
</li>
<li data-start="2531" data-end="2553">
<p data-start="2533" data-end="2553">JUnit (unit testing)</p>
</li>
<li data-start="2554" data-end="2573">
<p data-start="2556" data-end="2573">Firebase Test Lab</p>
</li>
</ul>
<hr data-start="2575" data-end="2578" />
<h2 data-start="2580" data-end="2628"><strong data-start="2583" data-end="2628">4. Understanding the Android Architecture</strong></h2>
<p data-start="2630" data-end="2690">Knowing how Android apps work behind the scenes is critical.</p>
<h3 data-start="2692" data-end="2728">Android Architecture Components:</h3>
<ol data-start="2729" data-end="3027">
<li data-start="2729" data-end="2778">
<p data-start="2732" data-end="2778"><strong data-start="2732" data-end="2758">Activities &amp; Fragments</strong> – Manage UI screens</p>
</li>
<li data-start="2779" data-end="2835">
<p data-start="2782" data-end="2835"><strong data-start="2782" data-end="2795">ViewModel</strong> – Retains UI data during config changes</p>
</li>
<li data-start="2836" data-end="2875">
<p data-start="2839" data-end="2875"><strong data-start="2839" data-end="2851">LiveData</strong> – Observes data changes</p>
</li>
<li data-start="2876" data-end="2919">
<p data-start="2879" data-end="2919"><strong data-start="2879" data-end="2896">Room Database</strong> – Local SQLite storage</p>
</li>
<li data-start="2920" data-end="2980">
<p data-start="2923" data-end="2980"><strong data-start="2923" data-end="2939">Repositories</strong> – Handle data operations (API, local DB)</p>
</li>
<li data-start="2981" data-end="3027">
<p data-start="2984" data-end="3027"><strong data-start="2984" data-end="3008">Navigation Component</strong> – Manages app flow</p>
</li>
</ol>
<h3 data-start="3029" data-end="3049"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f9e0.png" alt="🧠" class="wp-smiley" style="height: 1em; max-height: 1em;" /> MVVM Pattern:</h3>
<p data-start="3050" data-end="3130">Helps separate UI (View) from business logic (ViewModel), improving scalability.</p>
<hr data-start="3132" data-end="3135" />
<h2 data-start="3137" data-end="3176"><strong data-start="3140" data-end="3176">5. Steps to Build an Android App</strong></h2>
<p data-start="3178" data-end="3228">Let’s walk through the actual development process:</p>
<h3 data-start="3230" data-end="3254">1. <strong data-start="3237" data-end="3254">Plan Your App</strong></h3>
<ul data-start="3255" data-end="3348">
<li data-start="3255" data-end="3275">
<p data-start="3257" data-end="3275">Define the problem</p>
</li>
<li data-start="3276" data-end="3306">
<p data-start="3278" data-end="3306">Identify the target audience</p>
</li>
<li data-start="3307" data-end="3327">
<p data-start="3309" data-end="3327">List core features</p>
</li>
<li data-start="3328" data-end="3348">
<p data-start="3330" data-end="3348">Sketch a wireframe</p>
</li>
</ul>
<h3 data-start="3350" data-end="3382">2. <strong data-start="3357" data-end="3382">Set Up Android Studio</strong></h3>
<ul data-start="3383" data-end="3438">
<li data-start="3383" data-end="3402">
<p data-start="3385" data-end="3402">Install SDK tools</p>
</li>
<li data-start="3403" data-end="3438">
<p data-start="3405" data-end="3438">Create a new project using Kotlin</p>
</li>
</ul>
<h3 data-start="3440" data-end="3464">3. <strong data-start="3447" data-end="3464">Design the UI</strong></h3>
<ul data-start="3465" data-end="3560">
<li data-start="3465" data-end="3507">
<p data-start="3467" data-end="3507">Use XML or Jetpack Compose (recommended)</p>
</li>
<li data-start="3508" data-end="3560">
<p data-start="3510" data-end="3560">Implement responsive layouts for different devices</p>
</li>
</ul>
<h3 data-start="3562" data-end="3591">4. <strong data-start="3569" data-end="3591">Implement Features</strong></h3>
<ul data-start="3592" data-end="3693">
<li data-start="3592" data-end="3627">
<p data-start="3594" data-end="3627">Use ViewModel for data management</p>
</li>
<li data-start="3628" data-end="3666">
<p data-start="3630" data-end="3666">Use Retrofit or Volley for API calls</p>
</li>
<li data-start="3667" data-end="3693">
<p data-start="3669" data-end="3693">Store data using Room DB</p>
</li>
</ul>
<h3 data-start="3695" data-end="3718">5. <strong data-start="3702" data-end="3718">Test the App</strong></h3>
<ul data-start="3719" data-end="3800">
<li data-start="3719" data-end="3758">
<p data-start="3721" data-end="3758">Use emulators or real Android devices</p>
</li>
<li data-start="3759" data-end="3800">
<p data-start="3761" data-end="3800">Perform unit, UI, and integration tests</p>
</li>
</ul>
<h3 data-start="3802" data-end="3841">6. <strong data-start="3809" data-end="3841">Publish on Google Play Store</strong></h3>
<ul data-start="3842" data-end="3966">
<li data-start="3842" data-end="3868">
<p data-start="3844" data-end="3868">Create developer account</p>
</li>
<li data-start="3869" data-end="3915">
<p data-start="3871" data-end="3915">Prepare app icons, descriptions, screenshots</p>
</li>
<li data-start="3916" data-end="3946">
<p data-start="3918" data-end="3946">Generate signed APK/AAB file</p>
</li>
<li data-start="3947" data-end="3966">
<p data-start="3949" data-end="3966">Submit for review</p>
</li>
</ul>
<hr data-start="3968" data-end="3971" />
<h2 data-start="3973" data-end="4018"><strong data-start="3976" data-end="4018">6. Android UI/UX Design Best Practices</strong></h2>
<p data-start="4020" data-end="4080">An Android app isn’t just about features—<strong data-start="4061" data-end="4079">design matters</strong>.</p>
<h3 data-start="4082" data-end="4103"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f9d1-200d-1f3a8.png" alt="🧑‍🎨" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Guidelines:</h3>
<ul data-start="4104" data-end="4269">
<li data-start="4104" data-end="4143">
<p data-start="4106" data-end="4143">Follow <strong data-start="4113" data-end="4132">Material Design</strong> principles</p>
</li>
<li data-start="4144" data-end="4184">
<p data-start="4146" data-end="4184">Ensure consistency in colors and fonts</p>
</li>
<li data-start="4185" data-end="4233">
<p data-start="4187" data-end="4233">Use native components (buttons, sliders, etc.)</p>
</li>
<li data-start="4234" data-end="4269">
<p data-start="4236" data-end="4269">Prioritize touch-friendly layouts</p>
</li>
</ul>
<h3 data-start="4271" data-end="4282"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/2728.png" alt="✨" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Tips:</h3>
<ul data-start="4283" data-end="4408">
<li data-start="4283" data-end="4314">
<p data-start="4285" data-end="4314">Keep UI clean and uncluttered</p>
</li>
<li data-start="4315" data-end="4361">
<p data-start="4317" data-end="4361">Use animations wisely (MotionLayout, Lottie)</p>
</li>
<li data-start="4362" data-end="4408">
<p data-start="4364" data-end="4408">Ensure fast loading and offline availability</p>
</li>
</ul>
<hr data-start="4410" data-end="4413" />
<h2 data-start="4415" data-end="4446"><strong data-start="4418" data-end="4446">7. Testing and Debugging</strong></h2>
<p data-start="4448" data-end="4502">Testing ensures your app runs smoothly across devices.</p>
<h3 data-start="4504" data-end="4523">Types of Tests:</h3>
<ul data-start="4524" data-end="4661">
<li data-start="4524" data-end="4569">
<p data-start="4526" data-end="4569"><strong data-start="4526" data-end="4542">Unit Testing</strong> – JUnit for business logic</p>
</li>
<li data-start="4570" data-end="4616">
<p data-start="4572" data-end="4616"><strong data-start="4572" data-end="4586">UI Testing</strong> – Espresso for user interface</p>
</li>
<li data-start="4617" data-end="4661">
<p data-start="4619" data-end="4661"><strong data-start="4619" data-end="4641">End-to-End Testing</strong> – Firebase Test Lab</p>
</li>
</ul>
<h3 data-start="4663" data-end="4683">Debugging Tools:</h3>
<ul data-start="4684" data-end="4748">
<li data-start="4684" data-end="4692">
<p data-start="4686" data-end="4692">Logcat</p>
</li>
<li data-start="4693" data-end="4706">
<p data-start="4695" data-end="4706">Breakpoints</p>
</li>
<li data-start="4707" data-end="4748">
<p data-start="4709" data-end="4748">Android Profiler (memory, CPU, network)</p>
</li>
</ul>
<p data-start="4750" data-end="4818"><strong data-start="4750" data-end="4758">Tip:</strong> Always test on different screen sizes and Android versions.</p>
<hr data-start="4820" data-end="4823" />
<h2 data-start="4825" data-end="4870"><strong data-start="4828" data-end="4870">8. Android App Monetization Strategies</strong></h2>
<p data-start="4872" data-end="4932">Want to earn revenue from your app? Here are top strategies:</p>
<h3 data-start="4934" data-end="4954"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4b0.png" alt="💰" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 1. In-App Ads</h3>
<ul data-start="4955" data-end="5001">
<li data-start="4955" data-end="5001">
<p data-start="4957" data-end="5001">Integrate AdMob or Facebook Audience Network</p>
</li>
</ul>
<h3 data-start="5003" data-end="5035"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4b3.png" alt="💳" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 2. In-App Purchases (IAP)</h3>
<ul data-start="5036" data-end="5086">
<li data-start="5036" data-end="5086">
<p data-start="5038" data-end="5086">Sell premium content, features, or virtual goods</p>
</li>
</ul>
<h3 data-start="5088" data-end="5112"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f510.png" alt="🔐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 3. Freemium Model</h3>
<ul data-start="5113" data-end="5163">
<li data-start="5113" data-end="5163">
<p data-start="5115" data-end="5163">Offer a free version with optional paid upgrades</p>
</li>
</ul>
<h3 data-start="5165" data-end="5193"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4bc.png" alt="💼" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 4. Subscription Model</h3>
<ul data-start="5194" data-end="5258">
<li data-start="5194" data-end="5258">
<p data-start="5196" data-end="5258">Recurring income for premium services (e.g., Spotify, Netflix)</p>
</li>
</ul>
<h3 data-start="5260" data-end="5292"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f6d2.png" alt="🛒" class="wp-smiley" style="height: 1em; max-height: 1em;" /> 5. E-commerce Integration</h3>
<ul data-start="5293" data-end="5344">
<li data-start="5293" data-end="5344">
<p data-start="5295" data-end="5344">Sell physical or digital products through the app</p>
</li>
</ul>
<hr data-start="5346" data-end="5349" />
<h2 data-start="5351" data-end="5397"><strong data-start="5354" data-end="5397">9. Cross-Platform vs Native Development</strong></h2>
<p data-start="5399" data-end="5453">Not sure whether to go Android-only or cross-platform?</p>
<div class="_tableContainer_16hzy_1">
<div class="_tableWrapper_16hzy_14 group flex w-fit flex-col-reverse" tabindex="-1">
<table class="w-fit min-w-(--thread-content-width)" data-start="5455" data-end="6048">
<thead data-start="5455" data-end="5538">
<tr data-start="5455" data-end="5538">
<th data-start="5455" data-end="5475" data-col-size="sm">Aspect</th>
<th data-start="5475" data-end="5497" data-col-size="sm">Native Android</th>
<th data-start="5497" data-end="5538" data-col-size="sm">Cross-Platform (Flutter/React Native)</th>
</tr>
</thead>
<tbody data-start="5624" data-end="6048">
<tr data-start="5624" data-end="5708">
<td data-start="5624" data-end="5644" data-col-size="sm">Performance</td>
<td data-col-size="sm" data-start="5644" data-end="5666">Best</td>
<td data-col-size="sm" data-start="5666" data-end="5708">Good</td>
</tr>
<tr data-start="5709" data-end="5793">
<td data-start="5709" data-end="5729" data-col-size="sm">UI Customization</td>
<td data-col-size="sm" data-start="5729" data-end="5751">Full control</td>
<td data-col-size="sm" data-start="5751" data-end="5793">Limited customization</td>
</tr>
<tr data-start="5794" data-end="5878">
<td data-start="5794" data-end="5814" data-col-size="sm">Development Time</td>
<td data-col-size="sm" data-start="5814" data-end="5836">Longer</td>
<td data-col-size="sm" data-start="5836" data-end="5878">Faster</td>
</tr>
<tr data-start="5879" data-end="5963">
<td data-start="5879" data-end="5899" data-col-size="sm">Cost</td>
<td data-start="5899" data-end="5921" data-col-size="sm">Higher</td>
<td data-col-size="sm" data-start="5921" data-end="5963">Lower</td>
</tr>
<tr data-start="5964" data-end="6048">
<td data-start="5964" data-end="5984" data-col-size="sm">Maintenance</td>
<td data-col-size="sm" data-start="5984" data-end="6006">Separate codebases</td>
<td data-col-size="sm" data-start="6006" data-end="6048">One codebase for both platforms</td>
</tr>
</tbody>
</table>
<div class="sticky end-(--thread-content-margin) h-0 self-end select-none">
<div class="absolute end-0 flex items-end"></div>
</div>
</div>
</div>
<p data-start="6050" data-end="6153"><strong data-start="6050" data-end="6062">Verdict:</strong> Go native if performance is your priority. Choose Flutter or React Native for faster MVPs.</p>
<hr data-start="6155" data-end="6158" />
<h2 data-start="6160" data-end="6211"><strong data-start="6163" data-end="6211">10. Publishing Your App to Google Play Store</strong></h2>
<h3 data-start="6213" data-end="6226"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4e4.png" alt="📤" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Steps:</h3>
<ol data-start="6227" data-end="6551">
<li data-start="6227" data-end="6290">
<p data-start="6230" data-end="6290">Sign up for Google Play Developer account ($25 one-time fee)</p>
</li>
<li data-start="6291" data-end="6330">
<p data-start="6294" data-end="6330">Prepare your app bundle (AAB format)</p>
</li>
<li data-start="6331" data-end="6431">
<p data-start="6334" data-end="6357">Add store listing info:</p>
<ul data-start="6361" data-end="6431">
<li data-start="6361" data-end="6397">
<p data-start="6363" data-end="6397">App name, description, screenshots</p>
</li>
<li data-start="6401" data-end="6431">
<p data-start="6403" data-end="6431">Category, tags, contact info</p>
</li>
</ul>
</li>
<li data-start="6432" data-end="6463">
<p data-start="6435" data-end="6463">Upload assets (logo, banner)</p>
</li>
<li data-start="6464" data-end="6495">
<p data-start="6467" data-end="6495">Set pricing and distribution</p>
</li>
<li data-start="6496" data-end="6551">
<p data-start="6499" data-end="6551">Submit and wait for approval (usually within 7 days)</p>
</li>
</ol>
<p data-start="6553" data-end="6635"><strong data-start="6553" data-end="6561">Tip:</strong> Use Play Console analytics to track installs, crashes, and user behavior.</p>
<hr data-start="6637" data-end="6640" />
<h2 data-start="6642" data-end="6695"><strong data-start="6645" data-end="6695">11. Best Android Libraries &amp; Frameworks (2025)</strong></h2>
<p data-start="6697" data-end="6743">Speed up development with pre-built libraries:</p>
<h3 data-start="6745" data-end="6758"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f9e9.png" alt="🧩" class="wp-smiley" style="height: 1em; max-height: 1em;" /> UI/UX:</h3>
<ul data-start="6759" data-end="6833">
<li data-start="6759" data-end="6789">
<p data-start="6761" data-end="6789">Glide / Coil (image loading)</p>
</li>
<li data-start="6790" data-end="6811">
<p data-start="6792" data-end="6811">Lottie (animations)</p>
</li>
<li data-start="6812" data-end="6833">
<p data-start="6814" data-end="6833">Material Components</p>
</li>
</ul>
<h3 data-start="6835" data-end="6853"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4e1.png" alt="📡" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Networking:</h3>
<ul data-start="6854" data-end="6930">
<li data-start="6854" data-end="6879">
<p data-start="6856" data-end="6879">Retrofit (API requests)</p>
</li>
<li data-start="6880" data-end="6902">
<p data-start="6882" data-end="6902">OkHttp (HTTP client)</p>
</li>
<li data-start="6903" data-end="6930">
<p data-start="6905" data-end="6930">Gson/Moshi (JSON parsing)</p>
</li>
</ul>
<h3 data-start="6932" data-end="6948"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f510.png" alt="🔐" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Security:</h3>
<ul data-start="6949" data-end="6993">
<li data-start="6949" data-end="6964">
<p data-start="6951" data-end="6964">Biometric API</p>
</li>
<li data-start="6965" data-end="6993">
<p data-start="6967" data-end="6993">EncryptedSharedPreferences</p>
</li>
</ul>
<h3 data-start="6995" data-end="7015"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f527.png" alt="🔧" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Architecture:</h3>
<ul data-start="7016" data-end="7132">
<li data-start="7016" data-end="7054">
<p data-start="7018" data-end="7054">Hilt / Dagger (dependency injection)</p>
</li>
<li data-start="7055" data-end="7094">
<p data-start="7057" data-end="7094">Coroutines / Flow (asynchronous code)</p>
</li>
<li data-start="7095" data-end="7132">
<p data-start="7097" data-end="7132">Jetpack Compose (modern UI toolkit)</p>
</li>
</ul>
<hr data-start="7134" data-end="7137" />
<h2 data-start="7139" data-end="7193"><strong data-start="7142" data-end="7193">12. Career Opportunities in Android Development</strong></h2>
<h3 data-start="7195" data-end="7215"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f468-200d-1f4bb.png" alt="👨‍💻" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Job Roles:</h3>
<ul data-start="7216" data-end="7324">
<li data-start="7216" data-end="7235">
<p data-start="7218" data-end="7235">Android Developer</p>
</li>
<li data-start="7236" data-end="7257">
<p data-start="7238" data-end="7257">Mobile App Engineer</p>
</li>
<li data-start="7258" data-end="7287">
<p data-start="7260" data-end="7287">Full Stack Mobile Developer</p>
</li>
<li data-start="7288" data-end="7324">
<p data-start="7290" data-end="7324">Flutter Developer (cross-platform)</p>
</li>
</ul>
<h3 data-start="7326" data-end="7351"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f3e2.png" alt="🏢" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Industries Hiring:</h3>
<ul data-start="7352" data-end="7405">
<li data-start="7352" data-end="7364">
<p data-start="7354" data-end="7364">E-commerce</p>
</li>
<li data-start="7365" data-end="7377">
<p data-start="7367" data-end="7377">Healthcare</p>
</li>
<li data-start="7378" data-end="7386">
<p data-start="7380" data-end="7386">EdTech</p>
</li>
<li data-start="7387" data-end="7396">
<p data-start="7389" data-end="7396">FinTech</p>
</li>
<li data-start="7397" data-end="7405">
<p data-start="7399" data-end="7405">Travel</p>
</li>
</ul>
<h3 data-start="7407" data-end="7426"><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4bc.png" alt="💼" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Freelancing:</h3>
<ul data-start="7427" data-end="7511">
<li data-start="7427" data-end="7462">
<p data-start="7429" data-end="7462">Platforms: Upwork, Toptal, Fiverr</p>
</li>
<li data-start="7463" data-end="7511">
<p data-start="7465" data-end="7511">Ideal for remote developers and small projects</p>
</li>
</ul>
<p data-start="7513" data-end="7592"><strong data-start="7513" data-end="7547">Expected Salary (India, 2025):</strong> ₹5L–₹18L+ per annum depending on skill level</p>
<hr data-start="7594" data-end="7597" />
<h2 data-start="7599" data-end="7632"><strong data-start="7602" data-end="7632">Conclusion (150–200 words)</strong></h2>
<p data-start="7634" data-end="7841">Android app development is one of the most rewarding and in-demand skills of the digital age. Whether you&#8217;re building apps for your business or developing software for clients, the opportunities are endless.</p>
<p data-start="7843" data-end="8006">With tools like <strong data-start="7859" data-end="7877">Android Studio</strong>, languages like <strong data-start="7894" data-end="7904">Kotlin</strong>, and platforms like <strong data-start="7925" data-end="7937">Firebase</strong>, it’s easier than ever to build powerful, scalable, and modern apps.</p>
<p data-start="8008" data-end="8017">Remember:</p>
<ul data-start="8018" data-end="8257">
<li data-start="8018" data-end="8061">
<p data-start="8020" data-end="8061">Start with the right tools and structure.</p>
</li>
<li data-start="8062" data-end="8108">
<p data-start="8064" data-end="8108">Focus on performance, UI/UX, and clean code.</p>
</li>
<li data-start="8109" data-end="8150">
<p data-start="8111" data-end="8150">Test your app rigorously before launch.</p>
</li>
<li data-start="8151" data-end="8196">
<p data-start="8153" data-end="8196">Use Google Play to reach millions of users.</p>
</li>
<li data-start="8197" data-end="8257">
<p data-start="8199" data-end="8257">Keep learning with the latest Android and Jetpack updates.</p>
</li>
</ul>
<p data-start="8259" data-end="8423">In 2025 and beyond, Android will continue to dominate the mobile space. Equip yourself with the right skills, stay updated, and create apps that make a real impact.</p><p>The post <a href="https://www.tagvibe.com/android-app-development-a-complete-guide-for-2025/">Android App Development A Complete Guide for 2025</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Set Up a WordPress Child Theme Like a Pro</title>
		<link>https://www.tagvibe.com/how-to-set-up-a-wordpress-child-theme-like-a-pro/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 26 Jun 2025 00:28:53 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<guid isPermaLink="false">https://www.tagvibe.com/?p=1766</guid>

					<description><![CDATA[<p>Creating a child theme in WordPress is one of the smartest things you can do as a site owner or developer. Whether you&#8217;re customizing the look of your site, adding new functionality, or experimenting with CSS, a child theme lets you do all that without touching the original theme files. In this detailed, 2000-word tutorial, we’ll show you how to set up a WordPress child theme like a pro. By the end, you’ll understand what a child theme is, why you need one, and how to build and activate one properly. What Is a Child Theme in WordPress? A child theme is a WordPress theme that inherits the functionality, features, and style of another theme, called the parent theme. It allows you to make changes and customizations without modifying the original theme’s files. Benefits of Using a Child Theme: Safe updates to the parent theme Easy rollback of customizations Cleaner, modular code Better practice for development When Should You Use a Child Theme? You should use a child theme if: You plan to make custom CSS or PHP edits You&#8217;re adding new templates or modifying existing ones You want to future-proof your site against theme updates If you&#8217;re only making minor visual changes using the Customizer or a plugin, you may not need a child theme. Step 1: Choose a Parent Theme Before you build a child theme, you need a parent theme installed. This could be: A popular theme like Astra, GeneratePress, or Kadence A theme from the WordPress repository A premium theme from marketplaces like ThemeForest Make sure the parent theme: Is regularly updated Follows WordPress coding standards Has clear documentation For this example, we’ll use the Twenty Twenty-Four theme. Step 2: Create a Child Theme Folder Navigate to your WordPress installation directory:  </p>
<p>The post <a href="https://www.tagvibe.com/how-to-set-up-a-wordpress-child-theme-like-a-pro/">How to Set Up a WordPress Child Theme Like a Pro</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<div data-elementor-type="wp-post" data-elementor-id="1766" class="elementor elementor-1766 gtfy-5 gtfy-6">
				<div class="elementor-element elementor-element-7228cd50 e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no e-con e-parent" data-id="7228cd50" data-element_type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-6aec572e elementor-widget elementor-widget-text-editor" data-id="6aec572e" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p data-pm-slice="1 1 []">Creating a child theme in WordPress is one of the smartest things you can do as a site owner or developer. Whether you&#8217;re customizing the look of your site, adding new functionality, or experimenting with CSS, a child theme lets you do all that without touching the original theme files.</p><p>In this detailed, 2000-word tutorial, we’ll show you <strong>how to set up a WordPress child theme like a pro</strong>. By the end, you’ll understand what a child theme is, why you need one, and how to build and activate one properly.</p><div><hr /></div><h2><strong>What Is a Child Theme in WordPress?</strong></h2><p>A child theme is a WordPress theme that inherits the functionality, features, and style of another theme, called the <strong>parent theme</strong>. It allows you to make changes and customizations without modifying the original theme’s files.</p><h3><strong>Benefits of Using a Child Theme:</strong></h3><ul data-spread="false"><li>Safe updates to the parent theme</li><li>Easy rollback of customizations</li><li>Cleaner, modular code</li><li>Better practice for development</li></ul><div><hr /></div><h2><strong>When Should You Use a Child Theme?</strong></h2><p>You should use a child theme if:</p><ul data-spread="false"><li>You plan to make custom CSS or PHP edits</li><li>You&#8217;re adding new templates or modifying existing ones</li><li>You want to future-proof your site against theme updates</li></ul><p>If you&#8217;re only making minor visual changes using the Customizer or a plugin, you may not need a child theme.</p><div><hr /></div><h2><strong>Step 1: Choose a Parent Theme</strong></h2><p>Before you build a child theme, you need a parent theme installed. This could be:</p><ul data-spread="false"><li>A popular theme like Astra, GeneratePress, or Kadence</li><li>A theme from the WordPress repository</li><li>A premium theme from marketplaces like ThemeForest</li></ul><p>Make sure the parent theme:</p><ul data-spread="false"><li>Is regularly updated</li><li>Follows WordPress coding standards</li><li>Has clear documentation</li></ul><p>For this example, we’ll use the <strong>Twenty Twenty-Four</strong> theme.</p><div><hr /></div><h2><strong>Step 2: Create a Child Theme Folder</strong></h2>								</div>
				</div>
					</div>
				</div>
		<div class="elementor-element elementor-element-8bb7a38 e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no e-con e-parent" data-id="8bb7a38" data-element_type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-7d11c11 elementor-widget elementor-widget-text-editor" data-id="7d11c11" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p data-pm-slice="1 1 []">Navigate to your WordPress installation directory:</p><p> </p>								</div>
				</div>
					</div>
				</div>
				</div><p>The post <a href="https://www.tagvibe.com/how-to-set-up-a-wordpress-child-theme-like-a-pro/">How to Set Up a WordPress Child Theme Like a Pro</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to customize pagebuilder</title>
		<link>https://www.tagvibe.com/how-to-customize-pagebuilder/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 24 Mar 2023 19:07:40 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<category><![CDATA[magento2]]></category>
		<category><![CDATA[pagebuilder]]></category>
		<guid isPermaLink="false">https://tagvibe.com/?p=339</guid>

					<description><![CDATA[<p>Magento 2 provides a powerful Page Builder feature that allows you to customize your website pages without any coding knowledge. Here are the steps to customize the Page Builder in Magento 2: Here are some more tips on how to customize the Page Builder in Magento 2: Here is an example of how you can customize the Page Builder in Magento 2: Let&#8217;s say you want to create a custom homepage for your online store. You want to include a banner, a featured products section, and a newsletter signup form. Here are the steps to achieve this using the Page Builder:</p>
<p>The post <a href="https://www.tagvibe.com/how-to-customize-pagebuilder/">How to customize pagebuilder</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<!--vcv no format--><!-- vcwb/dynamicElementComment:ff3b53d9 --><div class="vce-row-container gtfy-27 gtfy-28" data-vce-boxed-width="true"><div class="vce-row vce-row--col-gap-30 vce-row-equal-height vce-row-content--top" id="el-ff3b53d9" data-vce-do-apply="all el-ff3b53d9"><div class="vce-row-content" data-vce-element-content="true"><!-- vcwb/dynamicElementComment:c695123a --><div class="vce-col vce-col--md-auto vce-col--xs-1 vce-col--xs-last vce-col--xs-first vce-col--sm-last vce-col--sm-first vce-col--md-last vce-col--lg-last vce-col--xl-last vce-col--md-first vce-col--lg-first vce-col--xl-first" id="el-c695123a"><div class="vce-col-inner" data-vce-do-apply="border margin background  el-c695123a"><div class="vce-col-content" data-vce-element-content="true" data-vce-do-apply="padding el-c695123a"><!-- vcwb/dynamicElementComment:c9e4752c --><div class="vce-text-block"><div class="vce-text-block-wrapper vce" id="el-c9e4752c" data-vce-do-apply="all el-c9e4752c">
<p class="gtfy-29">Magento 2 provides a powerful Page Builder feature that allows you to customize your website pages without any coding knowledge. Here are the steps to customize the Page Builder in Magento 2:</p>



<ol class="wp-block-list gtfy-41">
<li class="gtfy-32 gutenify-list-item">Log in to your Magento 2 admin panel.</li>



<li class="gtfy-33 gutenify-list-item">Go to the Content tab and click on Pages.</li>



<li class="gtfy-34 gutenify-list-item">Click on the Edit button of the page you want to customize.</li>



<li class="gtfy-35 gutenify-list-item">Click on the Edit Page button to start customizing the page with Page Builder.</li>



<li class="gtfy-36 gutenify-list-item">To add new elements to the page, click on the Add Content button.</li>



<li class="gtfy-37 gutenify-list-item">Select the element you want to add and drag it to the desired location on the page.</li>



<li class="gtfy-38 gutenify-list-item">To configure the settings of each element, click on the element and choose the Edit option.</li>



<li class="gtfy-39 gutenify-list-item">You can customize the element’s properties, such as background color, font size, and more, using the options available in the panel.</li>



<li class="gtfy-40 gutenify-list-item">Once you are done with the changes, click on the Save button to save the changes.</li>
</ol>



<p class="gtfy-44">Here are some more tips on how to customize the Page Builder in Magento 2:</p>



<ol class="wp-block-list gtfy-53">
<li class="gtfy-47 gutenify-list-item">Create a custom block: You can create custom blocks with custom content and use them on different pages. To create a custom block, go to the Content tab and click on Blocks. Then click on the Add New Block button and enter the block information. After that, add the block to your page using the Page Builder.</li>



<li class="gtfy-48 gutenify-list-item">Use the Page Builder&#8217;s advanced options: The Page Builder has many advanced options that allow you to customize your pages even further. For example, you can add animations, create custom page layouts, and set up responsive designs for mobile devices.</li>



<li class="gtfy-49 gutenify-list-item">Customize the page layout: With the Page Builder, you can customize the page layout by adding columns and rows. To add a new column, click on the Add Column button in the Page Builder panel. Then, drag the elements to the column to create your desired layout.</li>



<li class="gtfy-50 gutenify-list-item">Preview your changes: Before publishing your changes, you can preview them to ensure that everything looks the way you want it to. Click on the Preview button in the Page Builder panel to preview your changes.</li>



<li class="gtfy-51 gutenify-list-item">Use templates: Magento 2 offers pre-designed templates that you can use to create your pages. To use a template, click on the Templates button in the Page Builder panel, choose a template, and then customize it to your liking.</li>



<li class="gtfy-52 gutenify-list-item">Use widgets: Magento 2 offers a range of widgets that you can use on your pages, such as images, videos, and social media links. To add a widget, click on the Add Content button and select the Widget option. Choose the widget you want to add and customize its settings.</li>
</ol>



<p class="gtfy-56">Here is an example of how you can customize the Page Builder in Magento 2:</p>



<p class="gtfy-59">Let&#8217;s say you want to create a custom homepage for your online store. You want to include a banner, a featured products section, and a newsletter signup form. Here are the steps to achieve this using the Page Builder:</p>



<ol class="wp-block-list gtfy-77">
<li class="gtfy-62 gutenify-list-item">Log in to your Magento 2 admin panel and go to the Content tab.</li>



<li class="gtfy-63 gutenify-list-item">Click on Pages and select the Homepage to edit.</li>



<li class="gtfy-64 gutenify-list-item">Click on the Edit button to edit the page with Page Builder.</li>



<li class="gtfy-65 gutenify-list-item">Click on the Add Content button and select the Banner option.</li>



<li class="gtfy-66 gutenify-list-item">Drag and drop the banner element onto the page and customize it by adding your desired image and text.</li>



<li class="gtfy-67 gutenify-list-item">Add a new row to the page by clicking on the Add Row button in the Page Builder panel.</li>



<li class="gtfy-68 gutenify-list-item">In the new row, add three columns by clicking on the Add Column button and selecting the 1/3 layout option.</li>



<li class="gtfy-69 gutenify-list-item">In the first column, add a Featured Products element by clicking on the Add Content button and selecting the Featured Products option.</li>



<li class="gtfy-70 gutenify-list-item">Customize the Featured Products element by selecting the products you want to feature and choosing their display options.</li>



<li class="gtfy-71 gutenify-list-item">In the second column, add a Newsletter Signup element by clicking on the Add Content button and selecting the Newsletter Signup option.</li>



<li class="gtfy-72 gutenify-list-item">Customize the Newsletter Signup element by adding your desired text and selecting the form fields you want to include.</li>



<li class="gtfy-73 gutenify-list-item">In the third column, add a Custom HTML element by clicking on the Add Content button and selecting the Custom HTML option.</li>



<li class="gtfy-74 gutenify-list-item">Customize the Custom HTML element by adding your desired HTML code for additional content or design.</li>



<li class="gtfy-75 gutenify-list-item">Preview the page to ensure everything looks the way you want it to.</li>



<li class="gtfy-76 gutenify-list-item">Once you are satisfied with the changes, click on the Save button to save the changes.</li>
</ol>
</div></div><!-- /vcwb/dynamicElementComment:c9e4752c --></div></div></div><!-- /vcwb/dynamicElementComment:c695123a --></div></div></div><!-- /vcwb/dynamicElementComment:ff3b53d9 --><!--vcv no format--><p>The post <a href="https://www.tagvibe.com/how-to-customize-pagebuilder/">How to customize pagebuilder</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How routes work in Adobe Commerce</title>
		<link>https://www.tagvibe.com/how-routes-work-in-adobe-commerce/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 17 Mar 2023 21:02:50 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<guid isPermaLink="false">https://tagvibe.com/?p=331</guid>

					<description><![CDATA[<p>In Magento 2, routes are used to define how a specific URL or path is handled by the system. When a user requests a specific URL, the system uses routes to determine which controller, action, and parameters should be executed to process the request. Here is a brief overview of how routes work in Magento 2: Let&#8217;s say we have a custom module called &#8220;MyModule&#8221; that provides a custom &#8220;Contact Us&#8221; form. To handle requests for this form, we need to define a new route in the module&#8217;s routes.xml file. First, we&#8217;ll define the route in the routes.xml file: In this example, we&#8217;re defining a new route with the ID &#8220;mymodule&#8221; and the frontName &#8220;mymodule&#8221;. This means that any URL that starts with &#8220;/mymodule/&#8221; will be handled by the module. Next, we&#8217;ll define the controller that will handle the request: In this example, we&#8217;re creating a new controller class called &#8220;ContactUs&#8221; in the &#8220;Index&#8221; namespace of the &#8220;MyModule&#8221; module. This controller extends the base Magento\Framework\App\Action\Action class and has an execute() method that will be executed when the route is requested. Finally, we&#8217;ll map the route to the controller and action: In this example, we&#8217;re mapping the &#8220;contactus&#8221; action to the &#8220;Index\ContactUs&#8221; controller. This means that when a user visits the URL &#8220;/mymodule/contactus&#8221;, the execute() method in the ContactUs controller will be executed. Check the below related topic:</p>
<p>The post <a href="https://www.tagvibe.com/how-routes-work-in-adobe-commerce/">How routes work in Adobe Commerce</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="gtfy-118">In Magento 2, routes are used to define how a specific URL or path is handled by the system. When a user requests a specific URL, the system uses routes to determine which controller, action, and parameters should be executed to process the request.</p>



<p class="gtfy-121">Here is a brief overview of how routes work in Magento 2:</p>



<ol class="wp-block-list gtfy-136">
<li class="gtfy-124 gutenify-list-item">Routes are defined in the <code>routes.xml</code> file located in the module&#8217;s <code>etc</code> directory. This file specifies the URL paths that should be associated with a specific controller and action.</li>



<li class="gtfy-125 gutenify-list-item">Each route has a unique name, which is defined in the <code>id</code> attribute of the <code>router</code> element in the <code>routes.xml</code> file.</li>



<li class="gtfy-126 gutenify-list-item">The <code>router</code> element in the <code>routes.xml</code> file defines the frontName, which is the first part of the URL path that is associated with the module. For example, if the frontName is &#8220;blog&#8221;, then URLs that start with &#8220;/blog/&#8221; will be handled by the module.</li>



<li class="gtfy-127 gutenify-list-item">The <code>controller</code> element in the <code>routes.xml</code> file defines the controller class that will handle the request for the specific route.</li>



<li class="gtfy-128 gutenify-list-item">The <code>action</code> element in the <code>routes.xml</code> file specifies the method in the controller class that will be executed to process the request.</li>



<li class="gtfy-129 gutenify-list-item">Additional parameters can be passed through the URL or query string, which are then passed to the controller action method for further processing.</li>



<li class="gtfy-130 gutenify-list-item">Magento 2 uses the Front Controller pattern, which means that all requests go through the <code>index.php</code> file in the root directory of the Magento installation. The <code>index.php</code> file is responsible for initializing the Magento application and routing the request to the appropriate controller.</li>



<li class="gtfy-131 gutenify-list-item">Magento 2 routes are defined in the <code>routes.xml</code> file in each module&#8217;s <code>etc</code> directory. The <code>routes.xml</code> file specifies the frontName (the part of the URL that comes after the domain name) and the module that will handle the request.</li>



<li class="gtfy-132 gutenify-list-item">Each route can have multiple actions, and each action is mapped to a controller and action method. The action name is the part of the URL that comes after the frontName. For example, in the route &#8220;mymodule/contactus&#8221;, &#8220;contactus&#8221; is the action name.</li>



<li class="gtfy-133 gutenify-list-item">Magento 2 provides several predefined routers, including the standard router (<code>Magento\Framework\App\Router\Base</code>), the admin router (<code>Magento\Backend\App\Router</code>), and the REST router (<code>Magento\Webapi\Controller\Rest\Router</code>). Each router is responsible for matching the request to the appropriate module and controller based on the URL.</li>



<li class="gtfy-134 gutenify-list-item">You can create custom routers in Magento 2 by implementing the <code>Magento\Framework\App\RouterInterface</code> interface and defining the router in the <code>di.xml</code> file of your module. Custom routers can be used to handle requests for specific URLs or to modify the request before it is passed to the controller.</li>



<li class="gtfy-135 gutenify-list-item">Magento 2 also provides several helper classes for working with URLs, including the <code>Magento\Framework\UrlInterface</code> and <code>Magento\Framework\UrlFactory</code> classes. These classes can be used to generate URLs for specific routes or to modify existing URLs.</li>
</ol>



<p class="gtfy-139">Let&#8217;s say we have a custom module called &#8220;MyModule&#8221; that provides a custom &#8220;Contact Us&#8221; form. To handle requests for this form, we need to define a new route in the module&#8217;s <code>routes.xml</code> file.</p>



<p class="gtfy-142">First, we&#8217;ll define the route in the <code>routes.xml</code> file:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers gtfy-145" style="font-size:.875rem;--cbp-line-number-color:#F8F8F2;--cbp-line-number-width:7.6979217529296875px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:App/etc/routes.xsd&quot;&gt;
    &lt;router id=&quot;standard&quot;&gt;
        &lt;route id=&quot;mymodule&quot; frontName=&quot;mymodule&quot;&gt;
            &lt;module name=&quot;MyModule&quot; /&gt;
        &lt;/route&gt;
    &lt;/router&gt;
&lt;/config&gt;" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36"><code><span class="line"><span style="color: #F8F8F2">&lt;?</span><span style="color: #FF79C6">xml</span><span style="color: #50FA7B; font-style: italic"> version</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">1.0</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2">?&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;</span><span style="color: #FF79C6">config</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">xmlns</span><span style="color: #FF79C6; font-style: italic">:</span><span style="color: #50FA7B; font-style: italic">xsi</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">http://www.w3.org/2001/XMLSchema-instance</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">xsi</span><span style="color: #FF79C6; font-style: italic">:</span><span style="color: #50FA7B; font-style: italic">noNamespaceSchemaLocation</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">urn:magento:framework:App/etc/routes.xsd</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;</span><span style="color: #FF79C6">router</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">id</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">standard</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">        &lt;</span><span style="color: #FF79C6">route</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">id</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">mymodule</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">frontName</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">mymodule</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">            &lt;</span><span style="color: #FF79C6">module</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">name</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">MyModule</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> /&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">        &lt;/</span><span style="color: #FF79C6">route</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;/</span><span style="color: #FF79C6">router</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;/</span><span style="color: #FF79C6">config</span><span style="color: #F8F8F2">&gt;</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#282a36;color:#efefe1;font-size:12px;line-height:1;position:relative">XML</span></div>



<p class="gtfy-148">In this example, we&#8217;re defining a new route with the ID &#8220;mymodule&#8221; and the frontName &#8220;mymodule&#8221;. This means that any URL that starts with &#8220;/mymodule/&#8221; will be handled by the module.</p>



<p class="gtfy-151">Next, we&#8217;ll define the controller that will handle the request:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers gtfy-154" style="font-size:.875rem;--cbp-line-number-color:#F8F8F2;--cbp-line-number-width:7.6979169845581055px;--cbp-line-highlight-color:rgba(253, 253, 237, 0.2);line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="namespace MyModule\Controller\Index;

class ContactUs extends \Magento\Framework\App\Action\Action
{
    public function execute()
    {
        // code to handle the request
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36"><code><span class="line"><span style="color: #FF79C6">namespace</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD; font-style: italic">MyModule</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Controller</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Index</span><span style="color: #F8F8F2">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FF79C6">class</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD">ContactUs</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">extends</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Magento</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Framework</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">App</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Action</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Action</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FF79C6">public</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">function</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B">execute</span><span style="color: #F8F8F2">()</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// code to handle the request</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-start;background-color:#282a36;color:#efefe1;font-size:12px;line-height:1;position:relative">PHP</span></div>



<p class="gtfy-157">In this example, we&#8217;re creating a new controller class called &#8220;ContactUs&#8221; in the &#8220;Index&#8221; namespace of the &#8220;MyModule&#8221; module. This controller extends the base <code>Magento\Framework\App\Action\Action</code> class and has an <code>execute()</code> method that will be executed when the route is requested.</p>



<p class="gtfy-160">Finally, we&#8217;ll map the route to the controller and action:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers gtfy-163" style="font-size:.875rem;--cbp-line-number-color:#F8F8F2;--cbp-line-number-width:15.395835876464844px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;router id=&quot;standard&quot;&gt;
    &lt;route id=&quot;mymodule&quot; frontName=&quot;mymodule&quot;&gt;
        &lt;module name=&quot;MyModule&quot; /&gt;
        &lt;action name=&quot;contactus&quot; path=&quot;contactus&quot; &gt;
            &lt;controller&gt;Index\ContactUs&lt;/controller&gt;
            &lt;title&gt;Contact Us&lt;/title&gt;
            &lt;resource&gt;MyModule::contactus&lt;/resource&gt;
            &lt;acl&gt;MyModule::contactus&lt;/acl&gt;
        &lt;/action&gt;
    &lt;/route&gt;
&lt;/router&gt;" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36"><code><span class="line"><span style="color: #F8F8F2">&lt;</span><span style="color: #FF79C6">router</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">id</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">standard</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;</span><span style="color: #FF79C6">route</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">id</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">mymodule</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">frontName</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">mymodule</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">        &lt;</span><span style="color: #FF79C6">module</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">name</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">MyModule</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> /&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">        &lt;</span><span style="color: #FF79C6">action</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">name</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">contactus</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">path</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">contactus</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> &gt;</span></span>
<span class="line"><span style="color: #F8F8F2">            &lt;</span><span style="color: #FF79C6">controller</span><span style="color: #F8F8F2">&gt;Index\ContactUs&lt;/</span><span style="color: #FF79C6">controller</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">            &lt;</span><span style="color: #FF79C6">title</span><span style="color: #F8F8F2">&gt;Contact Us&lt;/</span><span style="color: #FF79C6">title</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">            &lt;</span><span style="color: #FF79C6">resource</span><span style="color: #F8F8F2">&gt;MyModule::contactus&lt;/</span><span style="color: #FF79C6">resource</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">            &lt;</span><span style="color: #FF79C6">acl</span><span style="color: #F8F8F2">&gt;MyModule::contactus&lt;/</span><span style="color: #FF79C6">acl</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">        &lt;/</span><span style="color: #FF79C6">action</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">    &lt;/</span><span style="color: #FF79C6">route</span><span style="color: #F8F8F2">&gt;</span></span>
<span class="line"><span style="color: #F8F8F2">&lt;/</span><span style="color: #FF79C6">router</span><span style="color: #F8F8F2">&gt;</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#282a36;color:#efefe1;font-size:12px;line-height:1;position:relative">XML</span></div>



<p class="gtfy-166">In this example, we&#8217;re mapping the &#8220;contactus&#8221; action to the &#8220;Index\ContactUs&#8221; controller. This means that when a user visits the URL &#8220;/mymodule/contactus&#8221;, the <code>execute()</code> method in the <code>ContactUs</code> controller will be executed.</p>



<p class="gtfy-169">Check the below related topic:</p>



<ul class="wp-block-list gtfy-173">
<li class="gtfy-172 gutenify-list-item"><a href="https://tagvibe.com/custom-router-with-a-front-controller-in-magento-2/">Front controller and custom Routing</a></li>
</ul><p>The post <a href="https://www.tagvibe.com/how-routes-work-in-adobe-commerce/">How routes work in Adobe Commerce</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Custom router with a front controller in Magento 2:</title>
		<link>https://www.tagvibe.com/custom-router-with-a-front-controller-in-magento-2/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 17 Mar 2023 20:58:09 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<guid isPermaLink="false">https://tagvibe.com/?p=332</guid>

					<description><![CDATA[<p>Front controller architecture in Magento 2 and its flow: overview of the front controller architecture in Magento 2 and its flow: In summary, the front controller architecture in Magento 2 is designed to provide a flexible and modular system for handling requests and generating HTML output. It uses routing, controllers, models, views, blocks, and templates to process and render data, and relies on dependency injection and the layout file to manage the flow of information. Step-by-step guide on how to create a custom router with a front controller in Magento 2: In this example, we&#8217;re defining a new preference for the RouterInterface that points to a custom router class called Vendor\Module\Controller\Router. In this example, we&#8217;re defining a new router class that extends the Base router. We&#8217;re also injecting an ActionFactory object, which we&#8217;ll use to create a new controller instance. For example: In this example, we&#8217;re checking if the request URL starts with the string &#8220;customroute&#8221;. If it does, we&#8217;re setting the module, controller, and action values and passing an additional parameter called identifier. We&#8217;re also returning an instance of the Forward action, which will forward the request to the appropriate controller. In this example, we&#8217;re defining a new controller class that extends the Action class. We&#8217;re also injecting a PageFactory object, which we&#8217;ll use to create a new result page.</p>
<p>The post <a href="https://www.tagvibe.com/custom-router-with-a-front-controller-in-magento-2/">Custom router with a front controller in Magento 2:</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<h2 class="wp-block-heading gtfy-221">Front controller architecture in Magento 2 and its flow:</h2>



<p class="gtfy-224">overview of the front controller architecture in Magento 2 and its flow:</p>



<ol class="wp-block-list gtfy-238">
<li class="gtfy-227 gutenify-list-item">Request Routing: When a user sends a request to a Magento 2 website, the request is first passed through the web server and reaches the Magento 2 application. The request is then routed to the appropriate controller based on the requested URL and the Magento 2 routing configuration.</li>



<li class="gtfy-228 gutenify-list-item">Front Controller: The front controller is a single point of entry for all requests in Magento 2. It handles the incoming requests and dispatches them to the appropriate controllers. The front controller is located at <code>Magento\Framework\App\FrontControllerInterface</code>.</li>



<li class="gtfy-229 gutenify-list-item">Routing: The front controller checks the request URL against the routing configuration defined in the <code>routes.xml</code> file of the module. If there is a match, the front controller passes the request to the corresponding controller.</li>



<li class="gtfy-230 gutenify-list-item">Controllers: Magento 2 controllers are responsible for handling specific requests from users. They contain methods that process and output the data for a specific request. Magento 2 controllers are located in the <code>Controller</code> directory of each module.</li>



<li class="gtfy-231 gutenify-list-item">Dependency Injection: Controllers and other classes in Magento 2 use dependency injection to access the objects they need to function. Dependency injection allows Magento 2 to be flexible and modular, and helps with testing and maintaining code.</li>



<li class="gtfy-232 gutenify-list-item">Models: Models in Magento 2 are responsible for managing data and business logic. They interact with the database, process data, and perform calculations. Magento 2 models are located in the <code>Model</code> directory of each module.</li>



<li class="gtfy-233 gutenify-list-item">Views: Views in Magento 2 are responsible for rendering HTML output. They take data from the controllers and models, and generate HTML markup that is sent back to the user&#8217;s browser. Magento 2 views are located in the <code>view</code> directory of each module.</li>



<li class="gtfy-234 gutenify-list-item">Layout: The layout file is responsible for defining the structure of the HTML output. It contains instructions on how to render the various components of a page, including the header, footer, and main content area. Layout files in Magento 2 are located in the <code>view/frontend</code> or <code>view/adminhtml</code> directory of each module.</li>



<li class="gtfy-235 gutenify-list-item">Blocks: Blocks in Magento 2 are PHP classes that contain business logic and are responsible for generating HTML output. They can be used to define reusable components that can be used across multiple pages. Magento 2 blocks are located in the <code>Block</code> directory of each module.</li>



<li class="gtfy-236 gutenify-list-item">Templates: Templates in Magento 2 are responsible for defining the HTML markup that will be used to generate the final output. They are typically used in combination with blocks, and are located in the <code>view/frontend/templates</code> or <code>view/adminhtml/templates</code> directory of each module.</li>



<li class="gtfy-237 gutenify-list-item">Response: The final HTML output generated by the views is sent back to the user&#8217;s browser as a response. The response may also contain cookies, headers, and other metadata.</li>
</ol>



<p class="gtfy-241">In summary, the front controller architecture in Magento 2 is designed to provide a flexible and modular system for handling requests and generating HTML output. It uses routing, controllers, models, views, blocks, and templates to process and render data, and relies on dependency injection and the layout file to manage the flow of information.</p>



<p class="gtfy-244">Step-by-step guide on how to create a custom router with a front controller in Magento 2:</p>



<ol class="wp-block-list gtfy-250">
<li class="gtfy-247 gutenify-list-item">Create a new module or navigate to an existing module you want to add the custom router to. In this example, let&#8217;s say the module is called <code>Vendor_Module</code>.</li>



<li class="gtfy-248 gutenify-list-item">In the module&#8217;s <code>etc</code> directory, create a new file called <code>di.xml</code>. The file path will be something like <code>app/code/Vendor/Module/etc/di.xml</code>.</li>



<li class="gtfy-249 gutenify-list-item">In <code>di.xml</code>, define a new preference for the <code>Magento\Framework\App\RouterInterface</code> interface. For example:</li>
</ol>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers gtfy-253" style="font-size:.875rem;--cbp-line-number-color:#F8F8F2;--cbp-line-number-width:7.69793701171875px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;preference for=&quot;Magento\Framework\App\RouterInterface&quot; type=&quot;Vendor\Module\Controller\Router&quot; /&gt;" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36"><code><span class="line"><span style="color: #F8F8F2">&lt;</span><span style="color: #FF79C6">preference</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">for</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">Magento\Framework\App\RouterInterface</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B; font-style: italic">type</span><span style="color: #F8F8F2">=</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">Vendor\Module\Controller\Router</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2"> /&gt;</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#282a36;color:#efefe1;font-size:12px;line-height:1;position:relative">XML</span></div>



<p class="gtfy-256">In this example, we&#8217;re defining a new preference for the <code>RouterInterface</code> that points to a custom router class called <code>Vendor\Module\Controller\Router</code>.</p>



<ol class="wp-block-list gtfy-261" start="4">
<li class="gtfy-259 gutenify-list-item">Create a new file called <code>Router.php</code> in the module&#8217;s <code>Controller</code> directory. The file path will be something like <code>app/code/Vendor/Module/Controller/Router.php</code>.</li>



<li class="gtfy-260 gutenify-list-item">In <code>Router.php</code>, define the custom router class and extend the <code>Magento\Framework\App\Router\Base</code> class:</li>
</ol>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers gtfy-264" style="font-size:.875rem;--cbp-line-number-color:#F8F8F2;--cbp-line-number-width:15.395833015441895px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;?php
namespace Vendor\Module\Controller;

use Magento\Framework\App\ActionFactory;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Router\Base;

class Router extends Base
{
    protected $actionFactory;

    public function __construct(ActionFactory $actionFactory)
    {
        $this-&gt;actionFactory = $actionFactory;
    }

    public function match(RequestInterface $request)
    {
        // Implement custom routing logic here
        // Return false if the router doesn't match the request
        // Otherwise, return an array with the following keys:
        // - module
        // - controller
        // - action
        // - parameters
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36"><code><span class="line"><span style="color: #FF79C6">&lt;?</span><span style="color: #BD93F9">php</span></span>
<span class="line"><span style="color: #FF79C6">namespace</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD; font-style: italic">Vendor</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Module</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Controller</span><span style="color: #F8F8F2">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FF79C6">use</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD; font-style: italic">Magento</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Framework</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">App</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">ActionFactory</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #FF79C6">use</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD; font-style: italic">Magento</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Framework</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">App</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">RequestInterface</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #FF79C6">use</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD; font-style: italic">Magento</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Framework</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">App</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Router</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Base</span><span style="color: #F8F8F2">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FF79C6">class</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD">Router</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">extends</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD; font-style: italic">Base</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FF79C6">protected</span><span style="color: #F8F8F2"> $actionFactory;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FF79C6">public</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">function</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD">__construct</span><span style="color: #F8F8F2">(</span><span style="color: #8BE9FD; font-style: italic">ActionFactory</span><span style="color: #F8F8F2"> $actionFactory)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #BD93F9; font-style: italic">$this</span><span style="color: #FF79C6">-&gt;</span><span style="color: #F8F8F2">actionFactory </span><span style="color: #FF79C6">=</span><span style="color: #F8F8F2"> $actionFactory;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FF79C6">public</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">function</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B">match</span><span style="color: #F8F8F2">(</span><span style="color: #8BE9FD; font-style: italic">RequestInterface</span><span style="color: #F8F8F2"> $request)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// Implement custom routing logic here</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// Return false if the router doesn&#39;t match the request</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// Otherwise, return an array with the following keys:</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// - module</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// - controller</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// - action</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// - parameters</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#282a36;color:#efefe1;font-size:12px;line-height:1;position:relative">PHP</span></div>



<p class="gtfy-267">In this example, we&#8217;re defining a new router class that extends the <code>Base</code> router. We&#8217;re also injecting an <code>ActionFactory</code> object, which we&#8217;ll use to create a new controller instance.</p>



<ol class="wp-block-list gtfy-271" start="6">
<li class="gtfy-270 gutenify-list-item">In the <code>match()</code> method of <code>Router.php</code>, implement the custom routing logic. The method should return an array with the following keys:</li>
</ol>



<ul class="wp-block-list gtfy-278">
<li class="gtfy-274 gutenify-list-item"><code>module</code>: The name of the module that will handle the request.</li>



<li class="gtfy-275 gutenify-list-item"><code>controller</code>: The name of the controller class that will handle the request.</li>



<li class="gtfy-276 gutenify-list-item"><code>action</code>: The name of the action method that will handle the request.</li>



<li class="gtfy-277 gutenify-list-item"><code>parameters</code>: An array of additional parameters to pass to the action method.</li>
</ul>



<p class="gtfy-281">For example:</p>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers gtfy-284" style="font-size:.875rem;--cbp-line-number-color:#F8F8F2;--cbp-line-number-width:15.395833015441895px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="public function match(RequestInterface $request)
{
    $identifier = trim($request-&gt;getPathInfo(), '/');
    if (strpos($identifier, 'customroute') === 0) {
        $request-&gt;setModuleName('vendor_module');
        $request-&gt;setControllerName('index');
        $request-&gt;setActionName('custom');
        $request-&gt;setParams(['identifier' =&gt; $identifier]);
        return $this-&gt;actionFactory-&gt;create('Magento\Framework\App\Action\Forward', ['request' =&gt; $request]);
    }
    return false;
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36"><code><span class="line"><span style="color: #FF79C6">public</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">function</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B">match</span><span style="color: #F8F8F2">(</span><span style="color: #8BE9FD; font-style: italic">RequestInterface</span><span style="color: #F8F8F2"> $request)</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    $identifier </span><span style="color: #FF79C6">=</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD">trim</span><span style="color: #F8F8F2">($request</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">getPathInfo</span><span style="color: #F8F8F2">(),</span><span style="color: #50FA7B"> </span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">/</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FF79C6">if</span><span style="color: #F8F8F2"> (</span><span style="color: #8BE9FD">strpos</span><span style="color: #F8F8F2">($identifier,</span><span style="color: #50FA7B"> </span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">customroute</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2">) </span><span style="color: #FF79C6">===</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">0</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2">        $request</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">setModuleName</span><span style="color: #F8F8F2">(</span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">vendor_module</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">        $request</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">setControllerName</span><span style="color: #F8F8F2">(</span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">index</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">        $request</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">setActionName</span><span style="color: #F8F8F2">(</span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">custom</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2">        $request</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">setParams</span><span style="color: #F8F8F2">([</span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">identifier</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">=&gt;</span><span style="color: #F8F8F2"> $identifier]);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FF79C6">return</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9; font-style: italic">$this</span><span style="color: #FF79C6">-&gt;</span><span style="color: #F8F8F2">actionFactory</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">create</span><span style="color: #F8F8F2">(</span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">Magento\Framework\App\Action\Forward</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2">, [</span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">request</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">=&gt;</span><span style="color: #F8F8F2"> $request]);</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FF79C6">return</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">false</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#282a36;color:#efefe1;font-size:12px;line-height:1;position:relative">PHP</span></div>



<p class="gtfy-287">In this example, we&#8217;re checking if the request URL starts with the string &#8220;customroute&#8221;. If it does, we&#8217;re setting the <code>module</code>, <code>controller</code>, and <code>action</code> values and passing an additional parameter called <code>identifier</code>. We&#8217;re also returning an instance of the <code>Forward</code> action, which will forward the request to the appropriate controller.</p>



<ol class="wp-block-list gtfy-292" start="7">
<li class="gtfy-290 gutenify-list-item">Create a new file called <code>Index.php</code> in the module&#8217;s <code>Controller</code> directory. The file path will be something like <code>app/code/Vendor/Module/Controller/Index.php</code>.</li>



<li class="gtfy-291 gutenify-list-item">In <code>Index.php</code>, define the controller class and implement the custom action method:</li>
</ol>



<div class="wp-block-kevinbatdorf-code-block-pro padding-bottom-disabled cbp-has-line-numbers gtfy-295" style="font-size:.875rem;--cbp-line-number-color:#F8F8F2;--cbp-line-number-width:15.395833015441895px;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;?php
namespace Vendor\Module\Controller;

use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;

class Index extends \Magento\Framework\App\Action\Action
{
    protected $resultPageFactory;

    public function __construct(Context $context, PageFactory $resultPageFactory)
    {
        parent::__construct($context);
        $this-&gt;resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        // Get the identifier parameter from the request
        $identifier = $this-&gt;getRequest()-&gt;getParam('identifier');

        // Implement custom action logic here
        // Create a new result page and return it
        $resultPage = $this-&gt;resultPageFactory-&gt;create();
        $resultPage-&gt;getConfig()-&gt;getTitle()-&gt;set(__('Custom Page'));
        return $resultPage;
    }
}" style="color:#F8F8F2;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki dracula" style="background-color: #282A36"><code><span class="line"><span style="color: #FF79C6">&lt;?</span><span style="color: #BD93F9">php</span></span>
<span class="line"><span style="color: #FF79C6">namespace</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD; font-style: italic">Vendor</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Module</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Controller</span><span style="color: #F8F8F2">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FF79C6">use</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD; font-style: italic">Magento</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Framework</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">App</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Action</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Context</span><span style="color: #F8F8F2">;</span></span>
<span class="line"><span style="color: #FF79C6">use</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD; font-style: italic">Magento</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Framework</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">View</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Result</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">PageFactory</span><span style="color: #F8F8F2">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FF79C6">class</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD">Index</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">extends</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Magento</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Framework</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">App</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Action</span><span style="color: #FF79C6; font-style: italic">\</span><span style="color: #8BE9FD; font-style: italic">Action</span></span>
<span class="line"><span style="color: #F8F8F2">{</span></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FF79C6">protected</span><span style="color: #F8F8F2"> $resultPageFactory;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FF79C6">public</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">function</span><span style="color: #F8F8F2"> </span><span style="color: #8BE9FD">__construct</span><span style="color: #F8F8F2">(</span><span style="color: #8BE9FD; font-style: italic">Context</span><span style="color: #F8F8F2"> $context, </span><span style="color: #8BE9FD; font-style: italic">PageFactory</span><span style="color: #F8F8F2"> $resultPageFactory)</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #8BE9FD; font-style: italic">parent</span><span style="color: #FF79C6">::</span><span style="color: #50FA7B">__construct</span><span style="color: #F8F8F2">($context);</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #BD93F9; font-style: italic">$this</span><span style="color: #FF79C6">-&gt;</span><span style="color: #F8F8F2">resultPageFactory </span><span style="color: #FF79C6">=</span><span style="color: #F8F8F2"> $resultPageFactory;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">    </span><span style="color: #FF79C6">public</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">function</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B">execute</span><span style="color: #F8F8F2">()</span></span>
<span class="line"><span style="color: #F8F8F2">    {</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// Get the identifier parameter from the request</span></span>
<span class="line"><span style="color: #F8F8F2">        $identifier </span><span style="color: #FF79C6">=</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9; font-style: italic">$this</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">getRequest</span><span style="color: #F8F8F2">()</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">getParam</span><span style="color: #F8F8F2">(</span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">identifier</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// Implement custom action logic here</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #6272A4">// Create a new result page and return it</span></span>
<span class="line"><span style="color: #F8F8F2">        $resultPage </span><span style="color: #FF79C6">=</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9; font-style: italic">$this</span><span style="color: #FF79C6">-&gt;</span><span style="color: #F8F8F2">resultPageFactory</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">create</span><span style="color: #F8F8F2">();</span></span>
<span class="line"><span style="color: #F8F8F2">        $resultPage</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">getConfig</span><span style="color: #F8F8F2">()</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">getTitle</span><span style="color: #F8F8F2">()</span><span style="color: #FF79C6">-&gt;</span><span style="color: #50FA7B">set</span><span style="color: #F8F8F2">(</span><span style="color: #50FA7B">__</span><span style="color: #F8F8F2">(</span><span style="color: #E9F284">&#39;</span><span style="color: #F1FA8C">Custom Page</span><span style="color: #E9F284">&#39;</span><span style="color: #F8F8F2">));</span></span>
<span class="line"><span style="color: #F8F8F2">        </span><span style="color: #FF79C6">return</span><span style="color: #F8F8F2"> $resultPage;</span></span>
<span class="line"><span style="color: #F8F8F2">    }</span></span>
<span class="line"><span style="color: #F8F8F2">}</span></span></code></pre><span style="display:flex;align-items:flex-end;padding:10px;width:100%;justify-content:flex-end;background-color:#282a36;color:#efefe1;font-size:12px;line-height:1;position:relative">PHP</span></div>



<p class="gtfy-298">In this example, we&#8217;re defining a new controller class that extends the <code>Action</code> class. We&#8217;re also injecting a <code>PageFactory</code> object, which we&#8217;ll use to create a new result page.</p>



<ol class="wp-block-list gtfy-303" start="9">
<li class="gtfy-301 gutenify-list-item">In the <code>execute()</code> method of <code>Index.php</code>, implement the custom action logic. For example, you could use the <code>identifier</code> parameter to load data from a custom table and display it on the page.</li>



<li class="gtfy-302 gutenify-list-item">That&#8217;s it! Now you should be able to access your custom route at the URL <code>http://example.com/customroute/identifier</code>.</li>
</ol><p>The post <a href="https://www.tagvibe.com/custom-router-with-a-front-controller-in-magento-2/">Custom router with a front controller in Magento 2:</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Configuration layer in Magento 2</title>
		<link>https://www.tagvibe.com/configuration-layer-in-magento-2/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 17 Mar 2023 20:00:22 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<category><![CDATA[configuration-service]]></category>
		<category><![CDATA[magento2]]></category>
		<category><![CDATA[system-config]]></category>
		<guid isPermaLink="false">https://tagvibe.com/?p=326</guid>

					<description><![CDATA[<p>In Magento 2, the configuration layer is a critical component of the system that allows developers and store owners to manage various settings for their store. The configuration layer is implemented using the Configuration module, which is part of the Magento\Framework\App namespace. The configuration layer is designed to provide a hierarchical structure for managing different configuration settings. The hierarchy starts at the default level and extends to the store level. This hierarchical structure allows the settings to be inherited from the default level to the store level, making it easy to manage settings for multiple stores. The configuration settings are stored in the database in the core_config_data table. This table contains a row for each configuration setting and stores information such as the configuration path, the value of the configuration, and the scope of the configuration (i.e. website, store view, or default). The Configuration module also provides an API for retrieving and modifying configuration settings. This API can be used by developers to read and modify configuration settings programmatically. The configuration layer is used extensively throughout Magento 2, and it is an integral part of the system architecture. It is used to manage a wide range of settings, including store-specific settings, system-wide settings, and module-specific settings. Overall, the configuration layer in Magento 2 is a critical component of the system architecture, and it provides a flexible and hierarchical structure for managing configuration settings. Here is some more information about the configuration layer in Magento 2: The configuration layer in Magento 2 allows developers to set configuration settings at different levels of scope. The available scopes are &#8220;Default&#8221;, &#8220;Website&#8221;, and &#8220;Store View&#8221;. This means that a configuration setting can be applied to the entire Magento installation (Default scope), to a specific website, or to a specific store view. When a setting is applied at a higher scope, it is inherited by lower scopes. For example, if a configuration setting is set at the website level, all store views under that website will inherit that setting. Each configuration setting in Magento 2 has a unique configuration path. This path is used to identify the setting and to retrieve or modify its value. The configuration path is a combination of a group name, a field name, and (optionally) a website code or a store code. For example, the configuration path for the store name setting is &#8220;general/store_information/name&#8221;. The configuration settings in Magento 2 are organized into different groups based on their functionality. For example, there are groups for General Settings, Catalog Settings, Sales Settings, etc. These groups are defined in XML files located in the etc/adminhtml/system.xml and etc/frontend/system.xml files of each module. Each group contains one or more fields, which are the individual configuration settings. The configuration layer in Magento 2 allows developers to override the default configuration settings by creating custom XML files. These files can be placed in the app/code/[Vendor]/[Module]/etc directory of a custom module, and they can be used to set custom values for specific configuration settings. When Magento 2 loads the configuration settings, it will merge the custom XML files with the default XML files, and apply the custom values for any overridden settings. Overall, the configuration layer in Magento 2 provides a flexible and hierarchical structure for managing configuration settings, and it is an essential component of the system architecture. It allows developers to customize the behavior of the system and provides store owners with the ability to manage their stores efficiently. Example of how to use the configuration layer in Magento 2: Let&#8217;s say you want to change the maximum order amount allowed for your store. By default, Magento 2 sets the maximum order amount to 10,000. To change this setting, follow these steps: Now, let&#8217;s say you want to change the maximum order amount for a specific website. To do this, follow these steps: These changes will now apply to the specific website you selected, and any store views under that website. If you want to apply the same changes to all websites or store views, you can follow the same steps and select the &#8220;Default Config&#8221; scope from the dropdown menu in step 2. Alternatively, you can use the configuration override feature to set a custom value for the &#8220;Maximum Order Total&#8221; setting in a custom module. To do this, you can create an XML file with the following content: This XML file sets the &#8220;Maximum Order Total&#8221; value for the &#8220;ccsave&#8221; payment method to 40,000. You can place this file in the app/code/[Vendor]/[Module]/etc directory of your custom module and enable the module in the Magento 2 admin panel.</p>
<p>The post <a href="https://www.tagvibe.com/configuration-layer-in-magento-2/">Configuration layer in Magento 2</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="gtfy-370">In Magento 2, the configuration layer is a critical component of the system that allows developers and store owners to manage various settings for their store. The configuration layer is implemented using the Configuration module, which is part of the Magento\Framework\App namespace.</p>



<p class="gtfy-373">The configuration layer is designed to provide a hierarchical structure for managing different configuration settings. The hierarchy starts at the default level and extends to the store level. This hierarchical structure allows the settings to be inherited from the default level to the store level, making it easy to manage settings for multiple stores.</p>



<p class="gtfy-376">The configuration settings are stored in the database in the core_config_data table. This table contains a row for each configuration setting and stores information such as the configuration path, the value of the configuration, and the scope of the configuration (i.e. website, store view, or default).</p>



<p class="gtfy-379">The Configuration module also provides an API for retrieving and modifying configuration settings. This API can be used by developers to read and modify configuration settings programmatically.</p>



<p class="gtfy-382">The configuration layer is used extensively throughout Magento 2, and it is an integral part of the system architecture. It is used to manage a wide range of settings, including store-specific settings, system-wide settings, and module-specific settings.</p>



<p class="gtfy-385">Overall, the configuration layer in Magento 2 is a critical component of the system architecture, and it provides a flexible and hierarchical structure for managing configuration settings.</p>



<p class="gtfy-388">Here is some more information about the configuration layer in Magento 2:</p>



<ol class="wp-block-list gtfy-392">
<li class="gtfy-391 gutenify-list-item">Configuration Scope:</li>
</ol>



<p class="gtfy-395">The configuration layer in Magento 2 allows developers to set configuration settings at different levels of scope. The available scopes are &#8220;Default&#8221;, &#8220;Website&#8221;, and &#8220;Store View&#8221;. This means that a configuration setting can be applied to the entire Magento installation (Default scope), to a specific website, or to a specific store view. When a setting is applied at a higher scope, it is inherited by lower scopes. For example, if a configuration setting is set at the website level, all store views under that website will inherit that setting.</p>



<ol class="wp-block-list gtfy-399" start="2">
<li class="gtfy-398 gutenify-list-item">Configuration Path:</li>
</ol>



<p class="gtfy-402">Each configuration setting in Magento 2 has a unique configuration path. This path is used to identify the setting and to retrieve or modify its value. The configuration path is a combination of a group name, a field name, and (optionally) a website code or a store code. For example, the configuration path for the store name setting is &#8220;general/store_information/name&#8221;.</p>



<ol class="wp-block-list gtfy-406" start="3">
<li class="gtfy-405 gutenify-list-item">Configuration Structure:</li>
</ol>



<p class="gtfy-409">The configuration settings in Magento 2 are organized into different groups based on their functionality. For example, there are groups for General Settings, Catalog Settings, Sales Settings, etc. These groups are defined in XML files located in the etc/adminhtml/system.xml and etc/frontend/system.xml files of each module. Each group contains one or more fields, which are the individual configuration settings.</p>



<ol class="wp-block-list gtfy-413" start="4">
<li class="gtfy-412 gutenify-list-item">Configuration Override:</li>
</ol>



<p class="gtfy-416">The configuration layer in Magento 2 allows developers to override the default configuration settings by creating custom XML files. These files can be placed in the app/code/[Vendor]/[Module]/etc directory of a custom module, and they can be used to set custom values for specific configuration settings. When Magento 2 loads the configuration settings, it will merge the custom XML files with the default XML files, and apply the custom values for any overridden settings.</p>



<p class="gtfy-419">Overall, the configuration layer in Magento 2 provides a flexible and hierarchical structure for managing configuration settings, and it is an essential component of the system architecture. It allows developers to customize the behavior of the system and provides store owners with the ability to manage their stores efficiently.</p>



<h1 class="wp-block-heading gtfy-422">Example of how to use the configuration layer in Magento 2:</h1>



<p class="gtfy-425">Let&#8217;s say you want to change the maximum order amount allowed for your store. By default, Magento 2 sets the maximum order amount to 10,000. To change this setting, follow these steps:</p>



<ol class="wp-block-list gtfy-432">
<li class="gtfy-428 gutenify-list-item">Log in to the Magento 2 admin panel and navigate to &#8220;Stores&#8221; &gt; &#8220;Configuration&#8221; &gt; &#8220;Sales&#8221;.</li>



<li class="gtfy-429 gutenify-list-item">Click on the &#8220;Payment Methods&#8221; tab and then click on the &#8220;Credit Card&#8221; section to expand it.</li>



<li class="gtfy-430 gutenify-list-item">Scroll down to the &#8220;Maximum Order Total&#8221; setting and change the value to your desired maximum order amount (e.g. 20,000).</li>



<li class="gtfy-431 gutenify-list-item">Click the &#8220;Save Config&#8221; button to save your changes.</li>
</ol>



<p class="gtfy-435">Now, let&#8217;s say you want to change the maximum order amount for a specific website. To do this, follow these steps:</p>



<ol class="wp-block-list gtfy-442">
<li class="gtfy-438 gutenify-list-item">Log in to the Magento 2 admin panel and navigate to &#8220;Stores&#8221; &gt; &#8220;Configuration&#8221;.</li>



<li class="gtfy-439 gutenify-list-item">From the &#8220;Scope&#8221; dropdown menu, select the website for which you want to change the maximum order amount.</li>



<li class="gtfy-440 gutenify-list-item">Follow the same steps as above to locate the &#8220;Maximum Order Total&#8221; setting under the &#8220;Credit Card&#8221; section, and update the value to your desired maximum order amount (e.g. 30,000).</li>



<li class="gtfy-441 gutenify-list-item">Click the &#8220;Save Config&#8221; button to save your changes.</li>
</ol>



<p class="gtfy-445">These changes will now apply to the specific website you selected, and any store views under that website. If you want to apply the same changes to all websites or store views, you can follow the same steps and select the &#8220;Default Config&#8221; scope from the dropdown menu in step 2.</p>



<p class="gtfy-448">Alternatively, you can use the configuration override feature to set a custom value for the &#8220;Maximum Order Total&#8221; setting in a custom module. To do this, you can create an XML file with the following content:</p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-451" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Store:etc/config.xsd&quot;&gt;
    &lt;default&gt;
        &lt;payment&gt;
            &lt;ccsave&gt;
                &lt;order_total&gt;40000&lt;/order_total&gt;
            &lt;/ccsave&gt;
        &lt;/payment&gt;
    &lt;/default&gt;
&lt;/config&gt;" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">&lt;config</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">xmlns</span><span style="color: #ECEFF4">:</span><span style="color: #8FBCBB">xsi</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">http://www.w3.org/2001/XMLSchema-instance</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">xsi</span><span style="color: #ECEFF4">:</span><span style="color: #8FBCBB">noNamespaceSchemaLocation</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">urn:magento:module:Magento_Store:etc/config.xsd</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">&lt;default&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #81A1C1">&lt;payment&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">            </span><span style="color: #81A1C1">&lt;ccsave&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">                </span><span style="color: #81A1C1">&lt;order_total&gt;</span><span style="color: #D8DEE9FF">40000</span><span style="color: #81A1C1">&lt;/order_total&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">            </span><span style="color: #81A1C1">&lt;/ccsave&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #81A1C1">&lt;/payment&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">&lt;/default&gt;</span></span>
<span class="line"><span style="color: #81A1C1">&lt;/config&gt;</span></span></code></pre></div>



<p class="gtfy-454">This XML file sets the &#8220;Maximum Order Total&#8221; value for the &#8220;ccsave&#8221; payment method to 40,000. You can place this file in the app/code/[Vendor]/[Module]/etc directory of your custom module and enable the module in the Magento 2 admin panel.</p><p>The post <a href="https://www.tagvibe.com/configuration-layer-in-magento-2/">Configuration layer in Magento 2</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Partial caching in magento 2</title>
		<link>https://www.tagvibe.com/partial-caching-in-magento-2/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 16 Mar 2023 19:16:04 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<guid isPermaLink="false">https://tagvibe.com/?p=322</guid>

					<description><![CDATA[<p>Partial caching in Magento 2 is a technique used to improve the performance of the application by caching specific sections of a page that are likely to remain unchanged between requests. This allows the application to serve the cached content instead of generating it from scratch, which can significantly reduce the time it takes to load the page. In Magento 2, partial caching is implemented using a technology called &#8220;block caching.&#8221; Each block in a Magento 2 page can be individually cached, which means that only the blocks that have changed need to be re-rendered for subsequent requests. When a block is rendered for the first time, Magento 2 stores the output in the cache. The next time the block is requested, Magento 2 checks if the cache is still valid by comparing the current state of the system to the state when the cache was created. If the cache is still valid, Magento 2 serves the cached content, which avoids the need to re-render the block. Magento 2 also provides several tools for configuring and managing block caching, including: Here is a step-by-step explanation of how to implement partial caching for the product details block on a Magento 2 product page: Overall, partial caching is an important technique for optimizing the performance of Magento 2, especially for sites with high traffic or complex pages that take a long time to generate. By caching individual blocks, Magento 2 can provide a faster and more responsive experience for users, which can lead to higher conversion rates and improved customer satisfaction.</p>
<p>The post <a href="https://www.tagvibe.com/partial-caching-in-magento-2/">Partial caching in magento 2</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="gtfy-485">Partial caching in Magento 2 is a technique used to improve the performance of the application by caching specific sections of a page that are likely to remain unchanged between requests. This allows the application to serve the cached content instead of generating it from scratch, which can significantly reduce the time it takes to load the page.</p>



<p class="gtfy-488">In Magento 2, partial caching is implemented using a technology called &#8220;block caching.&#8221; Each block in a Magento 2 page can be individually cached, which means that only the blocks that have changed need to be re-rendered for subsequent requests.</p>



<p class="gtfy-491">When a block is rendered for the first time, Magento 2 stores the output in the cache. The next time the block is requested, Magento 2 checks if the cache is still valid by comparing the current state of the system to the state when the cache was created. If the cache is still valid, Magento 2 serves the cached content, which avoids the need to re-render the block.</p>



<p class="gtfy-494">Magento 2 also provides several tools for configuring and managing block caching, including:</p>



<ol class="wp-block-list gtfy-501">
<li class="gtfy-497 gutenify-list-item">Cache lifetime: The amount of time that a block should be cached before it is invalidated and regenerated.</li>



<li class="gtfy-498 gutenify-list-item">Cache tags: A way to group related blocks together so that they can be invalidated at the same time.</li>



<li class="gtfy-500 gutenify-list-item">Cache invalidation: A mechanism for explicitly invalidating specific caches when certain events occur, such as when a product is updated or a customer logs in.
<ul class="wp-block-list gtfy-499"></ul>
</li>
</ol>



<p class="gtfy-504">Here is a step-by-step explanation of how to implement partial caching for the product details block on a Magento 2 product page:</p>



<ul class="wp-block-list gtfy-510">
<li class="gtfy-507 gutenify-list-item">Identify the block containing the product details that you want to cache. In this case, it would be the block that contains the product name, description, and price.</li>



<li class="gtfy-508 gutenify-list-item">Determine the cache lifetime for the block. The cache lifetime is the amount of time that the block should be cached before it is invalidated and regenerated. For example, you may decide to cache the block for 24 hours.</li>



<li class="gtfy-509 gutenify-list-item">Configure Magento 2 to cache the block. You can do this by adding a cacheable=&#8221;true&#8221; attribute to the layout XML file that defines the block. For example:</li>
</ul>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-513" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;block class=&quot;Magento\Catalog\Block\Product\View\Details&quot; name=&quot;product.info.details&quot; template=&quot;Magento_Catalog::product/view/details.phtml&quot; cacheable=&quot;true&quot;&gt;" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">&lt;block</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">class</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Magento\Catalog\Block\Product\View\Details</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">product.info.details</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">template</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Magento_Catalog::product/view/details.phtml</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">cacheable</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">true</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span></code></pre></div>



<ul class="wp-block-list gtfy-519">
<li class="gtfy-516 gutenify-list-item">This tells Magento 2 to cache the block and serve the cached content for subsequent requests within the cache lifetime.</li>



<li class="gtfy-518 gutenify-list-item">Add cache tags to the block. Cache tags are used to group related blocks together so that they can be invalidated at the same time. For example, you may add the &#8220;catalog_product_&#8221; tag to the product details block to group it with other product-related blocks. You can do this by adding a cacheable=&#8221;true&#8221; attribute with the appropriate cache tag to the block definition. For example:
<ul class="wp-block-list gtfy-517"></ul>
</li>
</ul>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-522" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;block class=&quot;Magento\Catalog\Block\Product\View\Details&quot; name=&quot;product.info.details&quot; template=&quot;Magento_Catalog::product/view/details.phtml&quot; cacheable=&quot;true&quot; cache_tags=&quot;catalog_product_&quot;&gt;" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">&lt;block</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">class</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Magento\Catalog\Block\Product\View\Details</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">product.info.details</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">template</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Magento_Catalog::product/view/details.phtml</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">cacheable</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">true</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">cache_tags</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">catalog_product_</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span></code></pre></div>



<ul class="wp-block-list gtfy-527">
<li class="gtfy-526 gutenify-list-item">Invalidate the cache when necessary. If the product details block needs to be updated, such as when the product&#8217;s price changes, you can use cache invalidation to invalidate the cache and regenerate the block. For example, you can use the <code>cache:clean</code> command in the Magento 2 CLI to invalidate the cache for the &#8220;catalog_product_&#8221; tag:
<ul class="wp-block-list gtfy-525"></ul>
</li>
</ul>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-530" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="bin/magento cache:clean catalog_product_" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #D8DEE9FF">bin/magento </span><span style="color: #A3BE8C">cache:clean</span><span style="color: #D8DEE9FF"> </span><span style="color: #A3BE8C">catalog_product_</span></span></code></pre></div>



<p class="gtfy-533">Overall, partial caching is an important technique for optimizing the performance of Magento 2, especially for sites with high traffic or complex pages that take a long time to generate. By caching individual blocks, Magento 2 can provide a faster and more responsive experience for users, which can lead to higher conversion rates and improved customer satisfaction.</p><p>The post <a href="https://www.tagvibe.com/partial-caching-in-magento-2/">Partial caching in magento 2</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to apply observers, preferences, and plugins correctly in Magento 2</title>
		<link>https://www.tagvibe.com/how-to-apply-observers-preferences-and-plugins-correctly-in-magento-2/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 16 Mar 2023 18:49:16 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<guid isPermaLink="false">https://tagvibe.com/?p=319</guid>

					<description><![CDATA[<p>Observers, preferences, and plugins are all powerful tools in Magento 2 that can be used to modify and extend the behavior of the platform. Here&#8217;s a brief overview of each, along with an example of how to use them: Let&#8217;s say you want to modify the behavior of the checkout process when a customer submits their order. You could create an observer that listens for the sales_order_place_after event, which is triggered after an order has been successfully placed. To create this observer, you would define the event in app/code/Vendor/Module/etc/events.xml: Then, you would create a PHP class CustomObserver.php in app/code/Vendor/Module/Observer that implements the Magento\Framework\Event\ObserverInterface interface: In this class, you can write any custom code that you want to execute when the sales_order_place_after event is triggered. Let&#8217;s say you want to modify the behavior of the Magento\Catalog\Model\Product class to add a custom method. You could create a preference that overrides this class with your own custom implementation. To create this preference, you would define the class in app/code/Vendor/Module/etc/di.xml: Then, you would create a new PHP class CustomProduct.php in app/code/Vendor/Module/Model that extends the original Magento\Catalog\Model\Product class: In this class, you can write any custom methods or override any existing methods from the original Magento\Catalog\Model\Product class. Let&#8217;s say you want to modify the behavior of the Magento\Checkout\Block\Cart\Item\Renderer class to add some custom HTML to the product name. You could create a plugin that intercepts the toHtml method in this class and adds your custom HTML. To create this plugin, you would define the class and method in app/code/Vendor/Module/etc/di.xml: Then, you would create a PHP class CustomPlugin.php in app/code/Vendor/Module/Plugin that implements the Magento\Framework\Interception\InterceptorInterface interface: In this class, you can modify the behavior of the toHtml method by wrapping it with your own code using the around plugin method. The first parameter is the original class instance, and the second parameter is a callable function that represents the original method. Inside the around method, you can add your custom code before and after the original method call. Note: The sortOrder attribute in the XML configuration determines the order in which plugins are executed. Lower numbers are executed first. Additionally, the disabled attribute can be set to true to disable the plugin without removing it from the configuration. So, in the CustomPlugin class, you can write any custom code that you want to execute before or after the toHtml method is called on an instance of the Magento\Checkout\Block\Cart\Item\Renderer class. The aroundToHtml method provides the ability to modify the input parameters and/or the return value of the original method. In summary, observers, preferences, and plugins are powerful tools in Magento 2 that can be used to modify and extend the behavior of the platform. Observers allow you to listen for specific events and execute custom code in response, preferences allow you to override the default behavior of Magento classes with your own custom implementation, and plugins allow you to modify the behavior of public methods in Magento classes without modifying the original class code. By using these tools correctly, you can create highly customizable and extensible Magento modules that meet the needs of your clients or business.</p>
<p>The post <a href="https://www.tagvibe.com/how-to-apply-observers-preferences-and-plugins-correctly-in-magento-2/">How to apply observers, preferences, and plugins correctly in Magento 2</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="gtfy-592">Observers, preferences, and plugins are all powerful tools in Magento 2 that can be used to modify and extend the behavior of the platform. Here&#8217;s a brief overview of each, along with an example of how to use them:</p>



<ol class="wp-block-list gtfy-596">
<li class="gtfy-595 gutenify-list-item">Observers: Observers are used to listen for specific events that occur in Magento and execute custom code in response to those events. To create an observer, you need to define an event in Magento&#8217;s XML configuration and then create a PHP class that will listen for that event. Here&#8217;s an example:</li>
</ol>



<p class="gtfy-599">Let&#8217;s say you want to modify the behavior of the checkout process when a customer submits their order. You could create an observer that listens for the <code>sales_order_place_after</code> event, which is triggered after an order has been successfully placed. To create this observer, you would define the event in <code>app/code/Vendor/Module/etc/events.xml</code>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-602" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Event/etc/events.xsd&quot;&gt;
    &lt;event name=&quot;sales_order_place_after&quot;&gt;
        &lt;observer name=&quot;my_custom_observer&quot; instance=&quot;Vendor\Module\Observer\CustomObserver&quot; /&gt;
    &lt;/event&gt;
&lt;/config&gt;" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">&lt;config</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">xmlns</span><span style="color: #ECEFF4">:</span><span style="color: #8FBCBB">xsi</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">http://www.w3.org/2001/XMLSchema-instance</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">xsi</span><span style="color: #ECEFF4">:</span><span style="color: #8FBCBB">noNamespaceSchemaLocation</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">urn:magento:framework:Event/etc/events.xsd</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">&lt;event</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">sales_order_place_after</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #81A1C1">&lt;observer</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">my_custom_observer</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">instance</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Vendor\Module\Observer\CustomObserver</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">/&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">&lt;/event&gt;</span></span>
<span class="line"><span style="color: #81A1C1">&lt;/config&gt;</span></span></code></pre></div>



<p class="gtfy-605">Then, you would create a PHP class <code>CustomObserver.php</code> in <code>app/code/Vendor/Module/Observer</code> that implements the <code>Magento\Framework\Event\ObserverInterface</code> interface:</p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-608" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="namespace Vendor\Module\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class CustomObserver implements ObserverInterface
{
    public function execute(Observer $observer)
    {
        // Your custom code here
    }
}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">namespace</span><span style="color: #D8DEE9FF"> Vendor</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Module</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Observer</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">use</span><span style="color: #D8DEE9FF"> Magento</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Framework</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Event</span><span style="color: #ECEFF4">\</span><span style="color: #8FBCBB">Observer</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #81A1C1">use</span><span style="color: #D8DEE9FF"> Magento</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Framework</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Event</span><span style="color: #ECEFF4">\</span><span style="color: #8FBCBB">ObserverInterface</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">class</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">CustomObserver</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">implements</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB; font-weight: bold">ObserverInterface</span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">public</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">function</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">execute</span><span style="color: #ECEFF4">(</span><span style="color: #8FBCBB">Observer</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">$</span><span style="color: #D8DEE9">observer</span><span style="color: #ECEFF4">)</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #ECEFF4">        </span><span style="color: #616E88">// Your custom code here</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">}</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span></code></pre></div>



<p class="gtfy-611">In this class, you can write any custom code that you want to execute when the <code>sales_order_place_after</code> event is triggered.</p>



<ol class="wp-block-list gtfy-615" start="2">
<li class="gtfy-614 gutenify-list-item">Preferences: Preferences are used to override the default behavior of Magento classes with your own custom implementation. To create a preference, you need to define the class you want to override in Magento&#8217;s XML configuration and then create a new class that extends the original class. Here&#8217;s an example:</li>
</ol>



<p class="gtfy-618">Let&#8217;s say you want to modify the behavior of the <code>Magento\Catalog\Model\Product</code> class to add a custom method. You could create a preference that overrides this class with your own custom implementation. To create this preference, you would define the class in <code>app/code/Vendor/Module/etc/di.xml</code>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-621" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager/etc/config.xsd&quot;&gt;
    &lt;preference for=&quot;Magento\Catalog\Model\Product&quot; type=&quot;Vendor\Module\Model\CustomProduct&quot; /&gt;
&lt;/config&gt;" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">&lt;config</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">xmlns</span><span style="color: #ECEFF4">:</span><span style="color: #8FBCBB">xsi</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">http://www.w3.org/2001/XMLSchema-instance</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">xsi</span><span style="color: #ECEFF4">:</span><span style="color: #8FBCBB">noNamespaceSchemaLocation</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">urn:magento:framework:ObjectManager/etc/config.xsd</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">&lt;preference</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">for</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Magento\Catalog\Model\Product</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">type</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Vendor\Module\Model\CustomProduct</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">/&gt;</span></span>
<span class="line"><span style="color: #81A1C1">&lt;/config&gt;</span></span></code></pre></div>



<p class="gtfy-624">Then, you would create a new PHP class <code>CustomProduct.php</code> in <code>app/code/Vendor/Module/Model</code> that extends the original <code>Magento\Catalog\Model\Product</code> class:</p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-627" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="namespace Vendor\Module\Model;

use Magento\Catalog\Model\Product as MagentoProduct;

class CustomProduct extends MagentoProduct
{
    public function myCustomMethod()
    {
        // Your custom code here
    }
}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">namespace</span><span style="color: #D8DEE9FF"> Vendor</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Module</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Model</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">use</span><span style="color: #D8DEE9FF"> Magento</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Catalog</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Model</span><span style="color: #ECEFF4">\</span><span style="color: #8FBCBB">Product</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">as</span><span style="color: #D8DEE9FF"> MagentoProduct</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">class</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">CustomProduct</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">extends</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB; font-weight: bold">MagentoProduct</span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">public</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">function</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">myCustomMethod</span><span style="color: #ECEFF4">()</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #ECEFF4">        </span><span style="color: #616E88">// Your custom code here</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">}</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span></code></pre></div>



<p class="gtfy-630">In this class, you can write any custom methods or override any existing methods from the original <code>Magento\Catalog\Model\Product</code> class.</p>



<ol class="wp-block-list gtfy-634" start="3">
<li class="gtfy-633 gutenify-list-item">Plugins: Plugins, also known as interceptors, are used to modify the behavior of public methods in Magento classes without modifying the original class code. To create a plugin, you need to define the class and method you want to modify in Magento&#8217;s XML configuration and then create a PHP class that intercepts the method call. Here&#8217;s an example:</li>
</ol>



<p class="gtfy-637">Let&#8217;s say you want to modify the behavior of the <code>Magento\Checkout\Block\Cart\Item\Renderer</code> class to add some custom HTML to the product name. You could create a plugin that intercepts the <code>toHtml</code> method in this class and adds your custom HTML. To create this plugin, you would define the class and method in <code>app/code/Vendor/Module/etc/di.xml</code>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-640" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;config xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager/etc/config.xsd&quot;&gt;
    &lt;type name=&quot;Magento\Checkout\Block\Cart\Item\Renderer&quot;&gt;
        &lt;plugin name=&quot;my_custom_plugin&quot; type=&quot;Vendor\Module\Plugin\CustomPlugin&quot; sortOrder=&quot;10&quot; disabled=&quot;false&quot; /&gt;
    &lt;/type&gt;
&lt;/config&gt;" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">&lt;config</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">xmlns</span><span style="color: #ECEFF4">:</span><span style="color: #8FBCBB">xsi</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">http://www.w3.org/2001/XMLSchema-instance</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">xsi</span><span style="color: #ECEFF4">:</span><span style="color: #8FBCBB">noNamespaceSchemaLocation</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">urn:magento:framework:ObjectManager/etc/config.xsd</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">&lt;type</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Magento\Checkout\Block\Cart\Item\Renderer</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #81A1C1">&lt;plugin</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">my_custom_plugin</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">type</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Vendor\Module\Plugin\CustomPlugin</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">sortOrder</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">10</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">disabled</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">false</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">/&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">&lt;/type&gt;</span></span>
<span class="line"><span style="color: #81A1C1">&lt;/config&gt;</span></span></code></pre></div>



<p class="gtfy-643">Then, you would create a PHP class <code>CustomPlugin.php</code> in <code>app/code/Vendor/Module/Plugin</code> that implements the <code>Magento\Framework\Interception\InterceptorInterface</code> interface:</p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-646" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="namespace Vendor\Module\Plugin;

use Magento\Checkout\Block\Cart\Item\Renderer as MagentoRenderer;

class CustomPlugin
{
    public function aroundToHtml(MagentoRenderer $subject, callable $proceed)
    {
        // Your custom code here to modify the product name HTML
        $result = $proceed();
        // Your custom code here to modify the product name HTML
        return $result;
    }
}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">namespace</span><span style="color: #D8DEE9FF"> Vendor</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Module</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Plugin</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">use</span><span style="color: #D8DEE9FF"> Magento</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Checkout</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Block</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Cart</span><span style="color: #ECEFF4">\</span><span style="color: #D8DEE9FF">Item</span><span style="color: #ECEFF4">\</span><span style="color: #8FBCBB">Renderer</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">as</span><span style="color: #D8DEE9FF"> MagentoRenderer</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">class</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">CustomPlugin</span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">public</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">function</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">aroundToHtml</span><span style="color: #ECEFF4">(</span><span style="color: #8FBCBB">MagentoRenderer</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">$</span><span style="color: #D8DEE9">subject</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">callable</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">$</span><span style="color: #D8DEE9">proceed</span><span style="color: #ECEFF4">)</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #ECEFF4">        </span><span style="color: #616E88">// Your custom code here to modify the product name HTML</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #81A1C1">$</span><span style="color: #D8DEE9">result</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">$</span><span style="color: #D8DEE9">proceed</span><span style="color: #ECEFF4">()</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #ECEFF4">        </span><span style="color: #616E88">// Your custom code here to modify the product name HTML</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #81A1C1">return</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">$</span><span style="color: #D8DEE9">result</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">}</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span></code></pre></div>



<p class="gtfy-649">In this class, you can modify the behavior of the <code>toHtml</code> method by wrapping it with your own code using the <code>around</code> plugin method. The first parameter is the original class instance, and the second parameter is a callable function that represents the original method. Inside the <code>around</code> method, you can add your custom code before and after the original method call.</p>



<p class="gtfy-652">Note: The <code>sortOrder</code> attribute in the XML configuration determines the order in which plugins are executed. Lower numbers are executed first.</p>



<p class="gtfy-655">Additionally, the <code>disabled</code> attribute can be set to <code>true</code> to disable the plugin without removing it from the configuration.</p>



<p class="gtfy-658">So, in the <code>CustomPlugin</code> class, you can write any custom code that you want to execute before or after the <code>toHtml</code> method is called on an instance of the <code>Magento\Checkout\Block\Cart\Item\Renderer</code> class. The <code>aroundToHtml</code> method provides the ability to modify the input parameters and/or the return value of the original method.</p>



<p class="gtfy-661">In summary, observers, preferences, and plugins are powerful tools in Magento 2 that can be used to modify and extend the behavior of the platform. Observers allow you to listen for specific events and execute custom code in response, preferences allow you to override the default behavior of Magento classes with your own custom implementation, and plugins allow you to modify the behavior of public methods in Magento classes without modifying the original class code. By using these tools correctly, you can create highly customizable and extensible Magento modules that meet the needs of your clients or business.</p><p>The post <a href="https://www.tagvibe.com/how-to-apply-observers-preferences-and-plugins-correctly-in-magento-2/">How to apply observers, preferences, and plugins correctly in Magento 2</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to apply custom updates to product/category pages</title>
		<link>https://www.tagvibe.com/how-to-apply-custom-updates-to-product-category-pages/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 16 Mar 2023 18:10:51 +0000</pubDate>
				<category><![CDATA[Magento2]]></category>
		<guid isPermaLink="false">https://tagvibe.com/?p=315</guid>

					<description><![CDATA[<p>To apply custom updates to product/category pages in Magento 2, there are several solutions you can use depending on your specific needs. Here are a few examples: Use Layout XML UpdatesYou can use Layout XML Updates to apply custom updates to product/category pages in Magento 2. This solution allows you to modify the layout of the page by adding or removing blocks, changing block attributes, and more. Here is an example of how to add a custom block to the product page: In this example, we are adding a new block called &#8220;custom.block&#8221; to the &#8220;product.info.main&#8221; block on the product page. The block uses a custom template called &#8220;custom_block.phtml&#8221;, which should be located in the &#8220;Vendor_Module&#8221; module. Use CMS Static BlocksMagento 2 also allows you to create CMS static blocks and apply them to product/category pages. This solution is useful if you want to add custom content or promotions to a specific page without modifying the layout. Here is an example of how to add a CMS static block to the category page: Go to Content &#62; Elements &#62; Blocks in the Magento Admin Panel. Create a new static block with your custom content. Go to Products &#62; Categories and select the category you want to add the block to. Go to the Content tab and add the following code to the &#8220;Display Settings&#8221; field: In this example, &#8220;your_block_id&#8221; is the ID of the CMS static block you created. Use Theme CustomizationIf you want to apply custom updates to multiple pages or make more extensive modifications to the layout, you can use Magento 2&#8217;s built-in theme customization features. This solution involves creating a child theme of your current theme and making modifications to the theme&#8217;s files. Here is an example of how to add a custom block to the product page using theme customization: Create a child theme of your current theme. Copy the &#8220;catalog_product_view.xml&#8221; file from your parent theme to your child theme&#8217;s &#8220;Magento_Catalog/layout&#8221; folder. Add the following code to the &#8220;catalog_product_view.xml&#8221; file: In this example, we are adding a new block called &#8220;custom.block&#8221; to the &#8220;product.info.main&#8221; block on the product page. The block uses a custom template called &#8220;custom_block.phtml&#8221;, which should be located in the &#8220;Vendor_Module&#8221; module. These are just a few examples of how to apply custom updates to product/category pages in Magento 2. Depending on your specific needs, there may be other solutions available as well.</p>
<p>The post <a href="https://www.tagvibe.com/how-to-apply-custom-updates-to-product-category-pages/">How to apply custom updates to product/category pages</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></description>
										<content:encoded><![CDATA[<p class="gtfy-711">To apply custom updates to product/category pages in Magento 2, there are several solutions you can use depending on your specific needs. Here are a few examples:</p>



<p class="gtfy-714"><strong>Use Layout XML Updates</strong><br>You can use Layout XML Updates to apply custom updates to product/category pages in Magento 2. This solution allows you to modify the layout of the page by adding or removing blocks, changing block attributes, and more. Here is an example of how to add a custom block to the product page:<br></p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-717" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;referenceBlock name=&quot;product.info.main&quot;&gt;
   &lt;block class=&quot;Magento\Framework\View\Element\Template&quot; name=&quot;custom.block&quot; template=&quot;Vendor_Module::custom_block.phtml&quot;/&gt;
&lt;/referenceBlock&gt;
" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">&lt;referenceBlock</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">product.info.main</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">   </span><span style="color: #81A1C1">&lt;block</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">class</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Magento\Framework\View\Element\Template</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">custom.block</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">template</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Vendor_Module::custom_block.phtml</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">/&gt;</span></span>
<span class="line"><span style="color: #81A1C1">&lt;/referenceBlock&gt;</span></span>
<span class="line"></span></code></pre></div>



<p class="gtfy-720"><br>In this example, we are adding a new block called &#8220;custom.block&#8221; to the &#8220;product.info.main&#8221; block on the product page. The block uses a custom template called &#8220;custom_block.phtml&#8221;, which should be located in the &#8220;Vendor_Module&#8221; module.</p>



<p class="gtfy-723"><strong>Use CMS Static Blocks</strong><br>Magento 2 also allows you to create CMS static blocks and apply them to product/category pages. This solution is useful if you want to add custom content or promotions to a specific page without modifying the layout. Here is an example of how to add a CMS static block to the category page:</p>



<p class="gtfy-726">Go to Content &gt; Elements &gt; Blocks in the Magento Admin Panel.</p>



<p class="gtfy-729">Create a new static block with your custom content.</p>



<p class="gtfy-732">Go to Products &gt; Categories and select the category you want to add the block to.</p>



<p class="gtfy-735">Go to the Content tab and add the following code to the &#8220;Display Settings&#8221; field:</p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-738" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="{{block class=&quot;Magento\Cms\Block\Block&quot; block_id=&quot;your_block_id&quot;}}" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #ECEFF4">{{</span><span style="color: #D8DEE9FF">block </span><span style="color: #81A1C1">class=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Magento\Cms\Block\Block</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> block_id</span><span style="color: #81A1C1">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">your_block_id</span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">}}</span></span></code></pre></div>



<p class="gtfy-741"><br>In this example, &#8220;your_block_id&#8221; is the ID of the CMS static block you created.</p>



<p class="gtfy-744">Use Theme Customization<br>If you want to apply custom updates to multiple pages or make more extensive modifications to the layout, you can use Magento 2&#8217;s built-in theme customization features. This solution involves creating a child theme of your current theme and making modifications to the theme&#8217;s files. Here is an example of how to add a custom block to the product page using theme customization:</p>



<p class="gtfy-747">Create a child theme of your current theme.</p>



<p class="gtfy-750">Copy the &#8220;catalog_product_view.xml&#8221; file from your parent theme to your child theme&#8217;s &#8220;Magento_Catalog/layout&#8221; folder.</p>



<p class="gtfy-753">Add the following code to the &#8220;catalog_product_view.xml&#8221; file:</p>



<div class="wp-block-kevinbatdorf-code-block-pro gtfy-756" style="font-size:.875rem;line-height:1.25rem"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" data-code="&lt;referenceBlock name=&quot;product.info.main&quot;&gt;
   &lt;block class=&quot;Magento\Framework\View\Element\Template&quot; name=&quot;custom.block&quot; template=&quot;Vendor_Module::custom_block.phtml&quot;/&gt;
&lt;/referenceBlock&gt;" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff"><code><span class="line"><span style="color: #81A1C1">&lt;referenceBlock</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">product.info.main</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">&gt;</span></span>
<span class="line"><span style="color: #D8DEE9FF">   </span><span style="color: #81A1C1">&lt;block</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">class</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Magento\Framework\View\Element\Template</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">name</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">custom.block</span><span style="color: #ECEFF4">&quot;</span><span style="color: #D8DEE9FF"> </span><span style="color: #8FBCBB">template</span><span style="color: #D8DEE9FF">=</span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Vendor_Module::custom_block.phtml</span><span style="color: #ECEFF4">&quot;</span><span style="color: #81A1C1">/&gt;</span></span>
<span class="line"><span style="color: #81A1C1">&lt;/referenceBlock&gt;</span></span></code></pre></div>



<p class="gtfy-759"><br>In this example, we are adding a new block called &#8220;custom.block&#8221; to the &#8220;product.info.main&#8221; block on the product page. The block uses a custom template called &#8220;custom_block.phtml&#8221;, which should be located in the &#8220;Vendor_Module&#8221; module.</p>



<p class="gtfy-762">These are just a few examples of how to apply custom updates to product/category pages in Magento 2. Depending on your specific needs, there may be other solutions available as well.</p><p>The post <a href="https://www.tagvibe.com/how-to-apply-custom-updates-to-product-category-pages/">How to apply custom updates to product/category pages</a> first appeared on <a href="https://www.tagvibe.com">Tag Vibe</a>.</p>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
