## Bagisto Documentation Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. ## Package creation Learn how to create a new package for Bagisto. ## Digging Deeper Learn advanced topics like payment methods, shipping methods. ## Custom theme Learn how to create or customize a theme for Bagisto. ## Bagisto E-Commerce Framework Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/introduction/#introduction) Introduction **Bagisto** is a E-Commerce framework built on top of the hottest opensource technologies such as [Laravel(opens new window)](https://laravel.com/), a [PHP(opens new window)](https://php.net/) framework and [Vue.js(opens new window)](https://vuejs.org/), a progressive Javascript framework. **Bagisto** is a viable option to reduce your time, cost and workforce for building online stores or migrating from a physical store to an online platform. It is suitable for all small or large E-Commerce business demands using a simple set-up procedure. Built on top of [Laravel(opens new window)](https://laravel.com/) and equipped with an easy product information management. The framework is very flexible and easy to use even for non-tech users. **Bagisto** features an administration panel with a dashboard, sales data, a catalog for products and customer management. To learn more about **Bagisto's** features and try a demo, check out our website [https://bagisto.com(opens new window)](https://bagisto.com/). Get quickly updated on the current version and recently released features, see [Bagisto roadmap(opens new window)](https://bagisto.com/roadmap/). You can get started with the source code by checking out the repo on GitHub at [bagisto/bagisto(opens new window)](https://github.com/bagisto/bagisto). [Requirements](https://devdocs.bagisto.com/1.x/introduction/requirements.html) ## Bagisto Architecture Overview Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/architecture/#architecture-concepts) Architecture concepts **Bagisto** is very easy framework to understand. The goal of this document to give you overview of how bagisto works. We love to work with hot [Opensource(opens new window)](https://en.wikipedia.org/wiki/Open_source) softwares so Bagisto is built on technologies such as [PHP(opens new window)](https://php.net/), [Laravel(opens new window)](https://laravel.com/), [Vue.js(opens new window)](https://vuejs.org/) and [Tailwind CSS(opens new window)](https://tailwindcss.com/). As **Bagisto** targets e-commerce businesses so it provides front and back end features to enable customer account and administrative control simultaneously. Laravel packages are being used to separate each functionality such as Category, Product, Cart, Checkout, etc. We developed and used built-in components of Vue.js **Bagisto** registers useful events that are triggered on most of the pages which could enable to perform some custom operations in the application. [Docker](https://devdocs.bagisto.com/2.2/introduction/docker.html)[Packages](https://devdocs.bagisto.com/2.2/architecture/packages.html) ## Bagisto Architecture Overview This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/architecture/#architecture-concepts) Architecture concepts **Bagisto** is very easy framework to understand. The goal of this document to give you overview of how bagisto works. We love to work with hot [Opensource(opens new window)](https://en.wikipedia.org/wiki/Open_source) softwares so Bagisto is built on technologies such as [PHP(opens new window)](https://php.net/), [Laravel(opens new window)](https://laravel.com/), [Vue.js(opens new window)](https://vuejs.org/) and [Tailwind CSS(opens new window)](https://tailwindcss.com/). As **Bagisto** targets e-commerce businesses so it provides front and back end features to enable customer account and administrative control simultaneously. Laravel packages are being used to separate each functionality such as Category, Product, Cart, Checkout, etc. We developed and used built-in components of Vue.js **Bagisto** registers useful events that are triggered on most of the pages which could enable to perform some custom operations in the application. [Sail](https://devdocs.bagisto.com/2.3/introduction/sail.html)[Packages](https://devdocs.bagisto.com/2.3/architecture/packages.html) ## Bagisto Package Development This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. ## [#](https://devdocs.bagisto.com/2.3/packages/#package-development) Package Development If you are looking to extend the functionalities of Bagisto eCommerce platform, creating a package is the way to go. A package is a self-contained module that adds specific features to the platform. It allows developers to add custom functionality to the platform without modifying the core codebase. This guide will walk you through the process of developing a package for Bagisto. In Bagisto, we have created numerous packages located at **`packages/Webkul/`**. Below is a basic tree structure of a package: ``` └── Webkul └── Blog └── src ├── Config │ ├── acl.php │ ├── admin-menu.php │ ├── shop-menu.php │ └── system.php ├── Console │ └── Commands ├── Contracts │ └── Post.php ├── Database │ ├── Migrations │ │ └── 2024_10_10_122434_create_posts_table.php │ └── Seeders ├── Events ├── Http │ ├── Controllers │ │ ├── Admin │ │ │ └── PostController.php │ │ └── Shop │ │ └── PostController.php │ ├── Middleware │ └── Requests ├── Listeners ├── Mail ├── Models │ ├── Post.php │ └── PostProxy.php ├── Providers │ ├── BlogServiceProvider.php │ └── ModuleServiceProvider.php ├── Routes │ ├── admin-routes.php │ └── shop-routes.php ├── Repositories │ └── PostRepository.php └── Resources ├── assets │ ├── images │ │ └── blog-icon.png │ ├── js │ │ └── app.js │ └── css │ └── app.css ├── lang │ └── app.php └── views ├── admin │ └── blog │ ├── create.blade.php │ ├── edit.blade.php │ └── index.blade.php └── shop └── default ├── index.blade.php └── blog-details.blade.php ``` [Modular Design](https://devdocs.bagisto.com/2.3/architecture/modular-design.html)[Getting Started](https://devdocs.bagisto.com/2.3/packages/create-package.html) ## Bagisto Performance Guide This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/performance/#performance) Performance Bagisto is designed to be fast, scalable, and efficient, ensuring a smooth e-commerce experience even under heavy traffic. This guide covers essential performance optimizations, caching strategies, database tuning, indexing, full-page caching (FPC), Laravel Octane, and load balancing techniques to enhance scalability. In the realm of online stores, [web vitals(opens new window)](https://web.dev/vitals/) have become increasingly crucial. Bagisto prioritizes good [LCP(opens new window)](https://web.dev/lcp/) and [CLS(opens new window)](https://web.dev/cls/) to ensure an optimal user experience. Additionally, Bagisto has seamlessly integrated [ElasticSearch(opens new window)](https://bagisto.com/en/elasticsearch-for-bagisto/) to further enhance search speed and efficiency. ## [#](https://devdocs.bagisto.com/2.3/performance/#key-performance-features) Key Performance Features ### [#](https://devdocs.bagisto.com/2.3/performance/#caching-mechanisms) Caching Mechanisms - Implements Full Page Caching (FPC) to reduce server processing time and accelerate page loads. - Page and route caching improve response times. ### [#](https://devdocs.bagisto.com/2.3/performance/#optimized-codebase) Optimized Codebase - Follows best coding practices with a modular architecture for faster execution. - Uses Laravel Octane to boost performance by running the application with high-performance servers like RoadRunner and Swoole. ### [#](https://devdocs.bagisto.com/2.3/performance/#database-performance) Database Performance - Uses proper indexing and optimized queries to enhance database speed. - Supports read/write database replication for high availability. ### [#](https://devdocs.bagisto.com/2.3/performance/#lazy-loading) Lazy Loading - Implements lazy loading for images and assets to enhance page load speed. ### [#](https://devdocs.bagisto.com/2.3/performance/#indexing-for-enhanced-performance) Indexing for Enhanced Performance - Implements indexing strategies using Elasticsearch to speed up product searches and filtering. - Improves product listing performance with efficient indexing mechanisms. - Supports asynchronous indexing to prevent performance bottlenecks. ### [#](https://devdocs.bagisto.com/2.3/performance/#queue-processing) Queue Processing - Uses Laravel Queues to handle background tasks efficiently (e.g., emails, order processing). ## [#](https://devdocs.bagisto.com/2.3/performance/#load-balancing-for-scalability) Load Balancing for Scalability To ensure high availability and scalability, Bagisto can be deployed with a Load Balancer to distribute traffic efficiently across multiple instances. ### [#](https://devdocs.bagisto.com/2.3/performance/#optimize-database-queries) Optimize Database Queries - Monitor slow queries and implement indexing. ### [#](https://devdocs.bagisto.com/2.3/performance/#regular-updates) Regular Updates - Keep Bagisto and all dependencies up to date. ### [#](https://devdocs.bagisto.com/2.3/performance/#monitor-performance-metrics) Monitor Performance Metrics - Use AWS CloudWatch, New Relic, or other monitoring tools to track performance bottlenecks. By following these best practices and leveraging Bagisto's built-in performance features, you can ensure a fast, scalable, and reliable e-commerce platform. [Custom Theme Package](https://devdocs.bagisto.com/2.3/themes/custom-theme-package.html)[Indexing](https://devdocs.bagisto.com/2.3/performance/indexing.html) ## Advanced Bagisto Topics Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/advanced/#advanced-topics) Advanced Topics In this section, we will discuss the advanced topics of Bagisto like creating payment methods, shipping methods, data grids, and many more. Before diving into this, we are assuming that you are familiar with Laravel. [Repositories](https://devdocs.bagisto.com/1.x/packages/store-data-through-repositories.html)[Create a shipping method](https://devdocs.bagisto.com/1.x/advanced/create-shipping-method.html) ## Advanced Bagisto Features This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/advanced/#digging-deeper) Digging Deeper Welcome to the "Digging Deeper" section of the Bagisto documentation. Here, we will explore various advanced topics related to Bagisto, which will enable you to customize and extend your e-commerce platform to suit your specific needs. We expect you to have knowledge of creating packages in Laravel. If you are new to package development, we recommend referring to the [Package Development](https://devdocs.bagisto.com/2.3/packages/create-package.html) section for a primer on creating and managing packages in Laravel. ### [#](https://devdocs.bagisto.com/2.3/advanced/#creating-payment-methods) Creating Payment Methods Bagisto provides a flexible and configurable system for integrating different payment methods into your e-commerce store. We will guide you through the process of setting up and configuring payment methods, allowing you to offer a variety of options to your customers while ensuring a seamless and secure checkout experience. ### [#](https://devdocs.bagisto.com/2.3/advanced/#product-types) Product Types Bagisto supports different types of products, allowing you to showcase and sell a wide range of items. We will delve into the details of configuring and managing product types, giving you the ability to define specific attributes and behaviors for each product category. ### [#](https://devdocs.bagisto.com/2.3/advanced/#shipping-methods) Shipping Methods Efficient and reliable shipping is crucial for any e-commerce business. Bagisto offers robust features for managing shipping methods, enabling you to define various shipping options, rates, and rules based on factors such as location, weight, or order value. We will explain how to configure and customize shipping methods to streamline your order fulfillment process. ### [#](https://devdocs.bagisto.com/2.3/advanced/#events-and-event-handlers) Events and Event Handlers Events and event handlers provide a powerful way to extend the functionality of Bagisto by allowing you to react to specific actions or triggers within the application. We will show you how to utilize events and event handlers effectively, enabling you to integrate custom functionalities and automate processes. ### [#](https://devdocs.bagisto.com/2.3/advanced/#helpers) Helpers Bagisto includes a comprehensive set of helper functions that simplify common development tasks and enhance productivity. We will explore the various helper functions available, explaining their purpose and usage to assist you in writing clean and efficient code. ### [#](https://devdocs.bagisto.com/2.3/advanced/#indexing-through-elastic) Indexing through Elastic To optimize search performance, Bagisto integrates with Elasticsearch, a highly scalable search engine. We will guide you through the process of indexing your data using Elastic, improving the search functionality of your e-commerce store and providing a seamless search experience for your customers. ### [#](https://devdocs.bagisto.com/2.3/advanced/#overriding-core-models) Overriding Core Models Sometimes, you may need to modify or extend the default behavior of Bagisto's core models to accommodate your specific business requirements. We will demonstrate how to override core models effectively, enabling you to customize the behavior of Bagisto without modifying the underlying codebase. ### [#](https://devdocs.bagisto.com/2.3/advanced/#data-transfer) Data Transfer Directory Structure Creating a data import in a custom package makes it very easy to import bulk data into Bagisto. In Bagisto, data transfer can be found in the admin panel under the Settings Menu. [System Configuration](https://devdocs.bagisto.com/2.3/packages/create-system-configuration.html)[Shipping Method](https://devdocs.bagisto.com/2.3/advanced/create-shipping-method.html) ## Bagisto E-Commerce Platform This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/introduction/#introduction) Introduction ## [#](https://devdocs.bagisto.com/2.3/introduction/#bagisto-a-powerful-open-source-e-commerce-platform) Bagisto: A Powerful Open-Source E-Commerce Platform Bagisto is a popular open-source e-commerce platform built on the combination of the Laravel PHP framework, Vue.js, and the stylish Tailwind CSS framework. It provides a comprehensive set of tools and features to help developers and businesses create and manage their online stores effectively. With its flexible and adaptable nature, Bagisto has gained recognition and support from a growing community of users, as evidenced by its impressive 12.4K+ stars on [GitHub(opens new window)](https://github.com/bagisto/bagisto). ## [#](https://devdocs.bagisto.com/2.3/introduction/#key-features-of-bagisto) Key Features of Bagisto Bagisto comes with a rich set of features that empower developers and businesses to create and manage their online stores effectively: ### [#](https://devdocs.bagisto.com/2.3/introduction/#modular-design) Modular Design Bagisto adopts a modular design approach, providing developers with the flexibility to customize and extend the platform's functionalities to meet specific business requirements. It allows you to tailor your e-commerce store precisely to your needs. ### [#](https://devdocs.bagisto.com/2.3/introduction/#multi-channel-and-multi-vendor-support) Multi-Channel and Multi-Vendor Support With Bagisto, you can easily create and manage multiple sales channels, enabling you to expand your reach and cater to different customer segments. It also supports multi-vendor functionality, allowing various vendors to sell their products on your platform. ### [#](https://devdocs.bagisto.com/2.3/introduction/#multi-locals-and-currencies-support-in-installer) Multi-Locals and Currencies Support in Installer With Bagisto, you can now effortlessly install your application in multiple locales during the installation process. It also supports the functionality of multiple currencies during installation. By offering such flexibility during installation, applications extend their usability to a wider audience, fostering a more user-centric and globally accessible application ecosystem. ### [#](https://devdocs.bagisto.com/2.3/introduction/#responsive-and-mobile-friendly) Responsive and Mobile-Friendly Bagisto ensures that your online store looks great and performs flawlessly across different devices, including mobile phones and tablets. With a responsive design, you can provide a seamless shopping experience to your customers, no matter the device they use. ### [#](https://devdocs.bagisto.com/2.3/introduction/#efficient-inventory-management) Efficient Inventory Management Bagisto simplifies inventory management by providing tools to effectively track stock levels, set low inventory alerts, and streamline order fulfillment processes. You can efficiently manage your product inventory and ensure a smooth flow of operations. ### [#](https://devdocs.bagisto.com/2.3/introduction/#secure-payment-gateways-and-shipping-methods) Secure Payment Gateways and Shipping Methods Integrating popular payment gateways and shipping methods is effortless with Bagisto. It offers seamless integration options to ensure secure and convenient transactions for your customers, making the checkout process a breeze. ### [#](https://devdocs.bagisto.com/2.3/introduction/#search-engine-optimization-seo-capabilities) Search Engine Optimization (SEO) Capabilities Bagisto equips you with built-in features to optimize your online store for search engines. You can customize meta tags, URLs, and keywords to improve your store's visibility and attract more organic traffic. ## [#](https://devdocs.bagisto.com/2.3/introduction/#community-and-support) Community and Support Bagisto has a vibrant and supportive community of developers and users who actively contribute to its growth and improvement. - **Explore Bagisto**: Visit our website at [https://bagisto.com(opens new window)](https://bagisto.com/) to discover more about Bagisto's features and experience a demo. - **Stay Updated**: Refer to the [Bagisto roadmap(opens new window)](https://bagisto.com/roadmap) for the latest version and recently added features. - **GitHub Repository**: Access the Bagisto repository on [GitHub(opens new window)](https://github.com/bagisto/bagisto) with over 12.4K+ stars, reflecting its popularity and community support. Join the Bagisto community today and build and manage your online store with ease. [Contribution Guide](https://devdocs.bagisto.com/2.3/prologue/contribution-guide.html)[Requirements](https://devdocs.bagisto.com/2.3/introduction/requirements.html) ## Bagisto Package Development Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. ## [#](https://devdocs.bagisto.com/2.2/packages/#package-development) Package Development If you are looking to extend the functionalities of Bagisto eCommerce platform, creating a package is the way to go. A package is a self-contained module that adds specific features to the platform. It allows developers to add custom functionality to the platform without modifying the core codebase. This guide will walk you through the process of developing a package for Bagisto. In Bagisto, we have created numerous packages located at **`packages/Webkul/`**. Below is a basic tree structure of a package: ``` └── Webkul └── Blog └── src ├── Config │ ├── acl.php │ ├── admin-menu.php │ ├── shop-menu.php │ └── system.php ├── Console │ └── Commands ├── Contracts │ └── Post.php ├── Database │ ├── Migrations │ │ └── 2024_10_10_122434_create_posts_table.php │ └── Seeders ├── Events ├── Http │ ├── Controllers │ │ ├── Admin │ │ │ └── PostController.php │ │ └── Shop │ │ └── PostController.php │ ├── Middleware │ └── Requests ├── Listeners ├── Mail ├── Models │ ├── Post.php │ └── PostProxy.php ├── Providers │ ├── BlogServiceProvider.php │ └── ModuleServiceProvider.php ├── Routes │ ├── admin-routes.php │ └── shop-routes.php ├── Repositories │ └── PostRepository.php └── Resources ├── assets │ ├── images │ │ └── blog-icon.png │ ├── js │ │ └── app.js │ └── css │ └── app.css ├── lang │ └── app.php └── views ├── admin │ └── blog │ ├── create.blade.php │ ├── edit.blade.php │ └── index.blade.php └── shop └── default ├── index.blade.php └── blog-details.blade.php ``` [Modular Design](https://devdocs.bagisto.com/2.2/architecture/modular-design.html)[Getting Started](https://devdocs.bagisto.com/2.2/packages/create-package.html) ## Advanced Bagisto Documentation Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/advanced/#digging-deeper) Digging Deeper Welcome to the "Digging Deeper" section of the Bagisto documentation. Here, we will explore various advanced topics related to Bagisto, which will enable you to customize and extend your e-commerce platform to suit your specific needs. We expect you to have knowledge of creating packages in Laravel. If you are new to package development, we recommend referring to the [Package Development](https://devdocs.bagisto.com/2.2/packages/create-package.html) section for a primer on creating and managing packages in Laravel. ### [#](https://devdocs.bagisto.com/2.2/advanced/#creating-payment-methods) Creating Payment Methods Bagisto provides a flexible and configurable system for integrating different payment methods into your e-commerce store. We will guide you through the process of setting up and configuring payment methods, allowing you to offer a variety of options to your customers while ensuring a seamless and secure checkout experience. ### [#](https://devdocs.bagisto.com/2.2/advanced/#product-types) Product Types Bagisto supports different types of products, allowing you to showcase and sell a wide range of items. We will delve into the details of configuring and managing product types, giving you the ability to define specific attributes and behaviors for each product category. ### [#](https://devdocs.bagisto.com/2.2/advanced/#shipping-methods) Shipping Methods Efficient and reliable shipping is crucial for any e-commerce business. Bagisto offers robust features for managing shipping methods, enabling you to define various shipping options, rates, and rules based on factors such as location, weight, or order value. We will explain how to configure and customize shipping methods to streamline your order fulfillment process. ### [#](https://devdocs.bagisto.com/2.2/advanced/#events-and-event-handlers) Events and Event Handlers Events and event handlers provide a powerful way to extend the functionality of Bagisto by allowing you to react to specific actions or triggers within the application. We will show you how to utilize events and event handlers effectively, enabling you to integrate custom functionalities and automate processes. ### [#](https://devdocs.bagisto.com/2.2/advanced/#helpers) Helpers Bagisto includes a comprehensive set of helper functions that simplify common development tasks and enhance productivity. We will explore the various helper functions available, explaining their purpose and usage to assist you in writing clean and efficient code. ### [#](https://devdocs.bagisto.com/2.2/advanced/#indexing-through-elastic) Indexing through Elastic To optimize search performance, Bagisto integrates with Elasticsearch, a highly scalable search engine. We will guide you through the process of indexing your data using Elastic, improving the search functionality of your e-commerce store and providing a seamless search experience for your customers. ### [#](https://devdocs.bagisto.com/2.2/advanced/#overriding-core-models) Overriding Core Models Sometimes, you may need to modify or extend the default behavior of Bagisto's core models to accommodate your specific business requirements. We will demonstrate how to override core models effectively, enabling you to customize the behavior of Bagisto without modifying the underlying codebase. ### [#](https://devdocs.bagisto.com/2.2/advanced/#data-transfer) Data Transfer Directory Structure Creating a data import in a custom package makes it very easy to import bulk data into Bagisto. In Bagisto, data transfer can be found in the admin panel under the Settings Menu. [System Configuration](https://devdocs.bagisto.com/2.2/packages/create-system-configuration.html)[Shipping Method](https://devdocs.bagisto.com/2.2/advanced/create-shipping-method.html) ## Bagisto Performance Guide Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/performance/#performance) Performance Bagisto is designed to be fast, scalable, and efficient, ensuring a smooth e-commerce experience even under heavy traffic. This guide covers essential performance optimizations, caching strategies, database tuning, indexing, full-page caching (FPC), Laravel Octane, and load balancing techniques to enhance scalability. In the realm of online stores, [web vitals(opens new window)](https://web.dev/vitals/) have become increasingly crucial. Bagisto prioritizes good [LCP(opens new window)](https://web.dev/lcp/) and [CLS(opens new window)](https://web.dev/cls/) to ensure an optimal user experience. Additionally, Bagisto has seamlessly integrated [ElasticSearch(opens new window)](https://bagisto.com/en/elasticsearch-for-bagisto/) to further enhance search speed and efficiency. ## [#](https://devdocs.bagisto.com/2.2/performance/#key-performance-features) Key Performance Features ### [#](https://devdocs.bagisto.com/2.2/performance/#caching-mechanisms) Caching Mechanisms - Implements Full Page Caching (FPC) to reduce server processing time and accelerate page loads. - Page and route caching improve response times. ### [#](https://devdocs.bagisto.com/2.2/performance/#optimized-codebase) Optimized Codebase - Follows best coding practices with a modular architecture for faster execution. - Uses Laravel Octane to boost performance by running the application with high-performance servers like RoadRunner and Swoole. ### [#](https://devdocs.bagisto.com/2.2/performance/#database-performance) Database Performance - Uses proper indexing and optimized queries to enhance database speed. - Supports read/write database replication for high availability. ### [#](https://devdocs.bagisto.com/2.2/performance/#lazy-loading) Lazy Loading - Implements lazy loading for images and assets to enhance page load speed. ### [#](https://devdocs.bagisto.com/2.2/performance/#indexing-for-enhanced-performance) Indexing for Enhanced Performance - Implements indexing strategies using Elasticsearch to speed up product searches and filtering. - Improves product listing performance with efficient indexing mechanisms. - Supports asynchronous indexing to prevent performance bottlenecks. ### [#](https://devdocs.bagisto.com/2.2/performance/#queue-processing) Queue Processing - Uses Laravel Queues to handle background tasks efficiently (e.g., emails, order processing). ## [#](https://devdocs.bagisto.com/2.2/performance/#load-balancing-for-scalability) Load Balancing for Scalability To ensure high availability and scalability, Bagisto can be deployed with a Load Balancer to distribute traffic efficiently across multiple instances. ### [#](https://devdocs.bagisto.com/2.2/performance/#optimize-database-queries) Optimize Database Queries - Monitor slow queries and implement indexing. ### [#](https://devdocs.bagisto.com/2.2/performance/#regular-updates) Regular Updates - Keep Bagisto and all dependencies up to date. ### [#](https://devdocs.bagisto.com/2.2/performance/#monitor-performance-metrics) Monitor Performance Metrics - Use AWS CloudWatch, New Relic, or other monitoring tools to track performance bottlenecks. By following these best practices and leveraging Bagisto's built-in performance features, you can ensure a fast, scalable, and reliable e-commerce platform. [Admin Theme](https://devdocs.bagisto.com/2.2/themes/create-admin-theme.html)[Indexing](https://devdocs.bagisto.com/2.2/performance/indexing.html) ## Bagisto Package Development Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/packages/#package-development) Package development A package is a unit added to your application for enhancement which includes routes, controllers, views, and configuration specifically. Packages are created to manage your large applications into smaller units. In Bagisto, we have created plenty of packages at path `packages/Webkul/`. You can find a basic tree-structure of the package below: ``` - ACME/HelloWorld/ - publishable/assets - css/ - images/ - js/ - src/ - Config/ - acl.php - admin-menu.php - Console/ - Commands/ - Contracts/ - Database/ - Migrations/ - Seeders/ - Events/ - Http/ - Controllers/ - Admin/ - HelloWorldController.php - Shop/ - HelloWorldController.php - Middleware/ - Requests/ - admin-routes.php - shop-routes.php - Listeners/ - Mail/ - Models/ - Providers/ - HelloWorldServiceProvider.php - ModuleServiceProvider.php - Repositories/ - Resources/ - assets/ - images/ - js/ - app.js - sass/ - admin.scss - default.scss - velocity.scss - lang/ - views/ - admin/ - layouts/ - style.blade.php - index.blade.php - shop/ - default/ - index.blade.php - velocity/ - index.blade.php - package.json - webpack.mix.js ``` ## Bagisto Theme Development Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/themes/#themes) Themes If you are looking to customize the appearance and design of your Bagisto e-commerce store, creating a custom theme is the way to go. Bagisto offers a flexible and straightforward approach to theme development, allowing you to tailor the look and feel of your store to align with your brand and meet your specific requirements. ## [#](https://devdocs.bagisto.com/2.2/themes/#package-development-prerequisite) Package Development Prerequisite Before diving into theme development, it is recommended to have knowledge of creating packages in Laravel. If you are new to package development, you can refer to the [Package Development](https://devdocs.bagisto.com/2.2/packages) section for a primer on creating and managing packages in Laravel. Understanding package development concepts will greatly assist you in creating and organizing your custom theme. ## [#](https://devdocs.bagisto.com/2.2/themes/#creating-a-custom-theme) Creating a Custom Theme Creating a custom theme for Bagisto involves a few simple steps. Here's an overview of the process: 1. **Create a Package**: As themes in Bagisto are treated as packages, the first step is to create a new package specifically for your theme. This package will serve as the container for your theme files and configuration. 2. **Configure the Package**: Once the package is created, you need to configure it by defining the necessary details, such as the package name, author, description, and other relevant information. This configuration ensures that Bagisto recognizes your package as a theme. 3. **Define the Theme Assets**: In Bagisto, themes are primarily composed of assets such as CSS stylesheets, JavaScript files, and image files. You will need to create the appropriate directories within your theme package to store these assets. 4. **Create Blade Views**: Blade views are the templates used to render the frontend of your store. You can create your own custom views within your theme package, allowing you to customize the appearance of different pages and components. 5. **Configure Theme Layout**: Bagisto provides a layout system that defines the structure and organization of your store's pages. You can configure the layout for your theme by specifying the positions of various components, such as the header, footer, sidebar, and content sections. 6. **Customize Theme Styles**: To achieve a unique and visually appealing design, you can customize the CSS stylesheets of your theme. This includes modifying colors, typography, spacing, and other visual elements to match your branding and aesthetic preferences. 7. **Activate and Test the Theme**: Once your custom theme is ready, you can activate it in the Bagisto admin panel. This will make your theme the active theme for your store, reflecting the changes and customizations you have made. It is crucial to thoroughly test your theme to ensure its compatibility and responsiveness across different devices and browsers. By following these steps, you can create a fully customized theme for your Bagisto e-commerce store. This empowers you to create a unique and engaging shopping experience for your customers, aligning with your brand identity and enhancing your online presence. [Data Transfer](https://devdocs.bagisto.com/2.2/advanced/create-data-import.html)[Store Theme](https://devdocs.bagisto.com/2.2/themes/create-store-theme.html) ## Bagisto eCommerce Overview This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/prologue/#prologue) Prologue ## [#](https://devdocs.bagisto.com/2.3/prologue/#introduction-to-bagisto) Introduction to Bagisto [Bagisto(opens new window)](https://bagisto.com/) is a fantastic open-source eCommerce platform that allows businesses to create modern online stores easily. Bagisto offers a wide range of customizable features to meet the specific needs of any online business. The platform is built on top of the reliable [Laravel(opens new window)](https://laravel.com/) framework , [Tailwind CSS(opens new window)](https://tailwindcss.com/) and [Vue.js(opens new window)](https://vuejs.org/), a user-friendly JavaScript framework. It provides businesses with a user-friendly interface and powerful tools to manage their online stores, handle inventory and orders, and create a smooth shopping experience for customers. ## [#](https://devdocs.bagisto.com/2.3/prologue/#customization-and-branding) Customization and Branding With Bagisto, businesses have the flexibility to customize the look and feel of their online stores, from choosing themes and layouts to adding unique branding elements. The platform offers a comprehensive set of marketing and promotional tools, enabling businesses to attract customers and drive sales effectively. ## [#](https://devdocs.bagisto.com/2.3/prologue/#seo-optimization) SEO Optimization One of Bagisto's standout features is its robust SEO capabilities. It includes built-in SEO tools and optimization options, empowering businesses to improve their search engine rankings and increase organic traffic to their online stores. ## [#](https://devdocs.bagisto.com/2.3/prologue/#payment-and-shipping-integration) Payment and Shipping Integration Moreover, Bagisto supports a wide range of payment gateways, allowing businesses to offer convenient and secure payment options to their customers. It also integrates seamlessly with popular shipping providers, streamlining the order fulfillment process and ensuring reliable and timely deliveries. ## [#](https://devdocs.bagisto.com/2.3/prologue/#summary) Summary In summary, Bagisto is a powerful and flexible eCommerce platform that empowers businesses to build and manage online stores efficiently. With its customizable features, user-friendly interface, reliable framework, robust SEO capabilities, and comprehensive set of tools, Bagisto is the perfect choice for businesses looking to establish a strong online presence, drive sales growth, and deliver exceptional customer experiences. [Upgrade Guide](https://devdocs.bagisto.com/2.3/prologue/upgrade-guide.html) ## Bagisto Theme Development This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/themes/#themes) Themes If you are looking to customize the appearance and design of your Bagisto e-commerce store, creating a custom theme is the way to go. Bagisto offers a flexible and straightforward approach to theme development, allowing you to tailor the look and feel of your store to align with your brand and meet your specific requirements. ## [#](https://devdocs.bagisto.com/2.3/themes/#package-development-prerequisite) Package Development Prerequisite Before diving into theme development, it is recommended to have knowledge of creating packages in Laravel. If you are new to package development, you can refer to the [Package Development](https://devdocs.bagisto.com/2.3/packages) section for a primer on creating and managing packages in Laravel. Understanding package development concepts will greatly assist you in creating and organizing your custom theme. ## [#](https://devdocs.bagisto.com/2.3/themes/#creating-a-custom-theme) Creating a Custom Theme Creating a custom theme for Bagisto involves a few simple steps. Here's an overview of the process: 1. **Create a Package**: As themes in Bagisto are treated as packages, the first step is to create a new package specifically for your theme. This package will serve as the container for your theme files and configuration. 2. **Configure the Package**: Once the package is created, you need to configure it by defining the necessary details, such as the package name, author, description, and other relevant information. This configuration ensures that Bagisto recognizes your package as a theme. 3. **Define the Theme Assets**: In Bagisto, themes are primarily composed of assets such as CSS stylesheets, JavaScript files, and image files. You will need to create the appropriate directories within your theme package to store these assets. 4. **Create Blade Views**: Blade views are the templates used to render the frontend of your store. You can create your own custom views within your theme package, allowing you to customize the appearance of different pages and components. 5. **Configure Theme Layout**: Bagisto provides a layout system that defines the structure and organization of your store's pages. You can configure the layout for your theme by specifying the positions of various components, such as the header, footer, sidebar, and content sections. 6. **Customize Theme Styles**: To achieve a unique and visually appealing design, you can customize the CSS stylesheets of your theme. This includes modifying colors, typography, spacing, and other visual elements to match your branding and aesthetic preferences. 7. **Activate and Test the Theme**: Once your custom theme is ready, you can activate it in the Bagisto admin panel. This will make your theme the active theme for your store, reflecting the changes and customizations you have made. It is crucial to thoroughly test your theme to ensure its compatibility and responsiveness across different devices and browsers. By following these steps, you can create a fully customized theme for your Bagisto e-commerce store. This empowers you to create a unique and engaging shopping experience for your customers, aligning with your brand identity and enhancing your online presence. [Data Transfer](https://devdocs.bagisto.com/2.3/advanced/create-data-import.html)[Store Theme](https://devdocs.bagisto.com/2.3/themes/create-store-theme.html) ## Bagisto E-Commerce Docs Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.x/introduction/#introduction) Introduction ## [#](https://devdocs.bagisto.com/2.x/introduction/#bagisto-a-powerful-open-source-e-commerce-platform) Bagisto: A Powerful Open-Source E-Commerce Platform Bagisto is a popular open-source e-commerce platform built on the combination of the Laravel PHP framework, Vue.js, and the stylish Tailwind CSS framework. It provides a comprehensive set of tools and features to help developers and businesses create and manage their online stores effectively. With its flexible and adaptable nature, Bagisto has gained recognition and support from a growing community of users, as evidenced by its impressive 12.4K+ stars on [GitHub(opens new window)](https://github.com/bagisto/bagisto). ## [#](https://devdocs.bagisto.com/2.x/introduction/#key-features-of-bagisto) Key Features of Bagisto Bagisto comes with a rich set of features that empower developers and businesses to create and manage their online stores effectively: ### [#](https://devdocs.bagisto.com/2.x/introduction/#modular-design) Modular Design Bagisto adopts a modular design approach, providing developers with the flexibility to customize and extend the platform's functionalities to meet specific business requirements. It allows you to tailor your e-commerce store precisely to your needs. ### [#](https://devdocs.bagisto.com/2.x/introduction/#multi-channel-and-multi-vendor-support) Multi-Channel and Multi-Vendor Support With Bagisto, you can easily create and manage multiple sales channels, enabling you to expand your reach and cater to different customer segments. It also supports multi-vendor functionality, allowing various vendors to sell their products on your platform. ### [#](https://devdocs.bagisto.com/2.x/introduction/#multi-locals-and-currencies-support-in-installer) Multi-Locals and Currencies Support in Installer With Bagisto, you can now effortlessly install your application in multiple locales during the installation process. It also supports the functionality of multiple currencies during installation. By offering such flexibility during installation, applications extend their usability to a wider audience, fostering a more user-centric and globally accessible application ecosystem. ### [#](https://devdocs.bagisto.com/2.x/introduction/#responsive-and-mobile-friendly) Responsive and Mobile-Friendly Bagisto ensures that your online store looks great and performs flawlessly across different devices, including mobile phones and tablets. With a responsive design, you can provide a seamless shopping experience to your customers, no matter the device they use. ### [#](https://devdocs.bagisto.com/2.x/introduction/#efficient-inventory-management) Efficient Inventory Management Bagisto simplifies inventory management by providing tools to effectively track stock levels, set low inventory alerts, and streamline order fulfillment processes. You can efficiently manage your product inventory and ensure a smooth flow of operations. ### [#](https://devdocs.bagisto.com/2.x/introduction/#secure-payment-gateways-and-shipping-methods) Secure Payment Gateways and Shipping Methods Integrating popular payment gateways and shipping methods is effortless with Bagisto. It offers seamless integration options to ensure secure and convenient transactions for your customers, making the checkout process a breeze. ### [#](https://devdocs.bagisto.com/2.x/introduction/#search-engine-optimization-seo-capabilities) Search Engine Optimization (SEO) Capabilities Bagisto equips you with built-in features to optimize your online store for search engines. You can customize meta tags, URLs, and keywords to improve your store's visibility and attract more organic traffic. ## [#](https://devdocs.bagisto.com/2.x/introduction/#community-and-support) Community and Support Bagisto has a vibrant and supportive community of developers and users who actively contribute to its growth and improvement. - **Explore Bagisto**: Visit our website at [https://bagisto.com(opens new window)](https://bagisto.com/) to discover more about Bagisto's features and experience a demo. - **Stay Updated**: Refer to the [Bagisto roadmap(opens new window)](https://bagisto.com/roadmap) for the latest version and recently added features. - **GitHub Repository**: Access the Bagisto repository on [GitHub(opens new window)](https://github.com/bagisto/bagisto) with over 12.4K+ stars, reflecting its popularity and community support. Join the Bagisto community today and build and manage your online store with ease. [Contribution Guide](https://devdocs.bagisto.com/2.x/prologue/contribution-guide.html)[Requirements](https://devdocs.bagisto.com/2.x/introduction/requirements.html) ## Bagisto Documentation Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/prologue/#prologue) Prologue ## [#](https://devdocs.bagisto.com/2.2/prologue/#introduction-to-bagisto) Introduction to Bagisto [Bagisto(opens new window)](https://bagisto.com/) is a fantastic open-source eCommerce platform that allows businesses to create modern online stores easily. Bagisto offers a wide range of customizable features to meet the specific needs of any online business. The platform is built on top of the reliable [Laravel(opens new window)](https://laravel.com/) framework , [Tailwind CSS(opens new window)](https://tailwindcss.com/) and [Vue.js(opens new window)](https://vuejs.org/), a user-friendly JavaScript framework. It provides businesses with a user-friendly interface and powerful tools to manage their online stores, handle inventory and orders, and create a smooth shopping experience for customers. ## [#](https://devdocs.bagisto.com/2.2/prologue/#customization-and-branding) Customization and Branding With Bagisto, businesses have the flexibility to customize the look and feel of their online stores, from choosing themes and layouts to adding unique branding elements. The platform offers a comprehensive set of marketing and promotional tools, enabling businesses to attract customers and drive sales effectively. ## [#](https://devdocs.bagisto.com/2.2/prologue/#seo-optimization) SEO Optimization One of Bagisto's standout features is its robust SEO capabilities. It includes built-in SEO tools and optimization options, empowering businesses to improve their search engine rankings and increase organic traffic to their online stores. ## [#](https://devdocs.bagisto.com/2.2/prologue/#payment-and-shipping-integration) Payment and Shipping Integration Moreover, Bagisto supports a wide range of payment gateways, allowing businesses to offer convenient and secure payment options to their customers. It also integrates seamlessly with popular shipping providers, streamlining the order fulfillment process and ensuring reliable and timely deliveries. ## [#](https://devdocs.bagisto.com/2.2/prologue/#summary) Summary In summary, Bagisto is a powerful and flexible eCommerce platform that empowers businesses to build and manage online stores efficiently. With its customizable features, user-friendly interface, reliable framework, robust SEO capabilities, and comprehensive set of tools, Bagisto is the perfect choice for businesses looking to establish a strong online presence, drive sales growth, and deliver exceptional customer experiences. [Upgrade Guide](https://devdocs.bagisto.com/2.2/prologue/upgrade-guide.html) ## Bagisto API Documentation Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/api/#bagisto-web-apis) Bagisto Web APIs Bagisto Web API is a medium to use the features of the core Bagisto System. By using Bagisto Web API, you can integrate your application to serve the default content of Bagisto. ## [#](https://devdocs.bagisto.com/1.x/api/#key-features) Key Features - Bagisto APIs supports REST (Representational State Transfer). - Authentication: Customer Authentication with Login Details. - Provide access to performed CRUD operations. - Also Provide the option to filter the responses based on attribute fields. - The Framework supports the pagination which helps to increase the performance of application. ## [#](https://devdocs.bagisto.com/1.x/api/#where-can-i-use-bagisto-web-apis) Where can I use Bagisto Web APIs? We can use the Bagisto APIs in different areas. Some of them are: - To build a PWA (Progressive Web Application) application, which uses modern web capabilities to deliver an application like experience to the users and provide more user friendly experience than a web application. - Use to integrate an Online-Shopping Mobile Application with the Bagisto Store to help the customers make purchase. - Use to integrate with CRM (Customer Relationship Management) systems Like: HubSpot, Salesforce etc. which allows you to manage the business relationships with your customers to help you grow your business. ## Bagisto E-Commerce Docs Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/introduction/#introduction) Introduction ## [#](https://devdocs.bagisto.com/2.2/introduction/#bagisto-a-powerful-open-source-e-commerce-platform) Bagisto: A Powerful Open-Source E-Commerce Platform Bagisto is a popular open-source e-commerce platform built on the combination of the Laravel PHP framework, Vue.js, and the stylish Tailwind CSS framework. It provides a comprehensive set of tools and features to help developers and businesses create and manage their online stores effectively. With its flexible and adaptable nature, Bagisto has gained recognition and support from a growing community of users, as evidenced by its impressive 12.6K+ stars on [GitHub(opens new window)](https://github.com/bagisto/bagisto). ## [#](https://devdocs.bagisto.com/2.2/introduction/#key-features-of-bagisto) Key Features of Bagisto Bagisto comes with a rich set of features that empower developers and businesses to create and manage their online stores effectively: ### [#](https://devdocs.bagisto.com/2.2/introduction/#modular-design) Modular Design Bagisto adopts a modular design approach, providing developers with the flexibility to customize and extend the platform's functionalities to meet specific business requirements. It allows you to tailor your e-commerce store precisely to your needs. ### [#](https://devdocs.bagisto.com/2.2/introduction/#multi-channel-and-multi-vendor-support) Multi-Channel and Multi-Vendor Support With Bagisto, you can easily create and manage multiple sales channels, enabling you to expand your reach and cater to different customer segments. It also supports multi-vendor functionality, allowing various vendors to sell their products on your platform. ### [#](https://devdocs.bagisto.com/2.2/introduction/#multi-locals-and-currencies-support-in-installer) Multi-Locals and Currencies Support in Installer With Bagisto, you can now effortlessly install your application in multiple locales during the installation process. It also supports the functionality of multiple currencies during installation. By offering such flexibility during installation, applications extend their usability to a wider audience, fostering a more user-centric and globally accessible application ecosystem. ### [#](https://devdocs.bagisto.com/2.2/introduction/#responsive-and-mobile-friendly) Responsive and Mobile-Friendly Bagisto ensures that your online store looks great and performs flawlessly across different devices, including mobile phones and tablets. With a responsive design, you can provide a seamless shopping experience to your customers, no matter the device they use. ### [#](https://devdocs.bagisto.com/2.2/introduction/#efficient-inventory-management) Efficient Inventory Management Bagisto simplifies inventory management by providing tools to effectively track stock levels, set low inventory alerts, and streamline order fulfillment processes. You can efficiently manage your product inventory and ensure a smooth flow of operations. ### [#](https://devdocs.bagisto.com/2.2/introduction/#secure-payment-gateways-and-shipping-methods) Secure Payment Gateways and Shipping Methods Integrating popular payment gateways and shipping methods is effortless with Bagisto. It offers seamless integration options to ensure secure and convenient transactions for your customers, making the checkout process a breeze. ### [#](https://devdocs.bagisto.com/2.2/introduction/#search-engine-optimization-seo-capabilities) Search Engine Optimization (SEO) Capabilities Bagisto equips you with built-in features to optimize your online store for search engines. You can customize meta tags, URLs, and keywords to improve your store's visibility and attract more organic traffic. ## [#](https://devdocs.bagisto.com/2.2/introduction/#community-and-support) Community and Support Bagisto has a vibrant and supportive community of developers and users who actively contribute to its growth and improvement. - **Explore Bagisto**: Visit our website at [https://bagisto.com(opens new window)](https://bagisto.com/) to discover more about Bagisto's features and experience a demo. - **Stay Updated**: Refer to the [Bagisto roadmap(opens new window)](https://bagisto.com/roadmap) for the latest version and recently added features. - **GitHub Repository**: Access the Bagisto repository on [GitHub(opens new window)](https://github.com/bagisto/bagisto) with over 12.6K+ stars, reflecting its popularity and community support. Join the Bagisto community today and build and manage your online store with ease. [Contribution Guide](https://devdocs.bagisto.com/2.2/prologue/contribution-guide.html)[Requirements](https://devdocs.bagisto.com/2.2/introduction/requirements.html) ## Bagisto API Documentation Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.x/api/#bagisto-apis) Bagisto APIs - [REST API](https://devdocs.bagisto.com/2.x/api/#rest-api) ## [#](https://devdocs.bagisto.com/2.x/api/#rest-api) REST API The Bagisto REST API supports REST (Representational State Transfer) and provides access to CRUD (Create, Read, Update, Delete) operations. It also supports pagination to increase the performance of the application. The Bagisto REST API can be used to build a PWA (Progressive Web Application) application, integrate an online shopping mobile application with the Bagisto store. [Admin Theme](https://devdocs.bagisto.com/2.x/themes/create-admin-theme.html)[Rest API](https://devdocs.bagisto.com/2.x/api/getting-started-with-the-api.html) ## Bagisto API Documentation This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/api/#bagisto-apis) Bagisto APIs - [REST API](https://devdocs.bagisto.com/2.3/api/#rest-api) ## [#](https://devdocs.bagisto.com/2.3/api/#rest-api) REST API The Bagisto REST API supports REST (Representational State Transfer) and provides access to CRUD (Create, Read, Update, Delete) operations. It also supports pagination to increase the performance of the application. The Bagisto REST API can be used to build a PWA (Progressive Web Application) application, integrate an online shopping mobile application with the Bagisto store. [Load Balancing](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html)[Rest API](https://devdocs.bagisto.com/2.3/api/getting-started-with-the-api.html) ## Bagisto API Docs Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/api/#bagisto-apis) Bagisto APIs - [REST API](https://devdocs.bagisto.com/2.2/api/#rest-api) - [GraphQL API](https://devdocs.bagisto.com/2.2/api/#graphql-api) ## [#](https://devdocs.bagisto.com/2.2/api/#rest-api) REST API The Bagisto REST API supports REST (Representational State Transfer) and provides access to CRUD (Create, Read, Update, Delete) operations. It also supports pagination to increase the performance of the application. The Bagisto REST API can be used to build a PWA (Progressive Web Application) application, integrate an online shopping mobile application with the Bagisto store. ## [#](https://devdocs.bagisto.com/2.2/api/#graphql-api) GraphQL API Bagisto's GraphQL API enables a seamless, headless eCommerce experience built on Laravel. This API delivers ultra-fast, dynamic, and personalized shopping experiences through a scalable, open-source platform. [Load Balancing](https://devdocs.bagisto.com/2.2/performance/loadbalancing.html)[Rest API](https://devdocs.bagisto.com/2.2/api/getting-started-with-the-api.html) ## Bagisto Themes Guide Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/themes/#themes) Themes We hope that now you know how to create a package, if not then you may refer to [Package Development](https://devdocs.bagisto.com/1.x/packages) section. Creating a custom theme for Bagisto had been a hot topic lately. More and more users are actively trying our framework and we’re genuinely overwhelmed by it. Creating a custom theme for Bagisto is super easy with just a few lines of configuration code. Similarly following the traditional way of creating view files in Laravel would be enough. [Best Security Practices](https://devdocs.bagisto.com/1.x/advanced/security-practice.html)[Blade file tracer](https://devdocs.bagisto.com/1.x/themes/tracer.html) ## Bagisto Deployment Guide Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.x/deploy/#deploy) Deploy this article will explain how you can deploy your Bagisto store to your production server when you have been developing your Bagisto store on your local system. ## [#](https://devdocs.bagisto.com/2.x/deploy/#deploy-bagisto-with-s-ftp) Deploy Bagisto with (S)FTP ## [#](https://devdocs.bagisto.com/2.x/deploy/#deploy-on-cpanel) Deploy on Cpanel ## [#](https://devdocs.bagisto.com/2.x/deploy/#deploy-on-plesk) Deploy on Plesk ## Bagisto Admin Themes Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/admin-theme/#themes) Themes We hope that now you know how to create a package, if not then you may refer to [Package Development](https://devdocs.bagisto.com/1.x/packages) section. Creating a custom admin theme for Bagisto had been a hot topic lately. More and more users are actively trying our framework and we’re genuinely overwhelmed by it. Creating a custom admin theme for Bagisto is super easy with just a few lines of configuration code. Similarly following the traditional way of creating view files in Laravel would be enough. [Best Security Practices](https://devdocs.bagisto.com/1.x/advanced/security-practice.html)[Blade file tracer](https://devdocs.bagisto.com/1.x/themes/tracer.html) ## Laravel Sail Overview WARNING: You're browsing the documentation for an upcoming version. Features of this release are subject to change. # [#](https://devdocs.bagisto.com/master/introduction/sail.html#sail) Sail - [Introduction](https://devdocs.bagisto.com/master/introduction/sail.html#introduction) - [Installing Dependencies](https://devdocs.bagisto.com/master/introduction/sail.html#installing-dependencies) - [Available Services](https://devdocs.bagisto.com/master/introduction/sail.html#available-services) - [Environment Configuration](https://devdocs.bagisto.com/master/introduction/sail.html#environment-configuration) - [MySQL Configuration](https://devdocs.bagisto.com/master/introduction/sail.html#mysql-configuration) - [Redis Configuration](https://devdocs.bagisto.com/master/introduction/sail.html#redis-configuration) - [MailPit Configuration](https://devdocs.bagisto.com/master/introduction/sail.html#mailpit-configuration) - [Elasticsearch Configuration](https://devdocs.bagisto.com/master/introduction/sail.html#elasticsearch-configuration) - [Building and Running Containers](https://devdocs.bagisto.com/master/introduction/sail.html#building-and-running-containers) - [Installing Bagisto](https://devdocs.bagisto.com/master/introduction/sail.html#installing-bagisto) ## [#](https://devdocs.bagisto.com/master/introduction/sail.html#introduction) Introduction [Laravel Sail(opens new window)](https://laravel.com/docs/11.x/sail) is a lightweight CLI tool that simplifies the setup and management of Laravel's Docker development environment. It provides pre-configured Docker containers for services like PHP, MySQL, Redis, and Mailhog, allowing developers to quickly create a local environment for Laravel applications without manual configuration. Sail supports multiple PHP versions and is ideal for consistent and isolated local development, making it easier to run and manage Laravel-based projects, including Bagisto. ## [#](https://devdocs.bagisto.com/master/introduction/sail.html#installing-dependencies) Installing Dependencies To install Composer dependencies on a fresh clone of your project, the default PHP version is 8.3. However, you may switch to a Bagisto-supported PHP version by using one of the following: - `laravelsail/php81-composer:latest` - `laravelsail/php82-composer:latest` - `laravelsail/php83-composer:latest` When changing the PHP version, remember to update the Dockerfile context in the `docker-compose` file accordingly. For more details, refer to the [Laravel Sail documentation on PHP versions(opens new window)](https://laravel.com/docs/11.x/sail#sail-php-versions). ``` docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ laravelsail/php83-composer:latest \ composer require laravel/sail --dev --ignore-platform-reqs ``` If you are working on an existing project with a dependency manager installed, you can easily set up Laravel Sail by running the following command: ``` composer require laravel/sail --dev ``` ## [#](https://devdocs.bagisto.com/master/introduction/sail.html#available-services) Available Services The docker-compose file includes the following services for Bagisto: - Laravel - MySQL - Redis - Elasticsearch - Kibana - MailPit For detailed information about these services, please refer to the [Laravel Sail Documentation(opens new window)](https://laravel.com/docs/11.x/sail#introduction). ## [#](https://devdocs.bagisto.com/master/introduction/sail.html#environment-configuration) Environment Configuration Before starting Bagisto, you'll need to configure the following services in your `.env` file: ### [#](https://devdocs.bagisto.com/master/introduction/sail.html#mysql-configuration) MySQL Configuration These credentials will be used to create the database when the container starts for the first time: ``` DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=bagisto DB_USERNAME=sail DB_PASSWORD=password DB_PREFIX= ``` ### [#](https://devdocs.bagisto.com/master/introduction/sail.html#redis-configuration) Redis Configuration ``` REDIS_HOST=redis REDIS_PASSWORD=null REDIS_PORT=6379 ``` ### [#](https://devdocs.bagisto.com/master/introduction/sail.html#mailpit-configuration) MailPit Configuration ``` MAIL_MAILER=smtp MAIL_HOST=mailpit MAIL_PORT=1025 MAIL_USERNAME= MAIL_PASSWORD= MAIL_ENCRYPTION=tls ``` ### [#](https://devdocs.bagisto.com/master/introduction/sail.html#elasticsearch-configuration) Elasticsearch Configuration ``` ELASTICSEARCH_HOST=http://elasticsearch:9200 ``` ## [#](https://devdocs.bagisto.com/master/introduction/sail.html#building-and-running-containers) Building and Running Containers 1. Build the container (use `--no-cache` for a fresh build): ``` vendor/bin/sail build --no-cache ``` 2. Start the containers in detached mode: ``` vendor/bin/sail up -d ``` ## [#](https://devdocs.bagisto.com/master/introduction/sail.html#installing-bagisto) Installing Bagisto If this is your first time running the container, you'll need to install Bagisto: ``` vendor/bin/sail artisan bagisto:install ``` During the installation process, you'll be prompted for various credentials. The system will suggest default values based on your `.env` file configurations. For consistency, it's recommended to use the same credentials you specified in your `.env` file, even though this may seem redundant. Because some environment variables are used to create services (like MySQL), and we are now reconnecting with the following credentials. [Docker](https://devdocs.bagisto.com/master/introduction/docker.html)[Architecture concepts](https://devdocs.bagisto.com/master/architecture) ## Bagisto Installation Requirements WARNING: You're browsing the documentation for an upcoming version. Features of this release are subject to change. # [#](https://devdocs.bagisto.com/master/introduction/requirements.html#requirements) Requirements - [Server Configuration](https://devdocs.bagisto.com/master/introduction/requirements.html#server-configuration) - [PHP Extensions](https://devdocs.bagisto.com/master/introduction/requirements.html#php-extensions) - [PHP Configuration](https://devdocs.bagisto.com/master/introduction/requirements.html#php-configuration) - [Apache Configuration](https://devdocs.bagisto.com/master/introduction/requirements.html#apache-configuration) - [Nginx Configuration](https://devdocs.bagisto.com/master/introduction/requirements.html#nginx-configuration) - [Supported Database Servers](https://devdocs.bagisto.com/master/introduction/requirements.html#supported-database-servers) ## [#](https://devdocs.bagisto.com/master/introduction/requirements.html#server-configuration) Server Configuration - **Server**: Apache 2 or NGINX - **RAM**: 4GB or higher - **Node**: 23.10.0 LTS or higher - **PHP**: 8.2 or higher - **Composer**: 2.5 or higher ## [#](https://devdocs.bagisto.com/master/introduction/requirements.html#php-extensions) PHP Extensions Ensure the following extensions are installed and enabled. You can check using the **`phpinfo()`** page or the **`php -m`** command. - **php-intl extension**: This extension is required for internationalization support in Bagisto. - **php-gd extension**: The **`php-gd`** extension must be properly installed to ensure correct image functionality in the project. If not installed correctly, image-related features may not work as expected. Note It is important to ensure proper installation of the **`php-gd`** extension to avoid any issues with image manipulation in Bagisto. ## [#](https://devdocs.bagisto.com/master/introduction/requirements.html#php-configuration) PHP Configuration Open your **`php.ini`** file and modify the following settings. - **memory_limit**: Set the **`memory_limit`** directive to **`4G`** or higher to ensure sufficient memory allocation for the application. - **max_execution_time**: Adjust the **`max_execution_time`** directive to **`360`** or higher. This value determines the maximum time (in seconds) a script is allowed to run. Increasing this value ensures that longer operations, such as import/export processes, can be completed successfully. - **date.timezone**: Set the **`date.timezone`** directive to your specific timezone. For example, **`Asia/Kolkata`**. This ensures that date and time-related functions work accurately based on the specified timezone. ``` memory_limit = 4G max_execution_time = 360 date.timezone = Asia/Kolkata <- Change this to your own timezone. ``` Remember to restart your web server Whenever you make changes to the PHP configuration file, be sure to restart Apache or NGINX to apply the modifications. ## [#](https://devdocs.bagisto.com/master/introduction/requirements.html#apache-configuration) Apache Configuration To serve Bagisto using Apache, make sure your virtual host is properly configured. Below is a basic `VirtualHost` example suitable for local development: ``` ServerAdmin webmaster@localhost DocumentRoot /var/www/html/bagisto/public Options Indexes FollowSymLinks AllowOverride All Require all granted ``` Note Ensure `DocumentRoot` points to the `public` directory of your Bagisto installation. `AllowOverride All` is essential for Laravel’s `.htaccess` to function correctly. ## [#](https://devdocs.bagisto.com/master/introduction/requirements.html#nginx-configuration) Nginx Configuration If you are deploying your Bagisto application to a server that is running Nginx, you may use the following configuration file as a starting point for configuring your web server. Most likely, this file will need to be customized depending on your server's configuration. Please ensure, like the configuration below, your web server directs all requests to your application's `public/index.php` file. You should never attempt to move the `index.php` file to your project's root, as serving the application from the project root will expose many sensitive configuration files to the public Internet: ``` server { listen 80; listen [::]:80; server_name example.com; root /srv/example.com/public; add_header X-Frame-Options "SAMEORIGIN"; add_header X-Content-Type-Options "nosniff"; index index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location ~* ^\/(?!cache).*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|webp|woff|woff2)$ { expires max; access_log off; add_header Cache-Control "public"; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ ^/index\.php(/|$) { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; fastcgi_hide_header X-Powered-By; } location ~ /\.(?!well-known).* { deny all; } } ``` ## [#](https://devdocs.bagisto.com/master/introduction/requirements.html#supported-database-servers) Supported Database Servers Bagisto supports the following database servers: - **MySQL**: Version 8.0.32 or higher is recommended for optimal performance and compatibility. - **Database Collation**: The recommended collation for the database is **`utf8mb4_unicode_ci`**, which ensures proper handling of Unicode characters and multilingual support. [Introduction](https://devdocs.bagisto.com/master/introduction)[Installation](https://devdocs.bagisto.com/master/introduction/installation.html) ## Bagisto Docker Setup WARNING: You're browsing the documentation for an upcoming version. Features of this release are subject to change. # [#](https://devdocs.bagisto.com/master/introduction/docker.html#docker) Docker - [Introduction](https://devdocs.bagisto.com/master/introduction/docker.html#introduction) - [Docker Setup for Bagisto](https://devdocs.bagisto.com/master/introduction/docker.html#docker-setup-for-bagisto) - [1\. Using Bagisto Docker Image from Docker Hub](https://devdocs.bagisto.com/master/introduction/docker.html#_1-using-bagisto-docker-image-from-docker-hub) - [2\. Using Bagisto GitHub Docker Repository](https://devdocs.bagisto.com/master/introduction/docker.html#_2-using-bagisto-github-docker-repository) ## [#](https://devdocs.bagisto.com/master/introduction/docker.html#introduction) Introduction [Docker(opens new window)](https://www.docker.com/) is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. Docker can also be used for defining and running multi-container Docker applications using the Docker Compose tool. With the help of Docker Compose, you can define containers to be built, their configuration, links, volumes, ports, etc., in a single file, and it gets launched by a single command. You can also add multiple servers and services just by adding them to the Docker Compose configuration file. This configuration file is in [YAML(opens new window)](https://en.wikipedia.org/wiki/YAML) format. #### [#](https://devdocs.bagisto.com/master/introduction/docker.html#application-data-and-database-volume-persistence) Application Data and Database Volume Persistence It is recommended to keep your application files and database data volume on the Docker host and mount them on the running container. This ensures that the application and database data persistence even in the case of containers' failure or termination. In this way, even if you destroy containers, your data won't get lost unless you remove them forcefully. This compose configuration file mounts the application directory **`app`** and database volume **`dbvolume`** from the host to running Docker containers at the time of containers' launch. ### [#](https://devdocs.bagisto.com/master/introduction/docker.html#docker-setup-for-bagisto) Docker Setup for Bagisto You can configure Bagisto using Docker in two different ways: 1. **Using Bagisto Docker Image from Docker Hub** 2. **Using Bagisto GitHub Docker Repository** Both approaches allow you to set up the application quickly, managing all system requirements like Apache, MySQL, and PHPMyAdmin within isolated containers. Below is a detailed guide for each method. ### [#](https://devdocs.bagisto.com/master/introduction/docker.html#_1-using-bagisto-docker-image-from-docker-hub) 1\. **Using Bagisto Docker Image from Docker Hub** Follow the steps below to set up Bagisto using Docker Hub. This approach provides a pre-configured Docker image of Bagisto, allowing for a quick and easy installation. #### [#](https://devdocs.bagisto.com/master/introduction/docker.html#step-1-pull-bagisto-docker-image) Step 1: Pull Bagisto Docker Image To pull the Bagisto Docker image from Docker Hub, use the following command: ``` docker pull webkul/bagisto:2.3.0 ``` #### [#](https://devdocs.bagisto.com/master/introduction/docker.html#step-2-run-a-new-container) Step 2: Run a New Container Once the image is pulled, you can run a new Docker container using the command below. This will bind your local port 80 to the container’s port 80, so Bagisto can be accessed via the browser. ``` docker run -it -d -p 80:80 webkul/bagisto:2.3.0 ``` > **Note:** > If port 80 is already in use, you can try using a different port. For example, you can map port 8082 on your local machine to port 80 in the container by running the following command: > > ``` > docker run -it -d -p 8082:80 webkul/bagisto:2.3.0 > > ``` > > After this, you can access the application at `http://localhost:8082/` instead of `http://localhost:80`. #### [#](https://devdocs.bagisto.com/master/introduction/docker.html#step-3-access-bagisto-in-your-browser) Step 3: Access Bagisto in Your Browser After the container is up and running, open your browser and navigate to `http://localhost`. This will load the Bagisto setup. #### [#](https://devdocs.bagisto.com/master/introduction/docker.html#step-4-admin-login-credentials) Step 4: Admin Login Credentials Use the following credentials to log in to the Bagisto admin panel: - **Admin Username**: `admin@example.com` - **Admin Password**: `admin123` ### [#](https://devdocs.bagisto.com/master/introduction/docker.html#_2-using-bagisto-github-docker-repository) 2\. **Using Bagisto GitHub Docker Repository** #### [#](https://devdocs.bagisto.com/master/introduction/docker.html#system-requirements) System Requirements The Bagisto GitHub Docker repository automatically handles the system requirements for running Bagisto, including the necessary Apache and MySQL configurations. Before proceeding, ensure that you have the latest version of **Docker** and **Docker Compose** installed. You can find installation instructions for your operating system at the following links: - [Docker Installation Guide(opens new window)](https://docs.docker.com/install/) - [Docker Compose Installation Guide(opens new window)](https://docs.docker.com/compose/install/) #### [#](https://devdocs.bagisto.com/master/introduction/docker.html#docker-configuration) Docker Configuration 1. **Adjust Ports and Paths** Open the `docker-compose.yml` file and configure the ports for Apache, MySQL, and PHPMyAdmin. You can also specify the volumes and MySQL credentials. Here's an example configuration: ``` version: '3.1' services: bagisto-php-apache: build: args: container_project_path: /var/www/html/ uid: 1000 # Add your UID user: $USER context: . dockerfile: ./Dockerfile image: bagisto-php-apache ports: - 80:80 # Adjust Apache port volumes: - ./workspace/:/var/www/html/ bagisto-mysql: image: mysql:8.0 command: --default-authentication-plugin=mysql_native_password restart: always environment: MYSQL_ROOT_HOST: '%' MYSQL_ROOT_PASSWORD: root ports: - 3306:3306 # Adjust MySQL port volumes: - ./.configs/mysql-data:/var/lib/mysql/ bagisto-phpmyadmin: image: phpmyadmin:latest restart: always environment: PMA_HOST: bagisto-mysql PMA_USER: root PMA_PASSWORD: root ports: - 8080:80 # Adjust PHPMyAdmin port volumes: mysql-data: ``` 2. **Running the Setup** After adjusting the configurations, execute the following command to start the Docker containers: ``` sh setup.sh ``` #### [#](https://devdocs.bagisto.com/master/introduction/docker.html#accessing-bagisto) Accessing Bagisto - **Admin Panel** Access the admin panel at: `http(s)://your_server_endpoint/admin/login` Use the default credentials: - **Email**: `admin@example.com` - **Password**: `admin123` - **Customer Registration** Register and log in as a customer at: `http(s)://your_server_endpoint/customer/register` [Installation](https://devdocs.bagisto.com/master/introduction/installation.html)[Sail](https://devdocs.bagisto.com/master/introduction/sail.html) ## Bagisto Documentation Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.5.x/introduction/#introduction) Introduction ## [#](https://devdocs.bagisto.com/1.5.x/introduction/#bagisto-a-powerful-open-source-e-commerce-platform) Bagisto: A Powerful Open-Source E-Commerce Platform Bagisto is a popular open-source e-commerce platform built on the combination of Laravel PHP framework and Vue.js. It provides a comprehensive set of tools and features to help developers and businesses create and manage their online stores effectively. With its flexible and adaptable nature, Bagisto has gained recognition and support from a growing community of users, as evidenced by its impressive 6K+ stars on [GitHub(opens new window)](https://github.com/bagisto/bagisto). ## [#](https://devdocs.bagisto.com/1.5.x/introduction/#key-features-of-bagisto) Key Features of Bagisto Bagisto comes with a rich set of features that empower developers and businesses to create and manage their online stores effectively: ### [#](https://devdocs.bagisto.com/1.5.x/introduction/#modular-design) Modular Design Bagisto adopts a modular design approach, providing developers with the flexibility to customize and extend the platform's functionalities to meet specific business requirements. It allows you to tailor your e-commerce store precisely to your needs. ### [#](https://devdocs.bagisto.com/1.5.x/introduction/#multi-channel-and-multi-vendor-support) Multi-Channel and Multi-Vendor Support With Bagisto, you can easily create and manage multiple sales channels, enabling you to expand your reach and cater to different customer segments. It also supports multi-vendor functionality, allowing various vendors to sell their products on your platform. ### [#](https://devdocs.bagisto.com/1.5.x/introduction/#responsive-and-mobile-friendly) Responsive and Mobile-Friendly Bagisto ensures that your online store looks great and performs flawlessly across different devices, including mobile phones and tablets. With a responsive design, you can provide a seamless shopping experience to your customers, no matter the device they use. ### [#](https://devdocs.bagisto.com/1.5.x/introduction/#efficient-inventory-management) Efficient Inventory Management Bagisto simplifies inventory management by providing tools to effectively track stock levels, set low inventory alerts, and streamline order fulfillment processes. You can efficiently manage your product inventory and ensure a smooth flow of operations. ### [#](https://devdocs.bagisto.com/1.5.x/introduction/#secure-payment-gateways-and-shipping-methods) Secure Payment Gateways and Shipping Methods Integrating popular payment gateways and shipping methods is effortless with Bagisto. It offers seamless integration options to ensure secure and convenient transactions for your customers, making the checkout process a breeze. ### [#](https://devdocs.bagisto.com/1.5.x/introduction/#search-engine-optimization-seo-capabilities) Search Engine Optimization (SEO) Capabilities Bagisto equips you with built-in features to optimize your online store for search engines. You can customize meta tags, URLs, and keywords to improve your store's visibility and attract more organic traffic. ## [#](https://devdocs.bagisto.com/1.5.x/introduction/#community-and-support) Community and Support Bagisto has a vibrant and supportive community of developers and users who actively contribute to its growth and improvement. - **Explore Bagisto**: Visit our website at [https://bagisto.com(opens new window)](https://bagisto.com/) to discover more about Bagisto's features and experience a demo. - **Stay Updated**: Refer to the [Bagisto roadmap(opens new window)](https://bagisto.com/roadmap) for the latest version and recently added features. - **GitHub Repository**: Access the Bagisto repository on [GitHub(opens new window)](https://github.com/bagisto/bagisto) with over 6K+ stars, reflecting its popularity and community support. Join the Bagisto community today and build and manage your online store with ease. [Contribution Guide](https://devdocs.bagisto.com/1.5.x/prologue/contribution-guide.html)[Requirements](https://devdocs.bagisto.com/1.5.x/introduction/requirements.html) ## Bagisto GraphQL API Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/graphql-admin-api/#bagisto-graphql-admin-apis) Bagisto GraphQL Admin APIs Bagisto GraphQL Admin API is a medium to use the features of the core Bagisto Admin System. By using Bagisto GraphQL Admin API, you can integrate your application to serve the default content of Bagisto. **To download and contribute: [Bagisto GraphQL API GitHub(opens new window)](https://github.com/bagisto/headless-ecommerce/)** ## [#](https://devdocs.bagisto.com/1.x/graphql-admin-api/#key-features) Key Features - Bagisto GraphQL API provides a complete and understandable description of the data. - Authentication: Customer Authentication with Login Details. - Authentication: Admin Authentication with Login Details. - Provide access to performed CRUD operations. - Provide the option to filter the responses based on attribute fields. - The Framework supports the pagination which helps to increase the performance of application. - Get many resources in a single request. ## [#](https://devdocs.bagisto.com/1.x/graphql-admin-api/#request) Request - `http(s)://example.com/graphql` ## [#](https://devdocs.bagisto.com/1.x/graphql-admin-api/#where-can-i-use-bagisto-graphql-apis) Where can I use Bagisto GraphQL APIs? We can use the Bagisto GraphQL APIs in different areas. Some of them are: - To build a PWA (Progressive Web Application) application, which uses modern web capabilities to deliver an application like experience to the users and provide more user friendly experience than a web application. - Use to integrate an Online-Shopping Mobile Application with the Bagisto Store to help the customers make purchase. - Use to integrate with CRM (Customer Relationship Management) systems Like: HubSpot, Salesforce etc. which allows you to manage the business relationships with your customers to help you grow your business. - To provide exactly what you need and nothing more. - To get Predictable result. - Applications using GraphQL can be quick even on slow mobile network connections. - Applications for devices where bandwidth usage matters. ## Bagisto Requirements Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.x/introduction/requirements.html#requirements) Requirements - [Server Configuration](https://devdocs.bagisto.com/2.x/introduction/requirements.html#server-configuration) - [PHP Extensions](https://devdocs.bagisto.com/2.x/introduction/requirements.html#php-extensions) - [PHP Configuration](https://devdocs.bagisto.com/2.x/introduction/requirements.html#php-configuration) - [Apache Configuration](https://devdocs.bagisto.com/2.x/introduction/requirements.html#apache-configuration) - [Nginx Configuration](https://devdocs.bagisto.com/2.x/introduction/requirements.html#nginx-configuration) - [Supported Database Servers](https://devdocs.bagisto.com/2.x/introduction/requirements.html#supported-database-servers) ## [#](https://devdocs.bagisto.com/2.x/introduction/requirements.html#server-configuration) Server Configuration - **Server**: Apache 2 or NGINX - **RAM**: 4GB or higher - **Node**: 18.12.0 LTS or higher - **PHP**: 8.1 or higher - **Composer**: 2.5 or higher ## [#](https://devdocs.bagisto.com/2.x/introduction/requirements.html#php-extensions) PHP Extensions Ensure the following extensions are installed and enabled. You can check using the **`phpinfo()`** page or the **`php -m`** command. - **php-intl extension**: This extension is required for internationalization support in Bagisto. - **php-gd extension**: The **`php-gd`** extension must be properly installed to ensure correct image functionality in the project. If not installed correctly, image-related features may not work as expected. Note It is important to ensure proper installation of the **`php-gd`** extension to avoid any issues with image manipulation in Bagisto. ## [#](https://devdocs.bagisto.com/2.x/introduction/requirements.html#php-configuration) PHP Configuration Open your **`php.ini`** file and modify the following settings. - **memory_limit**: Set the **`memory_limit`** directive to **`4G`** or higher to ensure sufficient memory allocation for the application. - **max_execution_time**: Adjust the **`max_execution_time`** directive to **`360`** or higher. This value determines the maximum time (in seconds) a script is allowed to run. Increasing this value ensures that longer operations, such as import/export processes, can be completed successfully. - **date.timezone**: Set the **`date.timezone`** directive to your specific timezone. For example, **`Asia/Kolkata`**. This ensures that date and time-related functions work accurately based on the specified timezone. ``` memory_limit = 4G max_execution_time = 360 date.timezone = Asia/Kolkata <- Change this to your own timezone. ``` Remember to restart your web server Whenever you make changes to the PHP configuration file, be sure to restart Apache or NGINX to apply the modifications. ## [#](https://devdocs.bagisto.com/2.x/introduction/requirements.html#apache-configuration) Apache Configuration To serve Bagisto using Apache, make sure your virtual host is properly configured. Below is a basic `VirtualHost` example suitable for local development: ``` ServerAdmin webmaster@localhost DocumentRoot /var/www/html/bagisto/public Options Indexes FollowSymLinks AllowOverride All Require all granted ``` Note Ensure `DocumentRoot` points to the `public` directory of your Bagisto installation. `AllowOverride All` is essential for Laravel’s `.htaccess` to function correctly. ## [#](https://devdocs.bagisto.com/2.x/introduction/requirements.html#nginx-configuration) Nginx Configuration If you are deploying your Bagisto application to a server that is running Nginx, you may use the following configuration file as a starting point for configuring your web server. Most likely, this file will need to be customized depending on your server's configuration. Please ensure, like the configuration below, your web server directs all requests to your application's `public/index.php` file. You should never attempt to move the `index.php` file to your project's root, as serving the application from the project root will expose many sensitive configuration files to the public Internet: ``` server { listen 80; listen [::]:80; server_name example.com; root /srv/example.com/public; add_header X-Frame-Options "SAMEORIGIN"; add_header X-Content-Type-Options "nosniff"; index index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location ~* ^\/(?!cache).*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|webp|woff|woff2)$ { expires max; access_log off; add_header Cache-Control "public"; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ ^/index\.php(/|$) { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; fastcgi_hide_header X-Powered-By; } location ~ /\.(?!well-known).* { deny all; } } ``` ## [#](https://devdocs.bagisto.com/2.x/introduction/requirements.html#supported-database-servers) Supported Database Servers Bagisto supports the following database servers: - **MySQL**: Version 8.0.32 or higher is recommended for optimal performance and compatibility. - **MariaDB**: Version 10.3 or higher is recommended for optimal performance and compatibility. - **Database Collation**: The recommended collation for the database is **`utf8mb4_unicode_ci`**, which ensures proper handling of Unicode characters and multilingual support. [Introduction](https://devdocs.bagisto.com/2.x/introduction)[Installation](https://devdocs.bagisto.com/2.x/introduction/installation.html) ## Bagisto Product API Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/api/products.html#products) Products In this section, we will use the product's API. We will start with the fetching of all products. Then we will move forward to query params and filterable query params. In last, we will check the additional and variant information. ## [#](https://devdocs.bagisto.com/1.x/api/products.html#get-all-products) Get all products This request will fetch all the products based on `limit` and `page`. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `/api/products(?limit,page)` TIP If you didn't use the page(?page=x) filter, then it returns the data of the first page by default. - Params | Name | Info | Type | | ----- | -------------------------------------------- | ------ | | limit | Maximum number of records in each request | Number | | page | Records for specific page based on the limit | Number | TIP If you are using pagination and want to know more info about responses then check the [explanation](https://devdocs.bagisto.com/1.x/api/explanation) portion. ### [#](https://devdocs.bagisto.com/1.x/api/products.html#examples) Examples #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_1-get-products-for-specific-page) 1\. Get products for specific page - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `http(s)://example.com/api/products?page=1` Response ``` { "data": [\ {\ "id": 3,\ "type": "simple",\ "name": "Lenovo IdeaPad Yoga 500 15 Hybrid (2-in-1) White",\ "url_key": "lenovo-ideapad-yoga-500-15-hybrid-2-in-1-white",\ "price": "600.0000",\ "formated_price": "$600.00",\ ...\ "sku": "5626",\ "images": [\ {...}\ ],\ "base_image": {...},\ "variants": [],\ "in_stock": true,\ "reviews": {...},\ "is_saved": false,\ "created_at": "2020-09-09 03:31:47",\ "updated_at": "2020-09-09 03:31:47"\ },\ {...},\ {...}\ ], "links": {...}, "meta": {...} } ``` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_2-get-products-for-specific-page-with-limit) 2\. Get products for specific page with limit - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `http(s)://example.com/api/products?limit=2&page=1` Response ``` { "data": [\ {...},\ {...}\ ], "links": { "first": "https://example.com/api/products?page=1&limit=2", "last": "https://example.com/api/products?page=4&limit=2", "prev": null, "next": "https://example.com/api/products?page=2&limit=2" }, "meta": { "current_page": 1, "from": 1, "last_page": 4, "path": "https://example.com/api/products", "per_page": "2", // limit "to": 2, "total": 8 } } ``` ## [#](https://devdocs.bagisto.com/1.x/api/products.html#get-products-with-query-parameters) Get products with query parameters - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET /api/products(?category_id,new,featured,name,sku,url_key,limit,page)` - Params | Name | Info | Type | | ----------- | ---------------- | ------- | | category_id | Category's ID | Number | | new | New Product | Boolean | | featured | Featured Product | Boolean | | name | Name | String | | sku | SKU | String | | url_key | URL Key | String | | limit | Limit | Number | | page | Page | Number | ### [#](https://devdocs.bagisto.com/1.x/api/products.html#examples-2) Examples #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_1-if-you-want-to-get-the-store-s-products-those-are-having-new-condition-then-you-can-use-new-1-in-the-query-parameter-and-if-want-to-get-the-products-without-new-condition-then-use-new-0) 1\. If you want to get the store's products those are having new condition then you can use `new=1` in the query parameter and if want to get the products without new condition then use `new=0` - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?new=1` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_2-you-can-also-use-the-limit-and-page-query-parameters-with-the-new-query-parameter) 2\. You can also use the `limit` and `page` query parameters with the `new` query parameter - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?new=1&limit=5&page=1` `GET http(s)://example.com/api/products?new=0&limit=5&page=1` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_3-if-you-want-to-get-the-store-s-products-those-are-featured-then-you-can-use-featured-1-query-parameter) 3\. If you want to get the store's products those are featured then you can use `featured=1` query parameter - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?featured=1` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_4-you-can-also-use-the-limit-and-page-in-query-parameters-with-featured-query-parameter) 4\. You can also use the `limit` and `page` in query parameters with `featured` query parameter - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?featured=1&limit=5&page=1` `GET http(s)://example.com/api/products?featured=0&limit=5&page=1` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_5-suppose-you-want-to-find-out-the-data-of-your-product-in-the-bagisto-store-here-you-can-use-the-name-query-parameter-you-have-to-provide-the-product-name-to-the-name-query-parameter-in-the-api-url) 5\. Suppose you want to find out the data of your product in the Bagisto store, here you can use the `name` query parameter. You have to provide the product name to the `name` query parameter in the API URL - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?name='Leather Shoes'` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_6-you-can-also-get-your-product-related-details-with-the-help-of-the-product-s-sku-sku-will-be-unique-for-each-product-in-the-bagisto-store-for-this-you-have-to-use-sku-as-a-query-parameter-in-the-api-url) 6\. You can also get your product-related details with the help of the product's SKU. SKU will be unique for each product in the Bagisto store. For this, you have to use `sku` as a query parameter in the API URL - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?sku='1234'` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_7-url-key-is-a-unique-field-for-every-product-in-bagisto-store-you-can-also-find-out-product-details-by-using-url-key-for-this-you-have-to-pass-url-key-as-a-query-parameter-in-the-api-url) 7\. `url_key` is a unique field for every product in Bagisto Store. You can also find out product details by using `url_key`. For this, you have to pass `url_key` as a query parameter in the API URL - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?url_key='leather-shoes'` ## [#](https://devdocs.bagisto.com/1.x/api/products.html#get-products-with-filterable-query-parameters) Get products with filterable query parameters You can also filter your store products by using filterable attributes query parameters. These filters will only work with the `category_id` input query parameter. There are two system-defined filterable attributes in the Bagisto E-commerce framework i.e. `size` and `color`. Admin user can also create their own custom attribute and can make these custom attributes as filterable. By using these filterable attributes, customers can filter the category's products to get the desired result. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products(?category_id,size,color,price)` - Params | Name | Info | Type | | ----------- | ------------- | ------ | | category_id | Category's ID | Number | | size | Size | String | | color | Color | String | | price | Price | String | ### [#](https://devdocs.bagisto.com/1.x/api/products.html#examples-3) Examples #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_1-you-can-filter-bagisto-s-product-catalog-with-the-help-of-size-filter-size-filter-will-work-only-on-the-category-layout-you-can-pass-the-multiple-attribute-s-values-to-the-size-filterable-attributes-as-a-query-parameter-in-api-url-suppose-you-want-to-filter-men-s-t-shirt-with-medium-and-large-size-then-you-can-pass-the-id-of-both-medium-large) 1\. You can filter Bagisto's product catalog with the help of `size` filter. `size` filter will work only on the category layout. You can pass the multiple attribute's values to the `size` filterable attributes as a query parameter in API url. Suppose you want to filter men's T-Shirt with medium and large size, then you can pass the id of both medium & large - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?category_id=2&size=6,7` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_2-you-can-also-use-the-limit-and-page-in-query-parameters-with-category-size-filterable-parameters) 2\. You can also use the limit and page in query parameters with category & size filterable parameters - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?category_id=2&size=6,7&limit=10&page=1` ![Bagisto Product Size](https://devdocs.bagisto.com/assets/img/bagisto_prod_size.2fdc1d32.jpg) #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_3-you-can-also-filter-the-bagisto-product-catalog-with-the-help-of-color-filter-color-filter-will-work-only-on-the-category-layout-you-can-pass-the-multiple-attribute-s-values-to-the-color-s-filterable-attributes-as-a-query-parameter-in-api-url-suppose-you-want-to-filter-men-s-t-shirt-with-white-and-red-color-then-you-can-pass-the-id-of-both-white-red) 3\. You can also filter the Bagisto product catalog with the help of `color` filter. `color` filter will work only on the category layout. You can pass the multiple attribute's values to the color\`s filterable attributes as a query parameter in API URL. Suppose you want to filter men's T-Shirt with white and red color, then you can pass the id of both white & red - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?category_id=2&color=1,2` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_4-you-can-also-use-the-limit-and-page-in-query-parameters-with-category-color-filterable-parameters) 4\. You can also use the limit and page in query parameters with category & color filterable parameters - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?category_id=2&color=1,2&limit=10&page=1` ![Bagisto Product Color](https://devdocs.bagisto.com/assets/img/bagisto_prod_color.54846a87.jpg) #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_5-in-the-case-of-a-simple-product-you-can-set-a-range-of-a-minimum-price-and-maximum-price-same-as-size-and-color-the-price-filter-will-also-work-on-the-category-layout-only-suppose-you-want-to-filter-products-those-are-having-price-between-price-range-from-50-to-100-then-you-have-to-pass-value-like-price-10-50-as-the-query-parameter-in-api-url) 5\. In the case of a simple product, You can set a range of a minimum price and maximum price. Same as `size` and `color`, the `price` filter will also work on the category layout only. Suppose you want to filter products those are having price between price range from 50 to 100, then you have to pass value like `price=10,50` as the query parameter in API URL - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?category_id=2&price=50,100` #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_6-you-can-also-use-the-limit-and-page-in-query-parameters-with-category-price-filterable-parameters) 6\. You can also use the `limit` and `page` in query parameters with `category` & `price` filterable parameters - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?category_id=2&price=50,100&limit=10&page=1` ![Bagisto Product Price Simple](https://devdocs.bagisto.com/assets/img/bagisto_prod_price_simple.78ef8f5a.jpg) #### [#](https://devdocs.bagisto.com/1.x/api/products.html#_7-in-the-case-of-a-configurable-product-the-price-filter-will-also-work-with-the-product-s-variants-suppose-you-want-to-filter-products-with-the-40-min-and-100-max-price-range-and-there-is-a-configurable-product-named-men-s-t-shirts-having-a-price-30-and-there-is-any-variant-of-the-same-product-having-45-price-then-men-s-t-shirts-product-will-show-you-in-the-filtered-product-s-list) 7\. In the case of a configurable product, the `price` filter will also work with the product's variants. Suppose you want to filter products with the 40$ min and 100$ max price range. And there is a configurable product named men's T-shirts having a price 30$ and there is any variant of the same product having 45$ price, then men's T-shirts product will show you in the filtered product's list - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products?category_id=2&price=30,100` ![Bagisto Product Price Config](https://devdocs.bagisto.com/assets/img/bagisto_prod_price_config.1c3285d1.jpg) TIP The above-explained filter query parameters (i.e. size, color, price) can be used together. ## [#](https://devdocs.bagisto.com/1.x/api/products.html#get-product-by-id) Get product by id If you want the record of any specific product, then you have to provide the product id as an input parameter in the API URL. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET /api/products/{product_id}` - Params | Name | Info | Type | | ---------- | ------------ | ------ | | product_id | Product's ID | Number | ### [#](https://devdocs.bagisto.com/1.x/api/products.html#examples-4) Examples - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/products/1` Response ``` { "data": { "id": 1, "type": "simple", "name": "Adorable Cream Teddy Bear", "url_key": "adorable-cream-teddy-bear", "price": "10.0000", "formated_price": "$10.00", "short_description": "

Buy Adorable Cream Teddy Bear online at best price

", "description": "

Buy Adorable Cream Teddy Bear online at best price

", "sku": "80971254", "images": [\ {...}\ ], "base_image": {...}, "variants": [], "in_stock": true, "reviews": {...}, "is_saved": false, "created_at": "2020-09-08T23:52:02.000000Z", "updated_at": "2020-09-08T23:52:02.000000Z" } } ``` ## [#](https://devdocs.bagisto.com/1.x/api/products.html#get-product-s-additional-information) Get product's additional information Additional information relates to all the attributes and their values for which admin sets the `Yes` value for the `Visible on Product View Page on Front-end`. The product's additional information means those attributes which describe the product's specification. ![Bagisto Attribute](https://devdocs.bagisto.com/assets/img/bagisto_attribute.a6fc572b.jpg) - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/product-additional-information/1` Response ![Bagisto Additional Info](https://devdocs.bagisto.com/assets/img/bagisto_add_info.78af382e.jpg) ## [#](https://devdocs.bagisto.com/1.x/api/products.html#get-product-s-variants-information) Get product's variants information You can get all the configurable attributes of a product by using `product-configurable-config` resource in API calls. It will return all the variants of a product with their `label`, `options`, `regular_price` and `final_price` also. Admin can set the `Yes` value for the `Use To Create Configurable Product` field under the attribute panel to make that attribute as variant. ![Bagisto Config](https://devdocs.bagisto.com/assets/img/bagisto_config.325d4e50.jpg) - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/product-configurable-config/1` Response ``` { "data": { "attributes": [\ {\ "id": 24,\ "code": "size",\ "label": "Size",\ "swatch_type": null,\ "options": [\ {\ "id": 7,\ "label": "M",\ "swatch_value": null,\ "products": [4]\ }\ ]\ }\ ], "variant_prices": { "4": { "regular_price": { "formated_price": "$45.00", "price": 45 }, "final_price": { "formated_price": "$45.00", "price": 45 } } } } } ``` ![Bagisto Config Attributes](https://devdocs.bagisto.com/assets/img/bagisto_config_attr.83af48dd.jpg) [Addresses](https://devdocs.bagisto.com/1.x/api/addresses.html)[Categories](https://devdocs.bagisto.com/1.x/api/categories.html) ## Bagisto Installation Guide Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#installation) Installation - [Install Using GUI Installer](https://devdocs.bagisto.com/2.2/introduction/installation.html#install-using-gui-installer) - [Install Using Composer](https://devdocs.bagisto.com/2.2/introduction/installation.html#install-using-composer) - [Start Using Bagisto](https://devdocs.bagisto.com/2.2/introduction/installation.html#start-using-bagisto) - [On a Production Server](https://devdocs.bagisto.com/2.2/introduction/installation.html#on-a-production-server) - [On Your Local Server](https://devdocs.bagisto.com/2.2/introduction/installation.html#on-your-local-server) - [Login as an Admin](https://devdocs.bagisto.com/2.2/introduction/installation.html#login-as-an-admin) - [Login as a Customer](https://devdocs.bagisto.com/2.2/introduction/installation.html#login-as-a-customer) - [Installation of Mobile App](https://devdocs.bagisto.com/2.2/introduction/installation.html#installation-of-mobile-app) - [Clone the repository](https://devdocs.bagisto.com/2.2/introduction/installation.html#clone-the-repository) - [Install dependencies](https://devdocs.bagisto.com/2.2/introduction/installation.html#install-dependencies) - [Generate Required files](https://devdocs.bagisto.com/2.2/introduction/installation.html#generate-required-files) - [Connect a device or emulator](https://devdocs.bagisto.com/2.2/introduction/installation.html#connect-a-device-or-emulator) - [Run the Project](https://devdocs.bagisto.com/2.2/introduction/installation.html#run-the-project) - [Minimum Versions](https://devdocs.bagisto.com/2.2/introduction/installation.html#minimum-versions) - [Configurations Steps](https://devdocs.bagisto.com/2.2/introduction/installation.html#configurations-steps) - [For Setup](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-setup) - [For Theme](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-theme) - [For Push Notification Service](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-push-notification-service) - [For Application Title](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-application-title) - [For Splash Screen](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-splash-screen) - [For App Icon](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-app-icon) - [API Documentation](https://devdocs.bagisto.com/2.2/introduction/installation.html#api-documentation) - [Contributing](https://devdocs.bagisto.com/2.2/introduction/installation.html#contributing) - [License](https://devdocs.bagisto.com/2.2/introduction/installation.html#license) ## [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#install-using-gui-installer) Install Using GUI Installer To install Bagisto using our GUI installer, you can follow any of the following methods: #### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#method-1) Method 1: - Choose the directory where you want to install Bagisto. Open your terminal and navigate to this directory. - Once you are in the desired directory, run the following command in your terminal to install Bagisto: ``` composer create-project bagisto/bagisto ``` - Configure your HTTP server to point to the **`public/`** directory of the project. - Open your browser and access the following URL: ``` http://localhost/bagisto/public/ ``` This will launch the Bagisto installer. #### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#method-2) Method 2: Otherwise you can download the zip file and install it using the following steps: - [Download Bagisto(opens new window)](https://bagisto.com/en/download/) from our website. - Extract the contents of the downloaded - Navigate to the project root directory. - Run the following command: ``` composer create ``` - Configure your HTTP server to point to the **`public/`** directory of the project. - Open your browser and access the following URL: ``` http://localhost/bagisto/public/ ``` This will launch the Bagisto installer. WARNING Ensure that Composer is installed on your system ## [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#install-using-composer) Install Using Composer To install Bagisto using Composer, use the following steps: - Choose the directory where you want to install Bagisto. Open your terminal and navigate to this directory. - Once you are in the desired directory, run the following command in your terminal to install Bagisto: - Run the following command: ``` composer create-project bagisto/bagisto ``` - Run the following command: ``` php artisan bagisto:install ``` WARNING During the installation process, if the **`.env`** file doesn't exist, the installer will prompt you to provide the necessary information. - Follow the prompts during the installation process to provide the following details: ``` - Please Enter the Application Name : - Please Enter the APP URL : - Please enter the application URL: - Please select the default locale : - Please enter the default currency : - Please choose the Allowed Locales for your channels : - Please choose the Allowed Currencies for your channels : - Please select the Database Connection : - Please enter the Database Host : - Please enter the Database Port Number : - Please enter the Database Name : - Please enter the Database Prefix : - Please enter the Database Username : - Please enter the Database Password : ``` - For Create your admin credentials ``` - Enter the Name of Admin User : - Enter the Email address of the Admin User : - Configure the Password for admin user : - Please select if you want some sample products after installation: ``` ## [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#start-using-bagisto) Start Using Bagisto ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#on-a-production-server) On a Production Server To access Bagisto on a production server, open your domain in a web browser. For example: ``` https://example.com/ ``` ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#on-your-local-server) On Your Local Server To access Bagisto on your local server, follow these steps: 1. Configure your HTTP server to point to the **`public/`** directory of the project. 2. Run the following command: ``` php artisan serve ``` 3. Open your browser and access the provided local server URL. ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#login-as-an-admin) Login as an Admin To log in as an admin, visit **`https://example.com/admin/`**. If you used the **`php artisan bagisto:install`** command, use the following credentials: ``` Email: admin@example.com Password: admin123 ``` ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#login-as-a-customer) Login as a Customer To log in as a customer, you can directly register on **`https://example.com/customer/register`**. After registration, you can log in using your credentials on the domain. ## [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#installation-of-mobile-app) Installation of Mobile App Before beginning with the installation, you will need the following with the mentioned versions - Bagisto Version - v2.0.0 - Android Studio Version - Flamingo \| 2022.2.1 - Flutter Version - 3.10.1 - Dart - 3.0.1 - Xcode - 14.3 - Swift - 5 Make sure you have installed the API module and set this up properly on your bagisto. Note It is recommended that you run a simple Hello World program in Flutter first before proceeding further so that you are sure that the environment is properly set up. ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#clone-the-repository) Clone the repository - Open your terminal or command prompt - Navigate to the directory where you want to save the project - Use the git clone command followed by the repository URL ``` git clone https://github.com/bagisto/opensource-ecommerce-mobile-app.git ``` ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#install-dependencies) Install dependencies - Navigate to the project's directory ``` cd ``` - Run the following command to install the required packages ``` flutter pub get ``` ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#generate-required-files) Generate Required files - Navigate to the project's directory ``` cd ``` - Run the following command to generate the required files ``` flutter pub run build_runner build --delete-conflicting-outputs ``` ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#connect-a-device-or-emulator) Connect a device or emulator - Physical Device 1. Enable USB debugging on your device 2. Connect it to your computer using a USB cable. - Emulator 1. Start an Android or iOS emulator using your preferred IDE or tools. ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#run-the-project) Run the Project - Use the following command to build and run the project ``` flutter run ``` ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#minimum-versions) Minimum Versions - Android: 21 - iOS: 12 ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#configurations-steps) Configurations Steps ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-setup) For Setup Change the baseUrl as per your store **Path:** lib/utils/server_configuration.dart ``` static const String baseUrl = ‘....’; ``` Note Add the value of the complete URL ending with the GraphQL API endpoint. E.g - https://example.com/graphql ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-theme) For Theme Change the Theme for your app **Path:** lib/utils/mobikul_theme.dart ``` static const Color primaryColor = Color(***********); static const Color accentColor = Color(***********); ``` ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-push-notification-service) For Push Notification Service - Android Replace "google-services.json". - iOS Replace "GoogleService-Info.plist". Note Helpful Articles Android https://mobikul.com/knowledgebase/generating-google-service-file-enable-fcm-firebase-cloud-messaging-android-application/ iOS https://mobikul.com/knowledgebase/generating-new-googleservice-info-plist-file-fcm-based-project-ios-app/ ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-application-title) For Application Title - Android 1. **Path:** android/app/src/main/AndroidManifest.xml 2. **Change app name:** android:label="\*\*\*\*\*\*\*\*\*\*\*" - iOS 1. Go to the general tab and identity change the display name to your app name Note For Homepage Header Title - Go to ‘assets/language/en.json’ (Note: Here, “en” in en.json refers to the languages that would be supported within the application) ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-splash-screen) For Splash Screen - For adding Lottie as Splash Screen 1. **Path:** assets/lottie/splash_screen.json 2. After updating the Lottie file, update the ‘splashLottie’ in lib/utils/assets_constants. ``` static const String splashLottie = "assets/lottie/splash_screen.json"; ``` - For adding an Image as a Splash Screen 1. **Path:** assets/images/splash.png 2. After updating the Image file, update the ‘splashImage’ in lib/utils/assets_constants. ``` static const String splashImage = "assets/images/splash.png"; ``` ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#for-app-icon) For App Icon - **Android:** Open the android folder in Android Studio and then right click app > new > Image Asset set Image. - **iOS:** Replace the icons over the path > ios/Runner/Assets.xcassets/AppIcon.appiconset ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#api-documentation) API Documentation For the API Documentation, please go through - https://github.com/bagisto/headless-ecommerce/ ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#contributing) Contributing Contributions are welcome! Follow the contribution guidelines to get started. ### [#](https://devdocs.bagisto.com/2.2/introduction/installation.html#license) License Bagisto is open-sourced software licensed under the MIT license. [Requirements](https://devdocs.bagisto.com/2.2/introduction/requirements.html)[Docker](https://devdocs.bagisto.com/2.2/introduction/docker.html) ## Bagisto Core Helpers Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/advanced/helpers.html#helpers) Helpers In Bagisto, there are several packages have been used. We have provided useful helper methods in the packages which can help developers to develop their projects with ease. ## [#](https://devdocs.bagisto.com/1.x/advanced/helpers.html#core-helpers) Core Helpers All the mentioned helper methods are from Bagisto's core package class named `Core` in the `Webkul\Core` namespace. Let's discuss some common methods, - Get all the channels, ``` core()->getAllChannels(); ``` - Get the current channel, ``` core()->getCurrentChannel(); ``` - Set the current channel, this method will take one argument i.e. instance of this class `Webkul\Core\Models\Channel`, ``` core()->setCurrentChannel($channel); ``` - Get the current channel code, ``` core()->getCurrentChannelCode(); ``` - Get the default channel, ``` core()->getDefaultChannel(); ``` - Get the default channel code, ``` core()->getDefaultChannelCode(); ``` - Get requested channel code, this method is useful when you need to fetch the channel from the request, and no need to worry about the fallback as well. This method also has the optional parameter `$fallback`, which means the developer can use this with or without fallback, ``` core()->getRequestedChannelCode(); ``` - Get the channel name, yeah we know that you can chain it with the `Channel` instance but the purpose of this method is to handle the fallback case as well. This method will first check the name in the property, if not found then it will proceed further with app locale code, if still not found then it will check from the config key name as `app.fallback_locale`, ``` core()->getChannelName($channel); ``` - Get all the locales, ``` core()->getAllLocales(); ``` - Get all locales by requested channel, this method will provide you all the locales associated with the requested channel, ``` core()->getAllLocalesByRequestedChannel(); ``` - Get the current locale, ``` core()->getCurrentLocale(); ``` - Get the requested locale code, this method is useful when you need to fetch the locale code from the request, and no need to worry about the fallback as well. This method also has the optional parameter `$localeKey` and `$fallback`, which means the developer can use this with or without fallback, ``` core()->getRequestedLocaleCode(); ``` - Get all the customer groups, ``` core()->getAllCustomerGroups(); ``` - Get requested customer group code, this method will fetch you customer group code from the request, ``` core()->getRequestedCustomerGroupCode(); ``` - Get all the currencies, ``` core()->getAllCurrencies(); ``` - Get the base currency, ``` core()->getBaseCurrency(); ``` - Get the base currency code, ``` core()->getBaseCurrencyCode(); ``` - Get the channel based currency, ``` core()->getChannelBaseCurrency(); ``` - Get the channel based currency code, ``` core()->getChannelBaseCurrencyCode(); ``` - Get the current currency, ``` core()->getCurrentCurrency(); ``` - Get the current currency code, ``` core()->getCurrentCurrencyCode(); ``` - Get the exchange rate based on the currency id, ``` core()->getExchangeRate($targetCurrencyId); ``` - Get the formatted amount, ``` core()->currency($amount = 0); ``` - Get the configuration date based on the key, channel and locale, ``` core()->getConfigData($field, $channel = null, $locale = null); ``` - Get all the countries, ``` core()->countries(); ``` - Get the country name by country code, ``` core()->country_name($countryCode); ``` - Get all the country's state, ``` core()->states($countryCode); ``` - Get sender email details, ``` core()->getSenderEmailDetails(); ``` - Get admin email details, ``` core()->getAdminEmailDetails(); ``` [Events](https://devdocs.bagisto.com/1.x/advanced/events.html)[Override core models](https://devdocs.bagisto.com/1.x/advanced/override-core-model.html) ## Bagisto Validation Guide Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/packages/validation.html#validation) Validation - [Validation Using Laravel](https://devdocs.bagisto.com/2.2/packages/validation.html#validation-using-laravel) - [Introduction](https://devdocs.bagisto.com/2.2/packages/validation.html#introduction) - [Usage](https://devdocs.bagisto.com/2.2/packages/validation.html#usage) - [Using the validate Method on Request](https://devdocs.bagisto.com/2.2/packages/validation.html#using-the-validate-method-on-request) - [Using the Validator Facade](https://devdocs.bagisto.com/2.2/packages/validation.html#using-the-validator-facade) - [Validation Using Vue](https://devdocs.bagisto.com/2.2/packages/validation.html#validation-using-vue) - [Introduction](https://devdocs.bagisto.com/2.2/packages/validation.html#introduction) - [Installation](https://devdocs.bagisto.com/2.2/packages/validation.html#installation) - [Configuration](https://devdocs.bagisto.com/2.2/packages/validation.html#configuration) - [Examples](https://devdocs.bagisto.com/2.2/packages/validation.html#examples) - [Available Custom Validation in bagisto](https://devdocs.bagisto.com/2.2/packages/validation.html#available-custom-validation-in-bagisto) ## [#](https://devdocs.bagisto.com/2.2/packages/validation.html#validation-using-laravel) Validation Using Laravel ### [#](https://devdocs.bagisto.com/2.2/packages/validation.html#introduction) Introduction Laravel offers multiple approaches to validate incoming data in your application, ensuring that your data is accurate and meets the specified requirements before it is processed. The most common method is to use the validate method available on incoming HTTP requests. This method is easy to use and integrates seamlessly with Laravel's request lifecycle. By leveraging Laravel's built-in validation rules and custom validation logic, you can ensure your application handles data validation efficiently and effectively. For detailed information about validation in Laravel, refer to the [Laravel documentation(opens new window)](https://laravel.com/docs/11.x/validation). ### [#](https://devdocs.bagisto.com/2.2/packages/validation.html#usage) Usage Laravel provides multiple ways to handle validation in your application, ensuring your data meets specified criteria before processing it. Here are the two most common methods: ### [#](https://devdocs.bagisto.com/2.2/packages/validation.html#using-the-validate-method-on-request) Using the validate Method on Request The simplest and most common way to validate incoming data is to use the `validate` method available on incoming HTTP requests. Here’s an example of how you can use this method to validate data in a controller method: ``` /** * Store a new blog post. */ public function store(Request $request) { $validated = $request->validate([\ 'title' => 'required|unique:posts|max:255',\ 'body' => 'required',\ ]); } ``` In this example, the validate method takes an array of validation rules. If the validation fails, a ValidationException is thrown, and the user is redirected back to the previous page with error messages. ### [#](https://devdocs.bagisto.com/2.2/packages/validation.html#using-the-validator-facade) Using the Validator Facade For more complex validation scenarios, you can manually create a validator instance using the `Validator` facade. This approach gives you more control over the validation process and is useful for custom validation messages and handling errors in a more customized way. Here’s an example of how to use the Validator facade: ``` 'required',\ 'email' => 'required|email',\ 'message' => 'required|max:250',\ ]; $customMessages = [\ 'required' => 'The :attribute field is required.',\ ]; $this->validate($request, $rules, $customMessages); } } ``` - `Defining Rules` The $rules array contains the validation rules for each field. - `Custom Messages` The $customMessages array allows you to define custom validation messages. - `Creating Validator` The Validator::make method creates a validator instance. - `Handling Failure` If validation fails, the user is redirected back with the validation errors and input data. Both methods provide a robust way to ensure data integrity and user input validation in your Laravel application. ## [#](https://devdocs.bagisto.com/2.2/packages/validation.html#validation-using-vue) Validation Using Vue ### [#](https://devdocs.bagisto.com/2.2/packages/validation.html#introduction-2) Introduction VeeValidate is a powerful validation library for Vue.js that provides an extensive set of validation rules out of the box, along with support for custom rules. It is template-based, making it easy to validate HTML5 inputs as well as custom Vue components. VeeValidate also supports localization with 44 languages maintained by the community. For detailed information about validation in Vue.js using VeeValidate v4, refer to the [VeeValidate documentation(opens new window)](https://vee-validate.logaretm.com/v4/guide/overview/). ### [#](https://devdocs.bagisto.com/2.2/packages/validation.html#installation) Installation Bagisto already includes the VeeValidate v4 library, so there is no need to install it separately. ### [#](https://devdocs.bagisto.com/2.2/packages/validation.html#configuration) Configuration Bagisto comes with pre-configured settings for `vee-validate`. You can find the configuration in the following path: `bagisto/packages/Webkul/Admin/src/Resources/assets/js/app.js`. ``` /** * This will track all the images and fonts for publishing. */ import.meta.glob(["../images/**", "../fonts/**"]); /** * Main vue bundler. */ import { createApp } from "vue/dist/vue.esm-bundler"; /** * We are defining all the global rules here and configuring * all the `vee-validate` settings. */ import { configure, defineRule } from "vee-validate"; import { localize } from "@vee-validate/i18n"; import en from "@vee-validate/i18n/dist/locale/en.json"; import { all } from '@vee-validate/rules'; /** * Registration of all global validators. */ Object.entries(all).forEach(([name, rule]) => defineRule(name, rule)); /** * This regular expression allows phone numbers with the following conditions: * - The phone number can start with an optional "+" sign. * - After the "+" sign, there should be one or more digits. * * This validation is sufficient for global-level phone number validation. If * someone wants to customize it, they can override this rule. */ defineRule("phone", (value) => { if (! value || ! value.length) { return true; } if (!/^\+?\d+$/.test(value)) { return false; } return true; }); defineRule("decimal", (value, { decimals = '*', separator = '.' } = {}) => { if (value === null || value === undefined || value === '') { return true; } if (Number(decimals) === 0) { return /^-?\d*$/.test(value); } const regexPart = decimals === '*' ? '+' : `{1,${decimals}}`; const regex = new RegExp(`^[-+]?\\d*(\\${separator}\\d${regexPart})?([eE]{1}[-]?\\d+)?$`); return regex.test(value); }); defineRule("required_if", (value, { condition = true } = {}) => { if (condition) { if (value === null || value === undefined || value === '') { return false; } } return true; }); defineRule("", () => true); configure({ /** * Built-in error messages and custom error messages are available. Multiple * locales can be added in the same way. */ generateMessage: localize({ en: { ...en, messages: { ...en.messages, phone: "This {field} must be a valid phone number", }, }, }), validateOnBlur: true, validateOnInput: true, validateOnChange: true, }); ``` ### [#](https://devdocs.bagisto.com/2.2/packages/validation.html#examples) Examples Below are examples of how to use VeeValidate for validation in Vue components within Bagisto: ``` @lang('blog::app.admin.blog.create.title') ``` ### [#](https://devdocs.bagisto.com/2.2/packages/validation.html#available-custom-validation-in-bagisto) Available Custom Validation in bagisto - `phone` The phone validation rule is designed to ensure that the input is a valid phone number. ``` defineRule("phone", (value) => { if (! value || ! value.length) { return true; } if (! /^\+?\d+$/.test(value)) { return false; } return true; }); ``` - `address` The address validation rule typically ensures that an address field is not left empty and may include additional logic to check for valid address formats. ``` defineRule("address", (value) => { if (! value || ! value.length) { return true; } if ( ! /^[a-zA-Z0-9\s.\/*'\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\u0590-\u05FF\u3040-\u309F\u30A0-\u30FF\u0400-\u04FF\u0D80-\u0DFF\u3400-\u4DBF\u2000-\u2A6D\u00C0-\u017F\u0980-\u09FF\u0900-\u097F\u4E00-\u9FFF,\(\)-]{1,60}$/iu.test( value ) ) { return false; } return true; }); ``` - `postcode` The postcode validation rule is designed to ensure that the input is a valid post code. ``` defineRule("postcode", (value) => { if (! value || ! value.length) { return true; } if (! /^[a-zA-Z0-9][a-zA-Z0-9\s-]*[a-zA-Z0-9]$/.test(value)) { return false; } return true; }); ``` - `decimal` The decimal validation rule ensures that the input is a valid decimal number. This rule allows specifying the number of decimal places and the decimal separator. By default, it accepts any number of decimal places and uses the period (".") as the separator. ``` defineRule( "decimal", (value, { decimals = "*", separator = "." } = {}) => { if (value === null || value === undefined || value === "") { return true; } if (Number(decimals) === 0) { return /^-?\d*$/.test(value); } const regexPart = decimals === "*" ? "+" : `{1,${decimals}}`; const regex = new RegExp( `^[-+]?\\d*(\\${separator}\\d${regexPart})?([eE]{1}[-]?\\d+)?$` ); return regex.test(value); } ); ``` - `required_if` The required_if validation rule ensures that a value is required based on a given condition. If the specified condition evaluates to true, the input must not be null, undefined, or an empty string. If the condition is false, the validation passes regardless of the input value. ``` defineRule("required_if", (value, { condition = true } = {}) => { if (condition) { if (value === null || value === undefined || value === '') { return false; } } return true; }); ``` [Admin Menu](https://devdocs.bagisto.com/2.2/packages/add-menu-in-admin.html)[DataGrid](https://devdocs.bagisto.com/2.2/packages/datagrid.html) ## Bagisto Indexing Guide This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#indexing) Indexing - [Introduction](https://devdocs.bagisto.com/2.3/performance/indexing.html#introduction) - [Essential Indexers in Bagisto](https://devdocs.bagisto.com/2.3/performance/indexing.html#essential-indexers-in-bagisto) - [Price Indexing](https://devdocs.bagisto.com/2.3/performance/indexing.html#price-indexing) - [Inventory Indexing](https://devdocs.bagisto.com/2.3/performance/indexing.html#inventory-indexing) - [Flat Indexing](https://devdocs.bagisto.com/2.3/performance/indexing.html#flat-indexing) - [Catalog Rule Indexing](https://devdocs.bagisto.com/2.3/performance/indexing.html#catalog-rule-indexing) - [ElasticSearch](https://devdocs.bagisto.com/2.3/performance/indexing.html#elasticsearch) - [Configuration Setup](https://devdocs.bagisto.com/2.3/performance/indexing.html#configuration-setup) - [Re-indexing](https://devdocs.bagisto.com/2.3/performance/indexing.html#re-indexing) ## [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#introduction) Introduction When dealing with large volumes of data and retrieving complex information like variants and prices, optimizing queries becomes a challenge. Indexers create and maintain indexes, which are data structures optimized for quick retrieval of information. When data is added to a system, the indexer analyzes it and extracts key information or metadata. This metadata is then stored in the index, along with pointers to the original data. By indexing data, the system can quickly locate relevant information without having to scan through every piece of data sequentially. This greatly speeds up search and retrieval operations, especially in large datasets. Indexers improve the overall user experience. Users can quickly find what they're looking for, leading to increased satisfaction and productivity. ## [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#essential-indexers-in-bagisto) Essential Indexers in Bagisto To enhance **Bagisto's** performance, the following indexers play a crucial role: ### [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#price-indexing) Price Indexing Price indexing is a crucial component of eCommerce operations, ensuring that product prices are accurately reflected across the storefront. This documentation will delve into how Bagisto handles price indexing. The price indexing process in Bagisto involves updating product prices in the database whenever changes occur. This process ensures that the latest price information is reflected accurately across the storefront. ### [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#inventory-indexing) Inventory Indexing Similar to price indexing, the inventory indexing process in Bagisto involves updating product quantities in the database. Whenever a product is purchased, returned, or restocked, Bagisto automatically adjusts the inventory levels accordingly. This real-time synchronization ensures that inventory information remains accurate and up to date. Ensures that all pricing rules, including catalog rules, are applied consistently and accurately across the store. ### [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#flat-indexing) Flat Indexing Flat indexing in Bagisto is a vital mechanism designed to enhance the performance and efficiency of product data retrieval. The indexer processes products in batches, which is efficient for handling large datasets without overwhelming the system. It manages a set of fillable attribute codes that are essential during the creation of the flat index. The flat indexer takes into account various channels and locales, ensuring that product data is accurately indexed for different market segments. A predefined list of attribute codes, such as `sku`, `name`, `price`, `weight`, and `status`, that can be populated during the indexing process. By default, the Flat Indexer reindexes products based on product creation or update events. However, there are scenarios where you might need to reindex the flat index in response to changes in channels or locales. In such cases, you can manually trigger the re-indexing process to ensure that the flat tables reflect the latest channel and locale updates. ### [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#catalog-rule-indexing) Catalog Rule Indexing Catalog rule indexing in Bagisto ensures that product prices are updated based on any changes to catalog rules, such as offers expiring or being updated. To maintain accurate pricing, Bagisto schedules the catalog rule indexer to run daily. This scheduled task ensures that any modifications to catalog rules are promptly applied to the product prices. The catalog rule indexing process is set to execute at 00:01 every day. The product prices are consistently recalculated and updated based on the current catalog rules. This automatic re-indexing guarantees that any changes in promotional offers, discounts, or other pricing rules are reflected in the product listings without any manual intervention. ### [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#elasticsearch) ElasticSearch As Elastic is designed to handle large amounts of data and provide fast and scalable search capabilities, **Bagisto** leverages its capabilities to index all products, thereby significantly enhancing the search functionality. ## [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#configuration-setup) Configuration Setup To configure Elasticsearch, please refer to the [Configuration Setup(opens new window)](https://devdocs.bagisto.com/2.x/advanced/indexing-products-to-elasticsearch.html) documentation. ## [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#re-indexing) Re-indexing The `Re-indexCommands` console command is responsible for re-indexing data within Bagisto, facilitating efficient data retrieval and search functionality. This command offers flexibility in selecting specific indexers and re-indexing modes to suit varying requirements. By default, re-indexing is executed at the scheduled time or based on specific events, such as product creation or updates. However, there may be situations where you need to manually trigger re-indexing. This can be done using the following commands: #### [#](https://devdocs.bagisto.com/2.3/performance/indexing.html#command-signature) Command Signature The command `php artisan indexer:index` in Bagisto is used to manage the re-indexing of various indexers. Here is a detailed description of its usage: ``` php artisan indexer:index {--type=*} {--mode=*} ``` - **--type**: Specifies the type of indexers to reindex. - **--mode**: Specifies the re-indexing mode, either `full` for full re-indexing or selective for `selective` re-indexing (default). - **Full Reindexing for All Types** ``` php artisan indexer:index --mode=full ``` This command performs a full re-indexing for all indexers by default. - **Selective Re-indexing** ``` php artisan indexer:index --type=price ``` This command performs selective re-indexing specifically for the price indexer. Price and price rule indexing are scheduled to re-index at a specific time each day to ensure that the latest pricing information is accurately reflected in searches and displays. The following commands are scheduled to run daily at 00:01 AM: ``` $schedule->command('indexer:index --type=price')->dailyAt('00:01'); $schedule->command('product:price-rule:index')->dailyAt('00:01'); ``` [Performance](https://devdocs.bagisto.com/2.3/performance)[Full Page Cache](https://devdocs.bagisto.com/2.3/performance/fpc.html) ## Bagisto Layouts Guide This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/packages/layouts.html#layouts) Layouts - [Introduction](https://devdocs.bagisto.com/2.3/packages/layouts.html#introduction) - [Admin Layout](https://devdocs.bagisto.com/2.3/packages/layouts.html#admin-layout) - [Shop Layout](https://devdocs.bagisto.com/2.3/packages/layouts.html#shop-layout) ## [#](https://devdocs.bagisto.com/2.3/packages/layouts.html#introduction) Introduction Layouts in Bagisto are fundamental to structuring your application's views in a consistent and reusable way. They provide a template for rendering HTML across multiple pages, ensuring a unified design and user experience. By defining layouts, you can streamline development, improve maintainability, and enhance the overall aesthetics of your web application. To learn in detail about Layouts, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/blade). ## [#](https://devdocs.bagisto.com/2.3/packages/layouts.html#admin-layout) Admin Layout `` This component serves as the container for your extended admin layout. It encapsulates the entire layout structure, including the title and content. To extend the default layout of the Bagisto admin panel, you'll create or modify the `index.blade.php` file located at `packages/Webkul/Blog/src/Resources/views/admin/index.blade.php`. Below is a detailed breakdown of how to integrate and customize the layout: ``` @lang('blog::app.admin.index.page-title')

@lang('blog::app.admin.index.page-title')

``` ## [#](https://devdocs.bagisto.com/2.3/packages/layouts.html#shop-layout) Shop Layout `` This component serves as the container for your extended shop layout. It encapsulates the entire layout structure, including the title and content. To extend the shop layout in Bagisto, modify or create the `index.blade.php` file located at `packages/Webkul/Blog/src/Resources/views/shop/index.blade.php`. Below is a detailed breakdown of how to integrate and customize the shop layout: ``` @lang('blog::app.shop.blogs.page-title')

@lang('blog::app.shop.blogs.page-title')

``` | Prop Name | Description | Default Value | | ----------------- | ------------------------------------------------------------------ | ------------- | | **`has-header`** | Determines whether to include a header section in the component. | `true` | | **`has-feature`** | Controls the visibility of a feature section within the component. | `true` | | **`has-footer`** | Specifies whether to display a footer section in the component. | `true` | WARNING Notice that there are translations used in the blade files, so you will also need to add the corresponding translations in **`lang/app.php`**. If you don't want to include these layouts, you can create your own master file. [Blade Components](https://devdocs.bagisto.com/2.3/packages/blade-components.html)[Bundling Assets](https://devdocs.bagisto.com/2.3/packages/bundling-assets.html) ## Bagisto Blade Components WARNING: You're browsing the documentation for an upcoming version. Features of this release are subject to change. # [#](https://devdocs.bagisto.com/master/packages/blade-components.html#blade-components) Blade Components - [Introduction](https://devdocs.bagisto.com/master/packages/blade-components.html#introduction) - [Shop Component](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-component) - [Shop Accordion](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-accordion) - [Shop Breadcrumbs](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-breadcrumbs) - [Shop Button](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-button) - [Shop Drawer](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-drawer) - [Shop Dropdown](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-dropdown) - [Shop Flat-Picker](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-flat-picker) - [Shop Data Grid](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-data-grid) - [Shop Tabs](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-tabs) - [Shop Tinymce](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-tinymce) - [Shop Shimmer](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-shimmer) - [Shop Quantity Changer](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-quantity-changer) - [Shop Table](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-table) - [Shop Modal](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-modal) - [Shop Media(Image)](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-media-image) - [Admin Component](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-component) - [Admin Accordion](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-accordion) - [Admin Button](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-button) - [Admin Charts](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-charts) - [Admin Drawer](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-drawer) - [Admin Dropdown](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-dropdown) - [Admin Flat-Picker](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-flat-picker) - [Admin Data Grid](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-data-grid) - [Admin Tabs](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-tabs) - [Admin Tinymce](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-tinymce) - [Admin Shimmer](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-shimmer) - [Admin SEO](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-seo) - [Admin Quantity Changer](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-quantity-changer) - [Admin Table](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-table) - [Admin Modal](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-modal) - [Admin Tree](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-tree) - [Admin Media(Image/Video)](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-media-image-video) ## [#](https://devdocs.bagisto.com/master/packages/blade-components.html#introduction) Introduction To ensure optimal user experience in **Bagisto** we have created several separate Blade components for the Shop and Admin packages. Now in **`Bagisto`** we have also merged the vue.js code inside the blade component to improve application performance. Additionally, To learn in detail about blade components, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/blade#introduction). - Here are the list of Blade component that is available in **`Bagisto`**. ## [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-component) Shop Component Shop components are reusable Blade components used to build the shop. They manage product listings, shopping carts, checkout processes, and user interactions, providing a seamless shopping experience for customers. ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-accordion) Shop Accordion Bagisto provides a collapsible accordion UI element, allowing users to toggle the visibility of content sections. It is commonly used for organizing and presenting information in a compact and intuitive manner. | Props | Type | Default | Description | | --------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | **`is-active`** | Boolean | `false` | Determines the initial state of the accordion. When set to `true`, the accordion section will be expanded by default; otherwise, it will be collapsed. | | Slots | Description | | ------------- | ------------------------------------------------------- | | **`header`** | Used to customize the header section of the accordion. | | **`content`** | Used to customize the content section of the accordion. | You can customize the appearance of the accordion `header` and `content` by passing additional CSS classes to the header and content slots, respectively. Let's assume you want to use the **`accordion`** component, you can call it like this: ``` Accordion Header Accordion Content ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-breadcrumbs) Shop Breadcrumbs The breadcrumbs component generates `breadcrumb` navigation for the application. | Props | Type | Description | | ------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **`name`** | `String` | Specifies the name of the current page or resource. | | **`entity`** | `Mixed` | Optional. Represents the entity associated with the current page. It could be an object, ID, or other data used to retrieve additional information for breadcrumb customization. | Let's assume you want to use the **`breadcrumbs`** component. You can call it like this: ``` ``` By using the breadcrumbs component with these props, you can effectively enhance navigation within your shop application, providing users with clear paths to navigate through different sections or resources. ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-button) Shop Button The `button` component in Bagisto provides a versatile button element that supports loading state with a spinner animation. It offers flexibility in styling and functionality to suit various use cases within your application. | Prop | Type | Default Value | Description | | ------------------ | --------- | ------------- | ------------------------------------------------------------------------ | | **`title`** | `String` | None | Title text displayed on the button. | | **`loading`** | `Boolean` | `false` | Indicates whether the button is in a loading state. | | **`button-type`** | `String` | `'button'` | Specifies the type of button ( `'button'`, `'submit'`, `'reset'`, etc.). | | **`button-class`** | `String` | `''` | Additional classes for custom styling. | You can customize the appearance of the button by passing additional props `loading` `buttonType` `buttonClass` respectively. Let's assume you want to use the **`button`** component. You can call it like this: ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-drawer) Shop Drawer The `drawer` component in Bagisto provides a versatile drawer that can be positioned on the top, bottom, left, or right side of the screen. It allows you to create interactive drawers that can contain various content such as headers, body, and footer sections. The drawer can be toggled open or closed, providing a clean and efficient way to display additional information or functionality. | Props | Type | Default Value | Description | | --------------- | --------- | ------------- | ---------------------------------------------------------------------------- | | **`is-active`** | `Boolean` | `false` | Determines whether the drawer is initially active. | | **`position`** | `String` | `'left'` | Specifies the position of the drawer ( `top`, `bottom`, `left`, or `right`). | | **`width`** | `String` | `'500px'` | Specifies the width of the drawer. | | Slots | Description | | ------------- | -------------------------------------- | | **`toggle`** | Slot for the toggle button or element. | | **`header`** | Slot for the header content. | | **`content`** | Slot for the main content. | | **`footer`** | Slot for the footer content. | You can customize the appearance of the Drawer by passing additional CSS. - To customize the header section, you can target the `header` slot with your own CSS classes or styles. - Similarly, you can customize the content section using the `content` slot. - Similarly, you can customize the content section using the `footer` slot. Let's assume you want to use the **`drawer`** component. You can call it like this. ``` Drawer Toggle Drawer Header Drawer Content ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-dropdown) Shop Dropdown The `dropdown` component in Bagisto provides a customizable dropdown menu that can be positioned at different locations relative to its toggle button. It enables you to create dropdown menus with various content sections such as toggle button, content, and menu items. | Prop | Type | Default Value | Description | | -------------------- | --------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | **`close-on-click`** | `Boolean` | `true` | Determines whether the dropdown should close when clicking outside the menu. | | **`position`** | `String` | `'bottom-left'` | Specifies the position of the dropdown menu relative to the toggle button ( `top-left`, `top-right`, `bottom-left`, `bottom-right`). | | Slots | Description | | ------------- | --------------------------------------- | | **`toggle`** | Slot for the toggle button or element.. | | **`content`** | Slot for the main content. | | **`menu`** | Slot for the menu items.. | To customize the content section, you can target the `content` slot with your own CSS classes or styles. Let's assume you want to use the **`dropdown`** component. You can call it like this. ``` Dropdown Toggle Dropdown Content ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-flat-picker) Shop Flat-Picker The `datetime-picker` and `date-picker` components provide `date` and `time` picker functionality within Bagisto applications. These components are based on the Flatpickr library and offer customizable options for selecting dates and times. It can be configured with various props to customize its behavior according to application requirements. | Prop | Type | Default Value | Description | | ----------------- | --------- | ------------- | -------------------------------------------------------------- | | **`name`** | `String` | None | Name attribute for the input field. | | **`value`** | `String` | None | Initial value of the date picker. | | **`allow-input`** | `Boolean` | `true` | Determines whether manual input is allowed in the input field. | | **`disable`** | `Array` | `[]` | Array of dates to disable in the date picker. | Let's assume you want to use the **`flat-picker`** component. You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-data-grid) Shop Data Grid The `datagrid` component in Bagisto applications provides a flexible and customizable data grid interface for displaying tabular data. It includes features such as `sorting`, `filtering`, `pagination`, and `mass actions` to manage data efficiently. You can customize the appearance of the `DataGrid` by referring to the [DataGrid Customization(opens new window)](https://devdocs.bagisto.com/2.x/packages/datagrid.html#datagrid-customization) documentation. Let's assume you want to use the **`datagrid`** component. You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-tabs) Shop Tabs The Tabs component allows users to navigate between different content sections using tabs. It consists of two main parts: the `tabs` component for managing the tabs and the `tab-item` component for defining individual tab items. | Prop | Type | Default Value | Description | | -------------- | -------- | ------------- | ---------------------------------------------------------------- | | **`position`** | `String` | `'left'` | Specifies the position of the tabs ( `left`, `right`, `center`). | #### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#tab-item-component-props) Tab Item Component Props The `tab-item` component represents an individual tab within the `tabs` component: | Prop | Type | Default Value | Description | | ----------------- | --------- | ------------- | -------------------------------------------------------------------------------------- | | **`title`** | `String` | None | Title of the tab. | | **`is-selected`** | `Boolean` | `false` | Indicates whether the tab is selected ( `true`) or not ( `false`). Default is `false`. | You can customize the tabs and their content as per your requirements. Let's assume you want to use the **`tabs`** component on shop. You can call it like this. ```

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-tinymce) Shop Tinymce The `tinymce` component wraps the Tinymce editor and provides additional functionalities like AI content generation. | Props | Type | Default Value | Description | | -------------- | ------ | ------------- | ------------------------------------------------------------------- | | **`selector`** | String | `''` | The CSS selector for the textarea element to initialize as TinyMCE. | | **`field`** | Object | `{}` | Vue Formulate field object. | | **`prompt`** | String | `''` | The prompt to be used for AI content generation. | Let's assume you want to use the **`tinymce`** component on admin and shop. You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-shimmer) Shop Shimmer Prebuilt `shimmer` effects are available in Bagisto. You can easily use them. Let's assume you want to use the **`shimmer`** You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-quantity-changer) Shop Quantity Changer The Quantity Changer component, provides a simple interface for users to increase or decrease a quantity value. | Props | Type | Default Value | Description | | ----------- | ------ | ------------- | ---------------------------------------------- | | **`name`** | String | `''` | The name attribute for the hidden input field. | | **`value`** | Number | `1` | The initial quantity value. | Let's assume you want to use the **`Quantity Changer`** component on shop. You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-table) Shop Table The Table component provides a structured way to display tabular data in Bagisto. You can customize the appearance of the table elements using CSS. Below are some common customization options: | Styling | Description | | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **`Table`** | Apply custom styles to the `table` element to change its appearance, such as borders, padding, and background color. | | **`Cell`** | Customize the appearance of `th` and `td` elements using CSS, such as font size, text alignment, and background color. | | **`Row`** | Apply styles to `tr` elements to change their appearance, such as background color, hover effects, and borders. | | **`Header`** | Customize the appearance of the header cells within the `thead` section using `th` elements. Apply styles such as font weight, text color, and background color. | Let's assume you want to use the **`Table`** component on shop. You can call it like this. ``` Heading 1 Heading 2 Heading 3 Heading 4 Column 1 Column 2 Column 3 Column 4 ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-modal) Shop Modal The `modal` component in Bagisto provides a flexible way to create modal dialogs. It allows you to display content in a layer that floats above the rest of the page. | Props | Type | Default Value | Description | | ----------- | ------- | ------------- | ------------------------------------- | | `is-active` | Boolean | `false` | Controls the visibility of the modal. | | Slot | Description | | ------------- | -------------------------------------------------------------- | | **`toggle`** | Used for the element that toggles the visibility of the modal. | | **`header`** | Allows customization of the modal header content. | | **`content`** | Provides a slot for the main body content of the modal. | | **`footer`** | Allows customization of the footer content within the modal. | You can customize the appearance of the Modal by passing additional CSS. - To customize the header section, you can target the `header` slot with your own CSS classes or styles. - Similarly, you can customize the content section using the `content` slot. - Similarly, you can customize the content section using the `footer` slot. Let's assume you want to use the **`modal`** component, You can call it like this. ``` Modal Toggle Modal Header Modal Content ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#shop-media-image) Shop Media(Image) The Media component in Bagisto provides a user interface for managing and displaying images/videos, allowing users to upload, edit, and delete images.: | Prop Name | Type | Default Value | Description | | ---------------- | --------- | -------------------- | --------------------------------------------------------------- | | `name` | `String` | `'attachments'` | Specifies the name of the input field for uploaded media. | | `is-multiple` | `Boolean` | `false` | Indicates whether multiple media files can be uploaded at once. | | `rules` | `String` | `''` | Validation rules for uploaded files (e.g., file size, type). | | `accepted-types` | `String` | `'image/*, video/*'` | MIME types accepted for file upload (e.g., image/jpeg). | | `src` | `String` | `''` | Default media URL to display when initializing the component. | Let's assume you want to use the **`Image/Video`** component, You can call it like this. ``` ``` ## [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-component) Admin Component Admin components are reusable Blade components used to build the Admin. ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-accordion) Admin Accordion Bagisto provides a collapsible accordion UI element, allowing users to toggle the visibility of content sections. It is commonly used for organizing and presenting information in a compact and intuitive manner. | Props | Type | Default | Description | | --------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | **`is-active`** | Boolean | `false` | Determines the initial state of the accordion. When set to `true`, the accordion section will be expanded by default; otherwise, it will be collapsed. | | Slots | Description | | ------------- | ------------------------------------------------------- | | **`header`** | Used to customize the header section of the accordion. | | **`content`** | Used to customize the content section of the accordion. | You can customize the appearance of the accordion `header` and `content` by passing additional CSS classes to the header and content slots, respectively. Let's assume you want to use the **`accordion`** component, you can call it like this: ``` Accordion Header Accordion Content ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-button) Admin Button The `button` component in Bagisto provides a versatile button element that supports loading state with a spinner animation. It offers flexibility in styling and functionality to suit various use cases within your application. | Prop | Type | Default Value | Description | | ------------------ | --------- | ------------- | ------------------------------------------------------------------------ | | **`title`** | `String` | None | Title text displayed on the button. | | **`loading`** | `Boolean` | `false` | Indicates whether the button is in a loading state. | | **`button-type`** | `String` | `'button'` | Specifies the type of button ( `'button'`, `'submit'`, `'reset'`, etc.). | | **`button-class`** | `String` | `''` | Additional classes for custom styling. | You can customize the appearance of the button by passing additional props `loading` `buttonType` `buttonClass` respectively. Let's assume you want to use the **`button`** component. You can call it like this: ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-charts) Admin Charts The `charts-bar` and `charts-line` components in Bagisto provide easy-to-use chart components for displaying bar and line charts respectively. These components are based on the Chart.js library and offer customization options for labels, datasets, and aspect ratio to create visually appealing charts in your Bagisto application. | Prop | Type | Default Value | Description | | ----------------- | ------------------ | ------------- | ---------------------------------------------------------- | | **`labels`** | `Array` (required) | None | An array of labels for the x-axis of the chart. | | **`datasets`** | `Array` (required) | None | An array of datasets containing data points for the chart. | | **`aspectRatio`** | `Number` | `3.23` | Optional. Aspect ratio of the chart (width / height). | You can customize the appearance of the bar chart by providing different datasets with colors, labels, and data points. Additionally, you can adjust the aspect ratio of the chart by setting the aspect-ratio prop. Let's assume you want to use the **`charts`** component. You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-drawer) Admin Drawer The `drawer` component in Bagisto provides a versatile drawer that can be positioned on the top, bottom, left, or right side of the screen. It allows you to create interactive drawers that can contain various content such as headers, body, and footer sections. The drawer can be toggled open or closed, providing a clean and efficient way to display additional information or functionality. | Props | Type | Default Value | Description | | --------------- | --------- | ------------- | ---------------------------------------------------------------------------- | | **`is-active`** | `Boolean` | `false` | Determines whether the drawer is initially active. | | **`position`** | `String` | `'left'` | Specifies the position of the drawer ( `top`, `bottom`, `left`, or `right`). | | **`width`** | `String` | `'500px'` | Specifies the width of the drawer. | | Slots | Description | | ------------- | -------------------------------------- | | **`toggle`** | Slot for the toggle button or element. | | **`header`** | Slot for the header content. | | **`content`** | Slot for the main content. | | **`footer`** | Slot for the footer content. | You can customize the appearance of the Drawer by passing additional CSS. - To customize the header section, you can target the `header` slot with your own CSS classes or styles. - Similarly, you can customize the content section using the `content` slot. - Similarly, you can customize the content section using the `footer` slot. Let's assume you want to use the **`drawer`** component. You can call it like this. ``` Drawer Toggle Drawer Header Drawer Content ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-dropdown) Admin Dropdown The `dropdown` component in Bagisto provides a customizable dropdown menu that can be positioned at different locations relative to its toggle button. It enables you to create dropdown menus with various content sections such as toggle button, content, and menu items. | Prop | Type | Default Value | Description | | -------------------- | --------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | **`close-on-click`** | `Boolean` | `true` | Determines whether the dropdown should close when clicking outside the menu. | | **`position`** | `String` | `'bottom-left'` | Specifies the position of the dropdown menu relative to the toggle button ( `top-left`, `top-right`, `bottom-left`, `bottom-right`). | | Slots | Description | | ------------- | --------------------------------------- | | **`toggle`** | Slot for the toggle button or element.. | | **`content`** | Slot for the main content. | | **`menu`** | Slot for the menu items.. | To customize the content section, you can target the `content` slot with your own CSS classes or styles. Let's assume you want to use the **`dropdown`** component. You can call it like this. ``` Dropdown Toggle Dropdown Content ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-flat-picker) Admin Flat-Picker The `datetime-picker` and `date-picker` components provide `date` and `time` picker functionality within Bagisto applications. These components are based on the Flatpickr library and offer customizable options for selecting dates and times. It can be configured with various props to customize its behavior according to application requirements. | Prop | Type | Default Value | Description | | ----------------- | --------- | ------------- | -------------------------------------------------------------- | | **`name`** | `String` | None | Name attribute for the input field. | | **`value`** | `String` | None | Initial value of the date picker. | | **`allow-input`** | `Boolean` | `true` | Determines whether manual input is allowed in the input field. | | **`disable`** | `Array` | `[]` | Array of dates to disable in the date picker. | Let's assume you want to use the **`flat-picker`** component. You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-data-grid) Admin Data Grid The `datagrid` component in Bagisto applications provides a flexible and customizable data grid interface for displaying tabular data. It includes features such as `sorting`, `filtering`, `pagination`, and `mass actions` to manage data efficiently. You can customize the appearance of the `DataGrid` by referring to the [DataGrid Customization(opens new window)](https://devdocs.bagisto.com/2.x/packages/datagrid.html#datagrid-customization) documentation. Let's assume you want to use the **`datagrid`** component. You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-tabs) Admin Tabs The Tabs component allows users to navigate between different content sections using tabs. It consists of two main parts: the `tabs` component for managing the tabs and the `tab-item` component for defining individual tab items. | Prop | Type | Default Value | Description | | -------------- | -------- | ------------- | ---------------------------------------------------------------- | | **`position`** | `String` | `'left'` | Specifies the position of the tabs ( `left`, `right`, `center`). | #### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#tab-item-component-props-2) Tab Item Component Props The `tab-item` component represents an individual tab within the `tabs` component: | Prop | Type | Default Value | Description | | ----------------- | --------- | ------------- | -------------------------------------------------------------------------------------- | | **`title`** | `String` | None | Title of the tab. | | **`is-selected`** | `Boolean` | `false` | Indicates whether the tab is selected ( `true`) or not ( `false`). Default is `false`. | You can customize the tabs and their content as per your requirements. Let's assume you want to use the **`tabs`** component on shop. You can call it like this. ```

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

Lorem Ipsum is simply dummy text of the printing and typesetting industry.

``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-tinymce) Admin Tinymce The `tinymce` component wraps the Tinymce editor and provides additional functionalities like AI content generation. | Props | Type | Default Value | Description | | -------------- | ------ | ------------- | ------------------------------------------------------------------- | | **`selector`** | String | `''` | The CSS selector for the textarea element to initialize as TinyMCE. | | **`field`** | Object | `{}` | Vue Formulate field object. | | **`prompt`** | String | `''` | The prompt to be used for AI content generation. | Let's assume you want to use the **`tinymce`** component on admin and shop. You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-shimmer) Admin Shimmer Prebuilt `shimmer` effects are available in Bagisto. You can easily use them. Let's assume you want to use the **`shimmer`** You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-seo) Admin SEO The `seo` component, assists in managing SEO-related metadata for your pages. It dynamically updates the meta title and description based on user input and provides a preview of the generated SEO metadata. | Props | Type | Default Value | Description | | ---------- | ------ | ------------- | ---------------------- | | **`slug`** | String | `''` | URL slug for the page. | Let's assume you want to use the **`seo`** component. You can call it like this, It offers a convenient way to generate and display SEO-friendly content for web pages. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-quantity-changer) Admin Quantity Changer The Quantity Changer component, provides a simple interface for users to increase or decrease a quantity value. | Props | Type | Default Value | Description | | ----------- | ------ | ------------- | ---------------------------------------------- | | **`name`** | String | `''` | The name attribute for the hidden input field. | | **`value`** | Number | `1` | The initial quantity value. | Let's assume you want to use the **`Quantity Changer`** component on shop. You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-table) Admin Table The Table component provides a structured way to display tabular data in Bagisto. You can customize the appearance of the table elements using CSS. Below are some common customization options: | Styling | Description | | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **`Table`** | Apply custom styles to the `table` element to change its appearance, such as borders, padding, and background color. | | **`Cell`** | Customize the appearance of `th` and `td` elements using CSS, such as font size, text alignment, and background color. | | **`Row`** | Apply styles to `tr` elements to change their appearance, such as background color, hover effects, and borders. | | **`Header`** | Customize the appearance of the header cells within the `thead` section using `th` elements. Apply styles such as font weight, text color, and background color. | Let's assume you want to use the **`Table`** component on shop. You can call it like this. ``` Heading 1 Heading 2 Heading 3 Heading 4 Column 1 Column 2 Column 3 Column 4 ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-modal) Admin Modal The `modal` component in Bagisto provides a flexible way to create modal dialogs. It allows you to display content in a layer that floats above the rest of the page. | Props | Type | Default Value | Description | | ----------- | ------- | ------------- | ------------------------------------- | | `is-active` | Boolean | `false` | Controls the visibility of the modal. | | Slot | Description | | ------------- | -------------------------------------------------------------- | | **`toggle`** | Used for the element that toggles the visibility of the modal. | | **`header`** | Allows customization of the modal header content. | | **`content`** | Provides a slot for the main body content of the modal. | | **`footer`** | Allows customization of the footer content within the modal. | You can customize the appearance of the Modal by passing additional CSS. - To customize the header section, you can target the `header` slot with your own CSS classes or styles. - Similarly, you can customize the content section using the `content` slot. - Similarly, you can customize the content section using the `footer` slot. Let's assume you want to use the **`modal`** component, You can call it like this. ``` Modal Toggle Modal Header Modal Content ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-tree) Admin Tree The Tree component in Bagisto enables you to display hierarchical data in a tree-like structure, with support for checkboxes or radio buttons for selection. | Props | Type | Default Value | Description | | --------------------- | --------------------------- | ---------------- | ------------------------------------------------------------------------------------------- | | **`input-type`** | `String` | `'checkbox'` | Specifies the type of input to use for selection. Can be either `checkbox` or `radio`. | | **`selection-type`** | `String` | `'hierarchical'` | Specifies the selection type. Can be `'hierarchical'` or `'individual'`. | | **`name-field`** | `String` | `'permissions'` | The field name to use as the identifier for each tree node. | | **`value-field`** | `String` | `'value'` | The field name to use as the value for each tree node. | | **`id-field`** | `String` | `'id'` | The field name to use as the unique identifier for each tree node. | | **`label-field`** | `String` | `'name'` | The field name to use as the label for each tree node. | | **`children-field`** | `String` | `'children'` | The field name to use for nesting child nodes within each tree node. | | **`items`** | `Array`, `String`, `Object` | `[]` | The hierarchical data to be displayed in the tree structure. | | **`value`** | `Array`, `String`, `Object` | `[]` | The selected values. | | **`fallback-locale`** | `String` | `'en'` | The fallback locale to use for translations. | | **`collapse`** | `Boolean` | `false` | Determines whether the tree nodes are initially collapsed ( `true`) or expanded ( `false`). | Let's assume you want to use the **`tree`** component, You can call it like this. ``` ``` ### [#](https://devdocs.bagisto.com/master/packages/blade-components.html#admin-media-image-video) Admin Media(Image/Video) The Media component in Bagisto provides a user interface for managing and displaying images/videos, allowing users to upload, edit, and delete images.: | Props | Type | Default Value | Description | | ----------------------- | --------- | ------------- | --------------------------------------------------------------- | | **`name`** | `String` | | The name of the input field. | | **`allow-multiple`** | `Boolean` | `false` | Whether to allow uploading multiple images. | | **`show-placeholders`** | `Boolean` | `true` | Whether to show placeholder images when no images are uploaded. | | **`uploaded-images`** | `Array` | `[]` | Array of uploaded images. | | **`uploaded-videos`** | `Array` | `[]` | Array of uploaded videos. | | **`width`** | `String` | `'100%'` | Width of the image container. | | **`height`** | `String` | `'auto'` | Height of the image container. | Let's assume you want to use the **`Image/Video`** component, You can call it like this. ``` ``` [Localization](https://devdocs.bagisto.com/master/packages/localization.html)[Layouts](https://devdocs.bagisto.com/master/packages/layouts.html) ## Bagisto Controller Guide Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/packages/controllers.html#controller) Controller - [Introduction](https://devdocs.bagisto.com/2.2/packages/controllers.html#introduction) - [How to create Controllers](https://devdocs.bagisto.com/2.2/packages/controllers.html#how-to-create-controllers) - [Directory Structure](https://devdocs.bagisto.com/2.2/packages/controllers.html#directory-structure) - [Creating Controller Files](https://devdocs.bagisto.com/2.2/packages/controllers.html#creating-controller-files) - [PostController.php for Admin](https://devdocs.bagisto.com/2.2/packages/controllers.html#postcontroller-php-for-admin) - [PostController.php for Shop](https://devdocs.bagisto.com/2.2/packages/controllers.html#postcontroller-php-for-shop) ## [#](https://devdocs.bagisto.com/2.2/packages/controllers.html#introduction) Introduction In Laravel, controllers are responsible for handling the request logic of an application. They act as intermediaries between the models and views, processing user input, interacting with the data layer, and returning the appropriate responses. By organizing related request handling logic into separate classes, controllers make it easier to manage and maintain the application's codebase. To learn in detail about Controllers, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/controllers). ## [#](https://devdocs.bagisto.com/2.2/packages/controllers.html#how-to-create-controllers) How to create Controllers To start building a controller for our blog posts within the Laravel package named "Blog", follow the steps below: ### [#](https://devdocs.bagisto.com/2.2/packages/controllers.html#directory-structure) Directory Structure Create the necessary directory structure within the `packages/Webkul/Blog/src` path. To create the directory structure follow the following steps: - Navigate to the `packages/Webkul/Blog/src` directory. - Create an `Http` folder inside `src`. - Inside the `Http` folder, create another folder named `Controllers`. - Inside the `Controllers` folder, create one file named `Controller.php` and two folders, namely `Admin` and `Shop`. - Inside both the `Admin` and `Shop` folders, create a `PostController.php` file. The updated directory structure will look like this: ``` └── packages └── Webkul └── Blog └── src ├── ... └── Http └── Controllers ├── Controller.php ├── Admin │ └── PostController.php └── Shop └── PostController.php ``` ### [#](https://devdocs.bagisto.com/2.2/packages/controllers.html#creating-controller-files) Creating Controller Files Now, create the necessary controller files. #### [#](https://devdocs.bagisto.com/2.2/packages/controllers.html#base-controller-controller-php) Base Controller (Controller.php) In `packages/Webkul/Blog/src/Http/Controllers/Controller.php`, you can define the base controller for your package: ``` postRepository->all(); return view('blog::admin.index', compact('blogs')); } /** * Create. * * @return \Illuminate\View\View */ public function create() { // } /** * Store. * * @return \Illuminate\View\View */ public function store(Request $request) { // } /** * Function to update items. */ public function update(int $id) { // } /** * Function to remove items. */ public function destroy(int $id) { // } } ``` ### [#](https://devdocs.bagisto.com/2.2/packages/controllers.html#postcontroller-php-for-shop) PostController.php for Shop In `packages/Webkul/Blog/src/Http/Controllers/Shop/PostController.php`, define the Shop post controller: ``` postRepository->with(['author'])->all(); return view('blog::shop.index', compact('blogs')); } /** * Blog details. * * @return \Illuminate\View\View */ public function view(int $id) { // } } ``` By following these steps, you will have created the necessary structure and files for handling blog posts within your "Blog" package. You can now add the specific logic for each method to handle the functionality required for your blog posts in both the admin and shop areas. [Routes](https://devdocs.bagisto.com/2.2/packages/routes.html)[Views](https://devdocs.bagisto.com/2.2/packages/views.html) ## Bagisto Controllers Guide This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/packages/controllers.html#controller) Controller - [Introduction](https://devdocs.bagisto.com/2.3/packages/controllers.html#introduction) - [How to create Controllers](https://devdocs.bagisto.com/2.3/packages/controllers.html#how-to-create-controllers) - [Directory Structure](https://devdocs.bagisto.com/2.3/packages/controllers.html#directory-structure) - [Creating Controller Files](https://devdocs.bagisto.com/2.3/packages/controllers.html#creating-controller-files) - [PostController.php for Admin](https://devdocs.bagisto.com/2.3/packages/controllers.html#postcontroller-php-for-admin) - [PostController.php for Shop](https://devdocs.bagisto.com/2.3/packages/controllers.html#postcontroller-php-for-shop) ## [#](https://devdocs.bagisto.com/2.3/packages/controllers.html#introduction) Introduction In Laravel, controllers are responsible for handling the request logic of an application. They act as intermediaries between the models and views, processing user input, interacting with the data layer, and returning the appropriate responses. By organizing related request handling logic into separate classes, controllers make it easier to manage and maintain the application's codebase. To learn in detail about Controllers, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/controllers). ## [#](https://devdocs.bagisto.com/2.3/packages/controllers.html#how-to-create-controllers) How to create Controllers To start building a controller for our blog posts within the Laravel package named "Blog", follow the steps below: ### [#](https://devdocs.bagisto.com/2.3/packages/controllers.html#directory-structure) Directory Structure Create the necessary directory structure within the `packages/Webkul/Blog/src` path. To create the directory structure follow the following steps: - Navigate to the `packages/Webkul/Blog/src` directory. - Create an `Http` folder inside `src`. - Inside the `Http` folder, create another folder named `Controllers`. - Inside the `Controllers` folder, create one file named `Controller.php` and two folders, namely `Admin` and `Shop`. - Inside both the `Admin` and `Shop` folders, create a `PostController.php` file. The updated directory structure will look like this: ``` └── packages └── Webkul └── Blog └── src ├── ... └── Http └── Controllers ├── Controller.php ├── Admin │ └── PostController.php └── Shop └── PostController.php ``` ### [#](https://devdocs.bagisto.com/2.3/packages/controllers.html#creating-controller-files) Creating Controller Files Now, create the necessary controller files. #### [#](https://devdocs.bagisto.com/2.3/packages/controllers.html#base-controller-controller-php) Base Controller (Controller.php) In `packages/Webkul/Blog/src/Http/Controllers/Controller.php`, you can define the base controller for your package: ``` postRepository->all(); return view('blog::admin.index', compact('blogs')); } /** * Create. * * @return \Illuminate\View\View */ public function create() { // } /** * Store. * * @return \Illuminate\View\View */ public function store(Request $request) { // } /** * Function to update items. */ public function update(int $id) { // } /** * Function to remove items. */ public function destroy(int $id) { // } } ``` ### [#](https://devdocs.bagisto.com/2.3/packages/controllers.html#postcontroller-php-for-shop) PostController.php for Shop In `packages/Webkul/Blog/src/Http/Controllers/Shop/PostController.php`, define the Shop post controller: ``` postRepository->with(['author'])->all(); return view('blog::shop.index', compact('blogs')); } /** * Blog details. * * @return \Illuminate\View\View */ public function view(int $id) { // } } ``` By following these steps, you will have created the necessary structure and files for handling blog posts within your "Blog" package. You can now add the specific logic for each method to handle the functionality required for your blog posts in both the admin and shop areas. [Routes](https://devdocs.bagisto.com/2.3/packages/routes.html)[Views](https://devdocs.bagisto.com/2.3/packages/views.html) ## Bagisto Installation Requirements Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/introduction/requirements.html#requirements) Requirements - [Server Configuration](https://devdocs.bagisto.com/2.2/introduction/requirements.html#server-configuration) - [PHP Extensions](https://devdocs.bagisto.com/2.2/introduction/requirements.html#php-extensions) - [PHP Configuration](https://devdocs.bagisto.com/2.2/introduction/requirements.html#php-configuration) - [Apache Configuration](https://devdocs.bagisto.com/2.2/introduction/requirements.html#apache-configuration) - [Nginx Configuration](https://devdocs.bagisto.com/2.2/introduction/requirements.html#nginx-configuration) - [Supported Database Servers](https://devdocs.bagisto.com/2.2/introduction/requirements.html#supported-database-servers) ## [#](https://devdocs.bagisto.com/2.2/introduction/requirements.html#server-configuration) Server Configuration - **Server**: Apache 2 or NGINX - **RAM**: 4GB or higher - **Node**: 18.12.0 LTS or higher - **PHP**: 8.1 or higher - **Composer**: 2.5 or higher ## [#](https://devdocs.bagisto.com/2.2/introduction/requirements.html#php-extensions) PHP Extensions Ensure the following extensions are installed and enabled. You can check using the **`phpinfo()`** page or the **`php -m`** command. - **php-intl extension**: This extension is required for internationalization support in Bagisto. - **php-gd extension**: The **`php-gd`** extension must be properly installed to ensure correct image functionality in the project. If not installed correctly, image-related features may not work as expected. Note It is important to ensure proper installation of the **`php-gd`** extension to avoid any issues with image manipulation in Bagisto. ## [#](https://devdocs.bagisto.com/2.2/introduction/requirements.html#php-configuration) PHP Configuration Open your **`php.ini`** file and modify the following settings. - **memory_limit**: Set the **`memory_limit`** directive to **`4G`** or higher to ensure sufficient memory allocation for the application. - **max_execution_time**: Adjust the **`max_execution_time`** directive to **`360`** or higher. This value determines the maximum time (in seconds) a script is allowed to run. Increasing this value ensures that longer operations, such as import/export processes, can be completed successfully. - **date.timezone**: Set the **`date.timezone`** directive to your specific timezone. For example, **`Asia/Kolkata`**. This ensures that date and time-related functions work accurately based on the specified timezone. ``` memory_limit = 4G max_execution_time = 360 date.timezone = Asia/Kolkata <- Change this to your own timezone. ``` Remember to restart your web server Whenever you make changes to the PHP configuration file, be sure to restart Apache or NGINX to apply the modifications. ## [#](https://devdocs.bagisto.com/2.2/introduction/requirements.html#apache-configuration) Apache Configuration To serve Bagisto using Apache, make sure your virtual host is properly configured. Below is a basic `VirtualHost` example suitable for local development: ``` ServerAdmin webmaster@localhost DocumentRoot /var/www/html/bagisto/public Options Indexes FollowSymLinks AllowOverride All Require all granted ``` Note Ensure `DocumentRoot` points to the `public` directory of your Bagisto installation. `AllowOverride All` is essential for Laravel’s `.htaccess` to function correctly. ## [#](https://devdocs.bagisto.com/2.2/introduction/requirements.html#nginx-configuration) Nginx Configuration If you are deploying your Bagisto application to a server that is running Nginx, you may use the following configuration file as a starting point for configuring your web server. Most likely, this file will need to be customized depending on your server's configuration. Please ensure, like the configuration below, your web server directs all requests to your application's `public/index.php` file. You should never attempt to move the `index.php` file to your project's root, as serving the application from the project root will expose many sensitive configuration files to the public Internet: ``` server { listen 80; listen [::]:80; server_name example.com; root /srv/example.com/public; add_header X-Frame-Options "SAMEORIGIN"; add_header X-Content-Type-Options "nosniff"; index index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location ~* ^\/(?!cache).*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|webp|woff|woff2)$ { expires max; access_log off; add_header Cache-Control "public"; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ ^/index\.php(/|$) { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; fastcgi_hide_header X-Powered-By; } location ~ /\.(?!well-known).* { deny all; } } ``` ## [#](https://devdocs.bagisto.com/2.2/introduction/requirements.html#supported-database-servers) Supported Database Servers Bagisto supports the following database servers: - **MySQL**: Version 8.0.32 or higher is recommended for optimal performance and compatibility. - **MariaDB**: Version 10.3 or higher is recommended for optimal performance and compatibility. - **Database Collation**: The recommended collation for the database is **`utf8mb4_unicode_ci`**, which ensures proper handling of Unicode characters and multilingual support. [Introduction](https://devdocs.bagisto.com/2.2/introduction)[Installation](https://devdocs.bagisto.com/2.2/introduction/installation.html) ## Bagisto Controllers Guide Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.x/packages/controllers.html#controller) Controller - [Introduction](https://devdocs.bagisto.com/2.x/packages/controllers.html#introduction) - [How to create Controllers](https://devdocs.bagisto.com/2.x/packages/controllers.html#how-to-create-controllers) - [Directory Structure](https://devdocs.bagisto.com/2.x/packages/controllers.html#directory-structure) - [Creating Controller Files](https://devdocs.bagisto.com/2.x/packages/controllers.html#creating-controller-files) - [PostController.php for Admin](https://devdocs.bagisto.com/2.x/packages/controllers.html#postcontroller-php-for-admin) - [PostController.php for Shop](https://devdocs.bagisto.com/2.x/packages/controllers.html#postcontroller-php-for-shop) ## [#](https://devdocs.bagisto.com/2.x/packages/controllers.html#introduction) Introduction In Laravel, controllers are responsible for handling the request logic of an application. They act as intermediaries between the models and views, processing user input, interacting with the data layer, and returning the appropriate responses. By organizing related request handling logic into separate classes, controllers make it easier to manage and maintain the application's codebase. To learn in detail about Controllers, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/controllers). ## [#](https://devdocs.bagisto.com/2.x/packages/controllers.html#how-to-create-controllers) How to create Controllers To start building a controller for our blog posts within the Laravel package named "Blog", follow the steps below: ### [#](https://devdocs.bagisto.com/2.x/packages/controllers.html#directory-structure) Directory Structure Create the necessary directory structure within the `packages/Webkul/Blog/src` path. To create the directory structure follow the following steps: 1. Navigate to the `packages/Webkul/Blog/src` directory. 2. Create an `Http` folder inside `src`. 3. Inside the `Http` folder, create another folder named `Controllers`. 4. Inside the `Controllers` folder, create one file named `Controller.php` and two folders, namely `Admin` and `Shop`. 5. Inside both the `Admin` and `Shop` folders, create a `PostController.php` file. The updated directory structure will look like this: ``` └── packages └── Webkul └── Blog └── src ├── ... └── Http └── Controllers ├── Controller.php ├── Admin │ └── PostController.php └── Shop └── PostController.php ``` ### [#](https://devdocs.bagisto.com/2.x/packages/controllers.html#creating-controller-files) Creating Controller Files Now, create the necessary controller files. #### [#](https://devdocs.bagisto.com/2.x/packages/controllers.html#base-controller-controller-php) Base Controller (Controller.php) In `packages/Webkul/Blog/src/Http/Controllers/Controller.php`, you can define the base controller for your package: ``` postRepository->all(); return view('blog::admin.index', compact('blogs')); } /** * Create. * * @return \Illuminate\View\View */ public function create() { // } /** * Store. * * @return \Illuminate\View\View */ public function store(Request $request) { // } /** * Function to update items. */ public function update(int $id) { // } /** * Function to remove items. */ public function destroy(int $id) { // } } ``` ### [#](https://devdocs.bagisto.com/2.x/packages/controllers.html#postcontroller-php-for-shop) PostController.php for Shop In `packages/Webkul/Blog/src/Http/Controllers/Shop/PostController.php`, define the Shop post controller: ``` postRepository->with(['author'])->all(); return view('blog::shop.index', compact('blogs')); } /** * Blog details. * * @return \Illuminate\View\View */ public function view(int $id) { // } } ``` By following these steps, you will have created the necessary structure and files for handling blog posts within your "Blog" package. You can now add the specific logic for each method to handle the functionality required for your blog posts in both the admin and shop areas. [Routes](https://devdocs.bagisto.com/2.x/packages/routes.html)[Views](https://devdocs.bagisto.com/2.x/packages/views.html) ## Bagisto Localization Guide Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.1/packages/localization.html#localization) Localization - [Introduction](https://devdocs.bagisto.com/2.1/packages/localization.html#introduction) - [Publishing the Language Files](https://devdocs.bagisto.com/2.1/packages/localization.html#publishing-the-language-files) - [Configuring the Locale](https://devdocs.bagisto.com/2.1/packages/localization.html#configuring-the-locale) - [Create a new Locale](https://devdocs.bagisto.com/2.1/packages/localization.html#create-a-new-locale) - [Directory Structure](https://devdocs.bagisto.com/2.1/packages/localization.html#directory-structure) - [Writing a Translation in app.php](https://devdocs.bagisto.com/2.1/packages/localization.html#writing-a-translation-in-app-php) - [Load Translation from Package](https://devdocs.bagisto.com/2.1/packages/localization.html#load-translation-from-package) - [Update the Service Provider](https://devdocs.bagisto.com/2.1/packages/localization.html#update-the-service-provider) - [Use Translations in Blade Files](https://devdocs.bagisto.com/2.1/packages/localization.html#use-translations-in-blade-files) ## [#](https://devdocs.bagisto.com/2.1/packages/localization.html#introduction) Introduction Laravel's localization features provide a convenient way to retrieve strings in various languages, allowing you to easily support multiple languages within your application. Language strings may be stored in files within the application's lang directory. Within this directory, there may be subdirectories for each language supported by the application. This is the approach Laravel uses to manage translation strings for built-in Laravel features such as validation error messages: To learn in detail about Localization, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/localization). ## [#](https://devdocs.bagisto.com/2.1/packages/localization.html#publishing-the-language-files) Publishing the Language Files By default, the Laravel application skeleton does not include the lang directory. If you would like to customize Laravel's language files or create your own, you should scaffold the lang directory via the lang:publish Artisan command. The lang:publish command will create the lang directory in your application and publish the default set of language files used by Laravel: ``` php artisan lang:publish ``` ## [#](https://devdocs.bagisto.com/2.1/packages/localization.html#configuring-the-locale) Configuring the Locale The default language for your application is stored in the `config/app.php` configuration file's `locale` configuration option, which is typically set using the `APP_LOCALE` environment variable. You are free to modify this value to suit the needs of your application. You may also configure a `"fallback language"`, which will be used when the default language does not contain a given translation string. Like the default language, the fallback language is also configured in the `config/app.php` configuration file, and its value is typically set using the APP_FALLBACK_LOCALE environment variable. ``` /* |-------------------------------------------------------------------------- | Application Locale Configuration |-------------------------------------------------------------------------- | | The application locale determines the default locale that will be used | by the translation service provider. You are free to set this value | to any of the locales which will be supported by the application. | */ 'locale' => env('APP_LOCALE', 'en'), /* |-------------------------------------------------------------------------- | Application Fallback Locale |-------------------------------------------------------------------------- | | The fallback locale determines the locale to use when the current one | is not available. You may change the value to correspond to any of | the language folders that are provided through your application. | */ 'fallback_locale' => 'en', ``` ## [#](https://devdocs.bagisto.com/2.1/packages/localization.html#create-a-new-locale) Create a new Locale To support localization in your package, you need to create language files. Follow the steps below to set up a language file for English translations. #### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#create-the-lang-folder) Create the `lang` Folder - Navigate to the `packages/Webkul/Blog/src/Resources` directory. - Create a folder named `lang`. #### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#create-language-code-folders) Create Language Code Folders - Inside the `lang` folder, create different folders for each language you want to support. For example, you can create folders for English ( `en`), Hindi ( `hi`), etc. - For now, let's create a folder named `en` to represent English. #### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#create-the-app-php-file) Create the `app.php` File - Inside the `en` folder, create a file named `app.php` for language translations. ### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#directory-structure) Directory Structure The updated directory structure will look like this: ``` └── packages └── Webkul └── Blog └── src ├── ... └── Resources ├── ... └── lang └── en └── app.php ``` ### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#writing-a-translation-in-app-php) Writing a Translation in `app.php` To add translations for your package, you can edit the `app.php` file located in the language folder ( `en` in this case). Below is an example of how you can define translations: #### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#open-the-app-php-file) Open the `app.php` File - Navigate to `packages/Webkul/Blog/src/Resources/lang/en`. - Open the `app.php` file. #### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#add-the-translation) Add the Translation - Inside `app.php`, define your translations as an associative array. For example: ``` [\ 'name' => 'John Doe'\ ]\ ]; ``` ## [#](https://devdocs.bagisto.com/2.1/packages/localization.html#load-translation-from-package) Load Translation from Package To make translations from your package accessible, you need to register the language file in the service provider and then use them in your Blade templates. ### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#update-the-service-provider) Update the Service Provider - Open the `BlogServiceProvider.php` file located in `packages/Webkul/Blog/src/Providers`. - Add the following code to the `boot` method: ``` loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'blog'); } } ``` #### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#explanation) Explanation - This code uses `$this->loadTranslationsFrom` to register translations from the lang directory of your package ( `packages/ Webkul/Blog/src/Resources/lang`) under the namespace `'blog'`. - The `loadTranslationsFrom` method registers translations for the `'blog'` namespace from the specified path ( `__DIR__ . '/../Resources/lang'`). - This makes translations accessible throughout your Laravel application using the `'blog'` namespace prefix. ### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#use-translations-in-blade-files) Use Translations in Blade Files In your Blade templates ( `.blade.php` files), you can use the `@lang` helper function to retrieve translations. Use the namespace 'blog' followed by the translation key. For example: ``` @lang('blog::app.admin.name') ``` #### [#](https://devdocs.bagisto.com/2.1/packages/localization.html#explanation-2) Explanation - The `@lang('blog::app.admin.name')` syntax fetches the translation for `'name'` under the `'admin'` section from your package's translation file ( `app.php`). - Replace `'app.admin.name'` with your actual translation keys to use different translations as needed in your application. By following these steps, you've effectively loaded translations from your package and integrated them into your Laravel application's Blade templates. This allows you to maintain language-specific content and support localization within your package. [Views](https://devdocs.bagisto.com/2.1/packages/views.html)[Blade Components](https://devdocs.bagisto.com/2.1/packages/blade-components.html) ## Bagisto Events Overview Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.1/advanced/events.html#events) Events - [Introduction](https://devdocs.bagisto.com/2.1/advanced/events.html#introduction) - [Creating an Event Class](https://devdocs.bagisto.com/2.1/advanced/events.html#creating-an-event-class) - [Using Package Generator](https://devdocs.bagisto.com/2.1/advanced/events.html#using-package-generator) - [Manually Registering Events](https://devdocs.bagisto.com/2.1/advanced/events.html#manually-registering-events) - [Manually Registering Listeners](https://devdocs.bagisto.com/2.1/advanced/events.html#manually-registering-listeners) - [Specifying Events](https://devdocs.bagisto.com/2.1/advanced/events.html#specifying-events) - [Events Fired in Bagisto](https://devdocs.bagisto.com/2.1/advanced/events.html#events-fired-in-bagisto) - [Events Listen in Bagisto](https://devdocs.bagisto.com/2.1/advanced/events.html#events-listen-in-bagisto) - [Listening to Existing Events](https://devdocs.bagisto.com/2.1/advanced/events.html#listening-to-existing-events) - [Registering a Listener](https://devdocs.bagisto.com/2.1/advanced/events.html#registering-a-listener) ## [#](https://devdocs.bagisto.com/2.1/advanced/events.html#introduction) Introduction Event Listeners in Bagisto are a way to implement the observer pattern, where listeners respond to events that occur in the application. Events can be thought of as announcements made by the application, and listeners are the actions taken in response to those announcements. All event classes in Bagisto are stored in the `Providers` folder, and the listeners are stored in the `Listeners` folder. In Bagisto, events and listeners are organized in a clear and structured manner: - Events are typically stored in the Events folder. - Listeners are stored in the Listeners folder. This organization makes it easy to manage and locate the event-driven components of your application. To learn in detail about Controllers, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/events). ## [#](https://devdocs.bagisto.com/2.1/advanced/events.html#creating-an-event-class) Creating an Event Class ### [#](https://devdocs.bagisto.com/2.1/advanced/events.html#using-package-generator) Using Package Generator If you have the Bagisto Package Generator installed, you can use the following command to create a new event class in the `packages/Webkul/CustomEvent/src/Events` directory: ``` php artisan package:make-event CustomEvent Webkul/CustomEvent ``` If the event class already exists, you can use the --force option to overwrite it: ``` php artisan package:make-event CustomEvent Webkul/CustomEvent --force ``` Alternatively, if you don't have the package generator, you can create the file manually by creating a new class in the `packages/Webkul/CustomEvent/src/Events` directory. ### [#](https://devdocs.bagisto.com/2.1/advanced/events.html#manually-registering-events) Manually Registering Events In Bagisto, you register events manually in the `boot` method of your `EventServiceProvider.php` file. Here is an example of how to register events: ``` /** * Register any other events for your application. * * @return void */ public function boot() { //... Event::listen('event.name', 'path-upto-listener@function'); } ``` In this example, `event.name` is the name of the event, and `path-upto-listener@function` is the listener method that will handle the event. ### [#](https://devdocs.bagisto.com/2.1/advanced/events.html#manually-registering-listeners) Manually Registering Listeners When registering events, you specify the listener function to be executed when an event is triggered. Here is an example of how to register a listener: ``` class EventServiceProvider extends ServiceProvider { /** * Bootstrap services. * * @return void */ public function boot() { //... Event::listen('checkout.order.save.after', 'Webkul\Admin\Listeners\Order@sendNewOrderMail'); } } ``` In this example, the `checkout.order.save.after` event will trigger the `sendNewOrderMail` method of the `Order` listener in the `Webkul\Admin\Listeners` namespace. ## [#](https://devdocs.bagisto.com/2.1/advanced/events.html#specifying-events) Specifying Events In Bagisto, events are typically fired before and after the execution of CRUD operations. This allows listeners to perform additional actions, such as logging, notifications, or data manipulation, at specific points in the lifecycle of an operation. For example, you might have events fired during product creation, updating, or deletion. Here’s an example of firing events before and after saving an order: ``` namespace Webkul\Sales\Repositories; use Webkul\Sales\Contracts\Order; class OrderRepository extends Repository { public function create(array $data) { Event::dispatch('sales.order.create.before', $data); $order = parent::create($data); Event::dispatch('sales.order.create.after', $order); return $order; } } ``` ## [#](https://devdocs.bagisto.com/2.1/advanced/events.html#events-fired-in-bagisto) Events Fired in Bagisto In Bagisto, there are several events fired throughout its operations, allowing developers to hook into specific points in the application's lifecycle to customize behavior or add functionality. Here's a list of events that are fired in Bagisto, which you can listen to and handle as needed by creating event listeners: | Events name | Functionality | | ---------------------------------------- | ----------------------------------------------------------------- | | catalog.attribute.create.before | This event will be fired before attribute gets created. | | catalog.attribute.create.after | This event will be fired after attribute gets created. | | catalog.attribute.update.before | This event will be fired before attribute gets updated. | | catalog.attribute.update.after | This event will be fired after attribute gets updated. | | catalog.attribute.delete.before | This event will be fired before attribute gets deleted. | | catalog.attribute.delete.after | This event will be fired after attribute gets deleted. | | catalog.attribute_family.create.before | This event will be fired before attribute family gets created. | | catalog.attribute_family.create.after | This event will be fired after attribute family gets created. | | catalog.attribute_family.update.before | This event will be fired before updating attribute family. | | catalog.attribute_family.update.after | This event will be fired after updating attribute family. | | catalog.attribute_family.delete.before | This event will be fired before deleting attribute family. | | catalog.attribute_family.delete.after | This event will be fired after deleting attribute family. | | catalog.category.create.before | This event will be fired before creating category. | | catalog.category.create.after | This event will be fired after creating category. | | catalog.category.update.before | This event will be fired before updating category. | | catalog.category.update.after | This event will be fired after updating category. | | catalog.category.delete.before | This event will be fired before deleting category. | | catalog.category.delete.after | This event will be fired after deleting category. | | catalog.categories.mass-update.before | This event will be fired before bulk category update. | | catalog.categories.mass-update.after | This event will be fired after bulk category update. | | catalog.product.create.before | This event will be fired before product gets created. | | catalog.product.create.after | This event will be fired after product gets created. | | catalog.product.update.before | This event will be fired before product gets updated. | | catalog.product.update.after | This event will be fired after product gets updated. | | catalog.product.delete.before | This event will be fired before product gets deleted. | | catalog.product.delete.after | This event will be fired after product gets deleted. | | products.datagrid.sync | This event will be fired to synicing datagrid product. | | cms.pages.create.before | This event will be fired before cms page gets created. | | cms.pages.create.after | This event will be fired after cms page gets created. | | cms.pages.update.before | This event will be fired before cms page gets updated. | | cms.pages.update.after | This event will be fired after cms page gets updated. | | cms.pages.delete.before | This event will be fired before cms page gets deleted. | | cms.pages.delete.after | This event will be fired after cms page gets deleted. | | customer.addresses.create.before | This event will be fired before customer address gets created. | | customer.addresses.create.after | This event will be fired after customer address gets created. | | customer.addresses.update.before | This event will be fired before customer address gets updated. | | customer.addresses.update.after | This event will be fired after customer address gets updated. | | customer.addresses.delete.before | This event will be fired before customer address gets deleted. | | customer.addresses.delete.after | This event will be fired after customer address gets deleted. | | customer.registration.before | This event will be fired before customer gets created. | | customer.registration.after | This event will be fired after customer gets created. | | customer.login.after | This event will be fired after customer gets login. | | customer.logout.after | This event will be fired after customer gets logout. | | customer.update.before | This event will be fired before customer gets updated. | | customer.update.after | This event will be fired after customer gets updated. | | customer.password.update.after | This event will be fired after customer password gets updated. | | customer.note-created.after | This event will be fired after customer note gets created. | | customer.subscription.before | This event will be fired before customer gets subscription. | | customer.subscription.after | This event will be fired after customer gets subscription. | | customer.delete.before | This event will be fired before customer gets deleted. | | customer.delete.after | This event will be fired after customer gets deleted. | | customer.customer_group.create.before | This event will be fired before customer group gets created. | | customer.customer_group.create.after | This event will be fired after customer group gets created. | | customer.customer_group.update.before | This event will be fired before customer group gets updated. | | customer.customer_group.update.after | This event will be fired after customer group gets updated. | | customer.customer_group.delete.before | This event will be fired before customer group gets deleted. | | customer.customer_group.delete.after | This event will be fired after customer group gets deleted. | | customer.review.update.before | This event will be fired before customer review gets updated. | | customer.review.update.after | This event will be fired after customer review gets updated. | | customer.review.delete.before | This event will be fired before customer review gets deleted. | | customer.review.delete.after | This event will be fired after customer review gets deleted. | | marketing.sitemaps.create.before | This event will be fired before sitemaps gets created. | | marketing.sitemaps.create.after | This event will be fired after sitemaps gets created. | | marketing.sitemaps.update.before | This event will be fired before sitemaps gets updated. | | marketing.sitemaps.update.after | This event will be fired after sitemaps gets updated. | | marketing.sitemaps.delete.before | This event will be fired before sitemaps gets deleted. | | marketing.sitemaps.delete.after | This event will be fired after sitemaps gets deleted. | | marketing.campaigns.create.before | This event will be fired before campaigns gets created. | | marketing.campaigns.create.after | This event will be fired after campaigns gets created. | | marketing.campaigns.update.before | This event will be fired before campaigns gets updated. | | marketing.campaigns.update.after | This event will be fired after campaigns gets updated. | | marketing.campaigns.delete.before | This event will be fired before campaigns gets deleted. | | marketing.campaigns.delete.after | This event will be fired after campaigns gets deleted. | | marketing.events.create.before | This event will be fired before marketing event gets created. | | marketing.events.create.after | This event will be fired after marketing event gets created. | | marketing.events.update.before | This event will be fired before marketing event gets updated. | | marketing.events.update.after | This event will be fired after marketing event gets updated. | | marketing.events.delete.before | This event will be fired before marketing event gets deleted. | | marketing.events.delete.after | This event will be fired after marketing event gets deleted. | | marketing.templates.create.before | This event will be fired before templates gets created. | | marketing.templates.create.after | This event will be fired after templates gets created. | | marketing.templates.update.before | This event will be fired before templates gets updated. | | marketing.templates.update.after | This event will be fired after templates gets updated. | | marketing.templates.delete.before | This event will be fired before templates gets deleted. | | marketing.templates.delete.after | This event will be fired after templates gets deleted. | | promotions.cart_rule.create.before | This event will be fired before cart rule gets created. | | promotions.cart_rule.create.after | This event will be fired after cart rule gets created. | | promotions.cart_rule.update.before | This event will be fired before cart rule gets updated. | | promotions.cart_rule.update.after | This event will be fired after cart rule gets updated. | | promotions.cart_rule.delete.before | This event will be fired before cart rule gets deleted. | | promotions.cart_rule.delete.after | This event will be fired after cart rule gets deleted. | | promotions.catalog_rule.create.before | This event will be fired before catalog rule gets created. | | promotions.catalog_rule.create.after | This event will be fired after catalog rule gets created. | | promotions.catalog_rule.update.before | This event will be fired before catalog rule gets updated. | | promotions.catalog_rule.update.after | This event will be fired after catalog rule gets updated. | | promotions.catalog_rule.delete.before | This event will be fired before catalog rule gets deleted. | | promotions.catalog_rule.delete.after | This event will be fired after catalog rule gets deleted. | | sales.order.comment.create.before | This event will be fired before order comment gets created. | | sales.order.comment.create.after | This event will be fired after order comment gets created. | | core.channel.create.before | This event will be fired before channel gets created. | | core.channel.create.after | This event will be fired after channel gets created. | | core.channel.update.before | This event will be fired before channel gets updated. | | core.channel.update.after | This event will be fired after channel gets updated. | | core.channel.delete.before | This event will be fired before channel gets deleted. | | core.channel.delete.after | This event will be fired after channel gets deleted. | | core.exchange_rate.create.before | This event will be fired before exchange rate gets created. | | core.exchange_rate.create.after | This event will be fired after exchange rate gets created. | | core.exchange_rate.update.before | This event will be fired before exchange rate gets updated. | | core.exchange_rate.update.after | This event will be fired after exchange rate gets updated. | | core.exchange_rate.delete.before | This event will be fired before exchange rate gets deleted. | | core.exchange_rate.delete.after | This event will be fired after exchange rate gets deleted. | | inventory.inventory_source.create.before | This event will be fired before inventory source gets created. | | inventory.inventory_source.create.after | This event will be fired after inventory source gets created. | | inventory.inventory_source.update.before | This event will be fired before inventory source gets updated. | | inventory.inventory_source.update.after | This event will be fired after inventory source gets updated. | | inventory.inventory_source.delete.before | This event will be fired before inventory source gets deleted. | | inventory.inventory_source.delete.after | This event will be fired after inventory source gets deleted. | | user.role.create.before | This event will be fired before role gets created. | | user.role.create.after | This event will be fired after role gets created. | | user.role.update.before | This event will be fired before role gets updated. | | user.role.update.after | This event will be fired after role gets updated. | | user.role.delete.before | This event will be fired before role gets deleted. | | user.role.delete.after | This event will be fired after role gets deleted. | | theme_customization.create.before | This event will be fired before theme customization gets created. | | theme_customization.create.after | This event will be fired after theme customization gets created. | | theme_customization.update.before | This event will be fired before theme customization gets updated. | | theme_customization.update.after | This event will be fired after theme customization gets updated. | | theme_customization.delete.before | This event will be fired before theme customization gets deleted. | | theme_customization.delete.after | This event will be fired after theme customization gets deleted. | | user.admin.create.before | This event will be fired before admin gets created. | | user.admin.create.after | This event will be fired after admin gets created. | | user.admin.update.before | This event will be fired before admin gets updated. | | user.admin.update.after | This event will be fired after admin gets updated. | | admin.password.update.after | This event will be fired after admin password gets updated. | | user.admin.delete.before | This event will be fired before admin gets deleted. | | user.admin.delete.after | This event will be fired after admin gets deleted. | | tax.category.create.before | This event will be fired before tax category gets created. | | tax.category.create.after | This event will be fired after tax category gets created. | | tax.category.update.before | This event will be fired before tax category gets updated. | | tax.category.update.after | This event will be fired after tax category gets updated. | | tax.category.delete.before | This event will be fired before tax category gets deleted. | | tax.category.delete.after | This event will be fired after tax category gets deleted. | | tax.rate.create.before | This event will be fired before tax rate gets created. | | tax.rate.create.after | This event will be fired after tax rate gets created. | | tax.rate.update.before | This event will be fired before tax rate gets updated. | | tax.rate.update.after | This event will be fired after tax rate gets updated. | | tax.rate.delete.before | This event will be fired before tax rate gets deleted. | | tax.rate.delete.after | This event will be fired after tax rate gets deleted. | | checkout.cart.delete.before | This event will be fired before cart item gets deleted. | | checkout.cart.delete.after | This event will be fired after cart item gets deleted. | | checkout.cart.delete.all.before | This event will be fired before all cart items gets deleted. | | checkout.cart.delete.all.after | This event will be fired after all cart item gets deleted. | | checkout.cart.add.before | This event will be fired before cart item gets created. | | checkout.cart.add.after | This event will be fired after cart item gets created. | | checkout.cart.update.before | This event will be fired before cart item gets updated. | | checkout.cart.update.after | This event will be fired after cart item gets updated. | | checkout.cart.collect.totals.before | This event will be fired before collecting cart totals. | | checkout.cart.collect.totals.after | This event will be fired after collecting cart totals. | | checkout.cart.calculate.items.tax.before | This event will be fired before calculating cart items tax. | | checkout.cart.calculate.items.tax.after | This event will be fired after calculating cart items tax. | | core.configuration.save.before | This event will be fired before core configuration gets saved. | | core.configuration.save.after | This event will be fired after core configuration gets saved. | | core.currency.create.before | This event will be fired before currency gets created. | | core.currency.create.after | This event will be fired after currency gets created. | | core.currency.update.before | This event will be fired before currency gets updated. | | core.currency.update.after | This event will be fired after currency gets updated. | | core.currency.delete.before | This event will be fired before currency gets deleted. | | core.currency.delete.after | This event will be fired after currency gets deleted. | | core.locale.create.before | This event will be fired before locale gets created. | | core.locale.create.after | This event will be fired after locale gets created. | | core.locale.update.before | This event will be fired before locale gets updated. | | core.locale.update.after | This event will be fired after locale gets updated. | | core.locale.delete.before | This event will be fired before locale gets deleted. | | core.locale.delete.after | This event will be fired after locale gets deleted. | | sales.invoice.save.before | This event will be fired before invoice gets saved. | | sales.invoice.save.after | This event will be fired after invoice gets saved. | | checkout.order.save.before | This event will be fired before order gets saved. | | checkout.order.save.after | This event will be fired after order gets saved. | | checkout.order.orderitem.save.before | This event will be fired before order item gets saved. | | checkout.order.orderitem.save.after | This event will be fired after order item gets saved. | | sales.order.cancel.before | This event will be fired before order gets canceled. | | sales.order.cancel.after | This event will be fired after order gets canceled. | | sales.order.update-status.before | This event will be fired before order status gets updated. | | sales.order.update-status.after | This event will be fired after order status gets updated. | | sales.refund.save.before | This event will be fired before order refund gets saved. | | sales.refund.save.after | This event will be fired after order refund gets saved. | | sales.shipment.save.before | This event will be fired before shipment gets saved. | | sales.shipment.save.after | This event will be fired after shipment gets saved. | | checkout.load.index | This event will be fired on checkout page load. | | shop.item.buy-now | This event will be fired directly on the Buy Now product. | ## [#](https://devdocs.bagisto.com/2.1/advanced/events.html#events-listen-in-bagisto) Events Listen in Bagisto - Event listen in bagisto is given below with their functionality. | Events name | functionality | | ------------------------------------------------- | ------------------------------------------------------------------------ | | bagisto.shop.layout.body.after | Listing this event to load css of shop layout. | | bagisto.admin.layout.head | Listing this event to load css of admin layout. | | checkout.order.save.after | Listing this event to send notification of new order. | | sales.order.update-status.after | Listing this event to send notification of when order status is changed. | | sales.invoice.save.after | Listing this event to add paypal smart button. | | bagisto.shop.customers.login_form_controls.before | Listing this event to add social login buttons. | | bagisto.shop.products.view.compare.after | Listing this event to add social share buttons. | ## [#](https://devdocs.bagisto.com/2.1/advanced/events.html#listening-to-existing-events) Listening to Existing Events Bagisto uses events and listeners to implement the observer pattern, allowing you to respond to various actions and events within the application. You can listen to specific events and execute custom code when those events are triggered. ### [#](https://devdocs.bagisto.com/2.1/advanced/events.html#registering-a-listener) Registering a Listener Open the `EventServiceProvider.php` file located in the `Providers` directory of your Bagisto application. This file is where you register event listeners. Inside the `boot()` method of `EventServiceProvider.php`, use the `Event::listen` method to register your listener. This method takes the event name and a callback function or a class method that will handle the event. ``` Event::listen('checkout.order.save.after', 'Webkul\Notification\Listeners\Order@createOrder'); ``` In the example above, we are listening to the `checkout.order.save.after` event and specifying the `createOrder` function from the `Order` listener class in the `Webkul\Notification\Listeners` namespace. Replace `'checkout.order.save.after'` with the specific event you want to listen to. In this example, it listens to the event triggered after saving an order during checkout. By registering the listener, you have associated the **`createOrder`** function with the **`checkout.order.save.after`** event. Whenever this event is triggered, the specified function will be executed. You can modify the listener function according to your requirements to perform the desired operation. [Product Type](https://devdocs.bagisto.com/2.1/advanced/create-product-type.html)[Helpers](https://devdocs.bagisto.com/2.1/advanced/helpers.html) ## Bagisto Views Documentation Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.2/packages/views.html#views) Views - [Introduction](https://devdocs.bagisto.com/2.2/packages/views.html#introduction) - [Directory Structure](https://devdocs.bagisto.com/2.2/packages/views.html#directory-structure) - [Adding HTML Content](https://devdocs.bagisto.com/2.2/packages/views.html#adding-html-content) - [Load Views from Package](https://devdocs.bagisto.com/2.2/packages/views.html#load-views-from-package) - [Rendering Views](https://devdocs.bagisto.com/2.2/packages/views.html#rendering-views) - [Blade File Naming Convention](https://devdocs.bagisto.com/2.2/packages/views.html#blade-file-naming-convention) - [Listing (Index Blade):](https://devdocs.bagisto.com/2.2/packages/views.html#listing-index-blade) - [Creation (Create Blade):](https://devdocs.bagisto.com/2.2/packages/views.html#creation-create-blade) - [Updating (Edit Blade):](https://devdocs.bagisto.com/2.2/packages/views.html#updating-edit-blade) ## [#](https://devdocs.bagisto.com/2.2/packages/views.html#introduction) Introduction Views in Laravel are responsible for separating the application's logic from the presentation layer. They provide a clean way to manage and organize the HTML content of your application. Views are typically stored in the `resources/views` directory and are rendered using the Blade templating engine, which offers a simple and powerful way to create dynamic content. By using views, you can create reusable templates and components, making your code more maintainable and easier to understand. Blade templates allow you to use control structures like loops and conditionals, as well as to include other templates, which helps to keep your views organized and modular. To learn in detail about Views, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/views). Here's a basic example of a Blade template: ## [#](https://devdocs.bagisto.com/2.2/packages/views.html#directory-structure) Directory Structure To organize the views for our blog package, we need to set up a specific directory structure. Follow the steps below to create the necessary folders. #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#create-the-resources-folder) Create the `Resources` Folder - Navigate to the `packages/Webkul/Blog/src` directory. - Create a folder named `Resources`. #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#create-the-views-folder) Create the `views` Folder - Inside the `Resources` folder, create another folder named `views`. #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#create-the-admin-and-shop-folders) Create the `admin` and `shop` Folders - Inside the `views` folder, create two folders named `admin` and `shop`. The updated directory structure will look like this: ``` └── packages └── Webkul └── Blog └── src ├── ... └── Resources └── views ├── admin └── shop ``` #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#create-the-index-blade-php-file-in-the-shop-folder) Create the `index.blade.php` File in the `shop` Folder - Inside the `shop/default` folder, create a file named `index.blade.php`, `create.blade.php`, `edit.blade.php` . ``` └── packages └── Webkul └── Blog └── src ├── ... └── Resources └── views ├── admin │ └── index.blade.php └── shop └── index.blade.php └── create.blade.php └── edit.blade.php ``` ### [#](https://devdocs.bagisto.com/2.2/packages/views.html#adding-html-content) Adding HTML Content Below is an example of basic HTML content that you can add to each `index.blade.php` file. #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#index-blade-php-in-the-admin-folder) `index.blade.php` in the `admin` Folder ``` Admin - Blog Posts

Admin - Blog Posts

Welcome to the admin section for managing blog posts.

``` #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#index-blade-php-in-the-default-folder) `index.blade.php` in the `default` Folder ``` Shop - Blog Posts

Shop - Blog Posts

Welcome to the shop section for viewing blog posts.

``` ## [#](https://devdocs.bagisto.com/2.2/packages/views.html#load-views-from-package) Load Views from Package To make the views in our package accessible, we need to register them in the service provider's `boot` method. This involves updating the `BlogServiceProvider.php` file to include the view loading logic. Follow the steps below: #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#open-the-service-provider-file) Open the Service Provider File - Navigate to the `packages/Webkul/Blog/src/Providers` directory. - Open the `BlogServiceProvider.php` file. #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#update-the-boot-method) Update the `boot` Method - Inside the `boot` method of the `BlogServiceProvider` class, add the logic to load views from the package. #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#updated-blogserviceprovider-php) Updated `BlogServiceProvider.php` Here is the updated code for `BlogServiceProvider.php`: ``` loadViewsFrom(__DIR__ . '/../Resources/views', 'blog'); } } ``` #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#explanation) Explanation - The `namespace` keyword defines the namespace for the `BlogServiceProvider` class, which is `Webkul\Blog\Providers`. - The `BlogServiceProvider` class extends Laravel's base `ServiceProvider` class. - The `boot` method is used to bootstrap any application services. - Inside the `boot` method, we use the `$this->loadViewsFrom` method to register the views from the package. - The `loadViewsFrom` method takes two arguments: - The path to the views directory within the package: `__DIR__ . '/../Resources/views'`. - A namespace for the views: `'blog'`. ## [#](https://devdocs.bagisto.com/2.2/packages/views.html#rendering-views) Rendering Views In Laravel applications, views are typically rendered from controller methods using the `view` helper function. This section describes how views are invoked and passed data from a controller. ``` postRepository->with(['author'])->all(); return view('blog::shop.index', compact('blogs')); } } ``` #### [#](https://devdocs.bagisto.com/2.2/packages/views.html#explanation-2) Explanation - The `view` helper function in Laravel is used within the `index` method of the `PostController` to render the `shop.index` view. - It accepts two parameters the name of the view ( `blog::shop.index`) and an array of data ( `compact('blogs')`) to pass to the `view`. ## [#](https://devdocs.bagisto.com/2.2/packages/views.html#blade-file-naming-convention) Blade File Naming Convention Bagisto utilizes Blade templates to handle `listing`, `creation`, and `updating` operations for resources like products, posts, and categories. This section provides a detailed guide on how to implement these operations using Blade templates within your Bagisto package. ### [#](https://devdocs.bagisto.com/2.2/packages/views.html#listing-index-blade) Listing (Index Blade): - The `index.blade.php` template is used to display a list of all records (posts). - The controller's `index` method fetches all posts and passes them to the view. ### [#](https://devdocs.bagisto.com/2.2/packages/views.html#creation-create-blade) Creation (Create Blade): - The `create.blade.php` template contains a form for creating new records. - The controller's `create` method renders this view. ### [#](https://devdocs.bagisto.com/2.2/packages/views.html#updating-edit-blade) Updating (Edit Blade): - The `edit.blade.php` template contains a form for editing existing records. - The controller's `edit` method fetches the specific post and passes it to the view. By following these steps, you can effectively utilize Blade templates in Bagisto for listing, creating, and updating resources, ensuring a structured and maintainable approach to managing CRUD operations within your application. [Controllers](https://devdocs.bagisto.com/2.2/packages/controllers.html)[Localization](https://devdocs.bagisto.com/2.2/packages/localization.html) ## Bagisto Attributes API Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/api/attributes.html#attributes) Attributes In this section, we are using the attributes' API. An Attribute is a specification or characteristics of a product for example color, size, pattern are an attribute of T-Shirt. You can as create many attributes for a single product. Product Attribute plays a major factor in buying decision of the Customer. ## [#](https://devdocs.bagisto.com/1.x/api/attributes.html#get-all-attributes) Get all attributes This api request will fetch all the attributes. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET /api/attributes(?limit,page,pagination)` - Params | Name | Info | Type | | ---------- | -------------------------------------------- | ------ | | limit | Maximum number of records in each request | Number | | page | Records for specific page based on the limit | Number | | pagination | will display all the records if set to `0` | Number | TIP If you are using pagination and want to know more info about responses then check the [explanation](https://devdocs.bagisto.com/1.x/api/explanation) portion. ### [#](https://devdocs.bagisto.com/1.x/api/attributes.html#examples) Examples #### [#](https://devdocs.bagisto.com/1.x/api/attributes.html#_1-get-attributes-of-the-specific-page) 1\. Get attributes of the specific page - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/attributes?page=1` TIP If you didn't use the page (?page=x) filter, then it returns the data of the first page by default. `GET http(s)://example.com/api/attributes` Response ``` { "data": [\ {\ "id":27,\ "code":"product_number",\ "type":"text",\ "name":"Product Number",\ "swatch_type":null,\ "options":[],\ "created_at":"2021-05-24T05:09:12.000000Z",\ "updated_at":"2021-05-24T05:09:12.000000Z"\ },\ {...},\ {...}\ ], "links": { "first": "https://example.com/api/attributes?page=1", "last": "https://example.com/api/attributes?page=3", "prev": null, "next": "https://example.com/api/attributes?page=2" }, "meta": { "current_page": 1, "from": 1, "last_page": 3, "links": [...], "path": "https://example.com/api/attributes", "per_page": 10, "to": 10, "total": 27 } } ``` #### [#](https://devdocs.bagisto.com/1.x/api/attributes.html#_2-get-attributes-of-the-specific-page-with-limit) 2\. Get attributes of the specific page with limit - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/attributes?page=1&limit=5` Response ``` { "data": [\ {\ "id": 27,\ "code": "product_number",\ "type": "text",\ "name": "Product Number",\ "swatch_type": null,\ "options": [],\ "created_at": "2021-05-24T05:09:12.000000Z",\ "updated_at": "2021-05-24T05:09:12.000000Z"\ },\ {\ "id": 26,\ "code": "guest_checkout",\ "type": "boolean",\ "name": "Allow Guest Checkout",\ "swatch_type": null,\ "options": [],\ "created_at": "2021-05-24T05:09:12.000000Z",\ "updated_at": "2021-05-24T05:09:12.000000Z"\ },\ {\ "id": 25,\ "code": "brand",\ "type": "select",\ "name": "Brand",\ "swatch_type": null,\ "options": [],\ "created_at": "2021-05-24T05:09:12.000000Z",\ "updated_at": "2021-05-24T05:09:12.000000Z"\ },\ {\ "id": 24,\ "code": "size",\ "type": "select",\ "name": "Size",\ "swatch_type": null,\ "options": [\ { "id": 6, "admin_name": "S", "label": "S", "swatch_value": null },\ { "id": 7, "admin_name": "M", "label": "M", "swatch_value": null },\ { "id": 8, "admin_name": "L", "label": "L", "swatch_value": null },\ { "id": 9, "admin_name": "XL", "label": "XL", "swatch_value": null }\ ],\ "created_at": "2021-05-24T05:09:12.000000Z",\ "updated_at": "2021-05-24T05:09:12.000000Z"\ },\ {\ "id": 23,\ "code": "color",\ "type": "select",\ "name": "Color",\ "swatch_type": null,\ "options": [\ { "id": 1, "admin_name": "Red", "label": "Red", "swatch_value": null },\ {\ "id": 2,\ "admin_name": "Green",\ "label": "Green",\ "swatch_value": null\ },\ {\ "id": 3,\ "admin_name": "Yellow",\ "label": "Yellow",\ "swatch_value": null\ },\ {\ "id": 4,\ "admin_name": "Black",\ "label": "Black",\ "swatch_value": null\ },\ {\ "id": 5,\ "admin_name": "White",\ "label": "White",\ "swatch_value": null\ }\ ],\ "created_at": "2021-05-24T05:09:12.000000Z",\ "updated_at": "2021-05-24T05:09:12.000000Z"\ }\ ], "links": { "first": "https://example.com/api/attributes?limit=5&page=1", "last": "https://example.com/api/attributes?limit=5&page=6", "prev": null, "next": "https://example.com/api/attributes?limit=5&page=2" }, "meta": { "current_page": 1, "from": 1, "last_page": 6, "links": [\ {\ "url": null,\ "label": "« Previous",\ "active": false\ },\ {\ "url": "https://example.com/api/attributes?limit=5&page=1",\ "label": "1",\ "active": true\ },\ {\ "url": "https://example.com/api/attributes?limit=5&page=2",\ "label": "2",\ "active": false\ },\ {\ "url": "https://example.com/api/attributes?limit=5&page=3",\ "label": "3",\ "active": false\ },\ {\ "url": "https://example.com/api/attributes?limit=5&page=4",\ "label": "4",\ "active": false\ },\ {\ "url": "https://example.com/api/attributes?limit=5&page=5",\ "label": "5",\ "active": false\ },\ {\ "url": "https://example.com/api/attributes?limit=5&page=6",\ "label": "6",\ "active": false\ },\ {\ "url": "https://example.com/api/attributes?limit=5&page=2",\ "label": "Next »",\ "active": false\ }\ ], "path": "https://example.com/api/attributes", "per_page": "5", "to": 5, "total": 27 } } ``` #### [#](https://devdocs.bagisto.com/1.x/api/attributes.html#_3-get-all-attributes-without-pagination) 3\. Get all attributes without pagination If you don't want to use the pagination and want to access all the store's attributes at once, then you have to send a filter parameter named as `pagination` with value `zero`. By doing this you will get all attributes objects at once in the data object and this will not give you link and meta objects. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/attributes?pagination=0` Response ``` { "data": [\ {\ "id": 27,\ "code": "product_number",\ "type": "text",\ "name": "Product Number",\ "swatch_type": null,\ "options": [],\ "created_at": "2021-05-24T05:09:12.000000Z",\ "updated_at": "2021-05-24T05:09:12.000000Z"\ },\ {\ "id": 26,\ "code": "guest_checkout",\ "type": "boolean",\ "name": "Allow Guest Checkout",\ "swatch_type": null,\ "options": [],\ "created_at": "2021-05-24T05:09:12.000000Z",\ "updated_at": "2021-05-24T05:09:12.000000Z"\ },\ {...},\ {...},\ {...},\ {...}\ ] } ``` ## [#](https://devdocs.bagisto.com/1.x/api/attributes.html#get-attribute-by-id) Get attribute by id For fetching any specific attribute, you have to provide the attribute's id as an input parameter. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET /api/attributes/{id}` - Params | Name | Info | Type | | ---- | -------------- | ------ | | id | Attribute's id | Number | ### [#](https://devdocs.bagisto.com/1.x/api/attributes.html#examples-2) Examples #### [#](https://devdocs.bagisto.com/1.x/api/attributes.html#_1-let-s-try-to-fetch-attribute-by-id) 1\. Let's try to fetch attribute by id - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/attributes/1` Response ``` { "data": { "id": 1, "code": "sku", "type": "text", "name": "SKU", "swatch_type": null, "options": [], "created_at": "2021-05-24T05:09:12.000000Z", "updated_at": "2021-05-24T05:09:12.000000Z" } } ``` [Categories](https://devdocs.bagisto.com/1.x/api/categories.html)[Attribute Families](https://devdocs.bagisto.com/1.x/api/attribute-families.html) ## Full Page Cache Guide This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#full-page-cache) Full Page Cache - [Introduction](https://devdocs.bagisto.com/2.3/performance/fpc.html#introduction) - [How to Enable Full Page Cache In Bagisto](https://devdocs.bagisto.com/2.3/performance/fpc.html#how-to-enable-full-page-cache-in-bagisto) - [How to set Cache duration and other Configuration](https://devdocs.bagisto.com/2.3/performance/fpc.html#how-to-set-cache-duration-and-other-configuration) - [Full page cache supported pages](https://devdocs.bagisto.com/2.3/performance/fpc.html#full-page-cache-supported-pages) - [Supported Cache Drivers](https://devdocs.bagisto.com/2.3/performance/fpc.html#supported-cache-drivers) - [Clearing Response Cache with Artisan Commands:](https://devdocs.bagisto.com/2.3/performance/fpc.html#clearing-response-cache-with-artisan-commands) - [Cache invalidation](https://devdocs.bagisto.com/2.3/performance/fpc.html#cache-invalidation) ## [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#introduction) Introduction Bagisto introduces Full Page Cache support to deliver lightning-fast page loading, improved SEO, scalability, and reduced server load for enhanced eCommerce performance. Full Page Cache is a mechanism that stores entire HTML pages in the cache. When a request is made for the same page, the cache seamlessly serves the page without the need for re-executing server-side logic. This process allows for faster page load times as the cache provides a quick and efficient way to serve the requested page without the need to run the server-side logic again. This reduces the need for database queries, template rendering, and other resource-intensive tasks, resulting in faster page load times. We used the [Spatie Laravel Responsecache Package(opens new window)](https://github.com/spatie/laravel-responsecache) in Bagisto ### [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#how-to-enable-full-page-cache-in-bagisto) How to Enable Full Page Cache In Bagisto - Go to the .env Configuration file ``` Set RESPONSE_CACHE_ENABLED=true ``` ### [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#how-to-set-cache-duration-and-other-configuration) How to set Cache duration and other Configuration - Navigate to `config/responsecache.php.` this path to adjust cache duration and explore other configuration settings for Full Page Cache in Bagisto. Here, you’ll find all the configurations related to Full Page Cache. ### [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#full-page-cache-supported-pages) Full page cache supported pages - Home Page - Category Page - Product Page ### [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#supported-cache-drivers) Supported Cache Drivers - File - Memcached - Redis - DynamoDB ### [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#clearing-response-cache-with-artisan-commands) Clearing Response Cache with Artisan Commands: To effortlessly clear your application’s response cache in Bagisto, utilize the following command: ``` php artisan responsecache:clear ``` This command clears all cached responses. Optionally, you can provide a `--url` option to clear the cache for a specific URL: ``` php artisan responsecache:clear --url=http://example.com ``` Replace `http://example.com` with the actual URL for which you want to clear the cached response. ## [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#cache-invalidation) Cache invalidation Here are some common techniques for cache invalidation in Laravel: #### [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#create-the-eventserviceprovider-class) Create the EventServiceProvider class Create an EventServiceProvider in the `packages/Webkul/Post/src/Providers/EventServiceProvider.php` directory. This file contains the code for the event service provider, which can be used to register events and their listeners. To register an event and its listener, you can add them to the $listen array in the EventServiceProvider class. ``` [\ 'Webkul\Post\Listeners\Post@afterUpdate',\ ],\ ]; } ``` #### [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#register-the-service-in-the-post-service-provider) Register the Service in the Post Service Provider In the `packages/Webkul/Post/src/Providers/PostServiceProvider.php` file, locate the `boot()` method. Add EventServiceProvider within the `boot()` method. ``` app->register(EventServiceProvider::class); } /** * Register services. * * @return void */ public function register() { } } ``` #### [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#handling-events-in-the-post-controller) Handling Events in the Post Controller In the realm of event-based cache management, consider the event post.update.after triggered from the post controller upon a post update. This integration guarantees swift cache clearance or update, maintaining synchronization with the latest post modifications. ``` /** * Update the specified resource in storage. * * @return \Illuminate\Http\Response */ public function update(int $id) { Event::dispatch('post.update.before', $id); $post = $this->postRepository->update(request()->only(['status']), $id); Event::dispatch('post.update.after', $post); session()->flash('success', trans('shop::app.posts.update-success', ['name' => 'shop::app.posts.post'])); return redirect()->route('shop.posts.index'); } ``` #### [#](https://devdocs.bagisto.com/2.3/performance/fpc.html#listener-method-for-cache-invalidation) Listener Method for Cache Invalidation In the directory `packages/Webkul/Post/src/Listeners` you can find the `afterUpdate()` method. This method clears the cache using the `forget()` method when a post is updated. ``` /** * After post is updated * * @param \Webkul\Post\Contracts\Post $post * @return void */ public function afterUpdate($post) { ResponseCache::forget('/' . $post->url_key); } ``` [Indexing](https://devdocs.bagisto.com/2.3/performance/indexing.html)[Laravel Octane](https://devdocs.bagisto.com/2.3/performance/octane.html) ## Bagisto Upgrade Guide WARNING: You're browsing the documentation for an upcoming version. Features of this release are subject to change. # [#](https://devdocs.bagisto.com/master/prologue/upgrade-guide.html#upgrade-guide) Upgrade Guide - [Upgrade Steps](https://devdocs.bagisto.com/master/prologue/upgrade-guide.html#upgrade-steps) - [New Changes](https://devdocs.bagisto.com/master/prologue/upgrade-guide.html#new-changes) ## [#](https://devdocs.bagisto.com/master/prologue/upgrade-guide.html#upgrade-steps) Upgrade Steps To upgrade your current version to the latest version of Bagisto, follow these steps: 1. Download the latest version of Bagisto from one of the following links: - [Download From Official Bagisto Site(opens new window)](https://bagisto.com/en/download/) - [Download From GitHub(opens new window)](https://github.com/bagisto/bagisto) 2. Extract the downloaded Bagisto zip file to the desired deployment location. 3. Open the terminal and navigate to the root folder of the extracted Bagisto folder. 4. Run the following command in the terminal: ``` composer create-project ``` This command will install the necessary dependencies for the latest version of Bagisto. 5. Open the **`.env`** file in your project's root folder. Provide the database credentials of your old project, which you want to upgrade using Bagisto. 6. Run one of the following commands to cache the new changes: ``` php artisan optimize # -- OR -- php artisan config:cache ``` These commands will cache the configuration files and optimize the project. 7. Now, your project is ready to run the migration command. Execute the following command in the terminal: ``` php artisan migrate ``` WARNING Be cautious when using the seeder command as it may reset settings and categories. Add default settings manually if necessary. 8. Create a symbolic link to link public assets to the storage folder by running the following command: ``` php artisan storage:link ``` 9. Copy the contents of the previous version's folder (e.g., **`old-project/storage/app/public`**) to the corresponding folder in the latest version (e.g., **`new-project/storage/app/public`**). TIP If your existing project depends on local storage, has changed paths, or requires previous logs, ensure to include those as well. 10. Once the copying is complete, publish the new files by running the following command: ``` php artisan vendor:publish --all ``` WARNING Avoid using the **`--force`** flag, as it will reset all your views. Only use it if you understand the consequences. 11. Congratulations! Your project is now upgraded to the latest version of Bagisto. However, keep in mind that if you have made significant customizations, ensure compatibility with the latest version. ## [#](https://devdocs.bagisto.com/master/prologue/upgrade-guide.html#new-changes) New Changes We are excited to announce the latest updates in Bagisto! These changes have been implemented in the master branch, which serves as the development branch for new features and breaking changes. These updates will be included in the upcoming stable release. For a detailed list of changes, please visit the [Bagisto CHANGELOG.md on GitHub(opens new window)](https://github.com/bagisto/bagisto/blob/master/CHANGELOG.md). To help you prepare for the upcoming release, we have also provided an upgrade guide. You can find the full upgrade instructions here: [Bagisto UPGRADE.md on GitHub(opens new window)](https://github.com/bagisto/bagisto/blob/master/UPGRADE.md). [Prologue](https://devdocs.bagisto.com/master/prologue)[Contribution Guide](https://devdocs.bagisto.com/master/prologue/contribution-guide.html) ## Bagisto Categories API Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/api/categories.html#categories) Categories In this section, we are using the categories' API. We will fetch all the categories based on `id` and `parent_id` as well. ## [#](https://devdocs.bagisto.com/1.x/api/categories.html#get-all-categories) Get all categories This api request will fetch all the categories. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET /api/categories(?limit,page,pagination)` - Params | Name | Info | Type | | ---------- | -------------------------------------------- | ------ | | limit | Maximum number of records in each request | Number | | page | Records for specific page based on the limit | Number | | pagination | will display all the records if set to `0` | Number | TIP If you are using pagination and want to know more info about responses then check the [explanation](https://devdocs.bagisto.com/1.x/api/explanation) portion. ### [#](https://devdocs.bagisto.com/1.x/api/categories.html#examples) Examples #### [#](https://devdocs.bagisto.com/1.x/api/categories.html#_1-get-categories-of-the-specific-page) 1\. Get categories of the specific page - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/categories?page=1` TIP If you didn't use the page (?page=x) filter, then it returns the data of the first page by default. `GET http(s)://example.com/api/categories` Response ``` { "data": [\ {\ "id": 3,\ "code": null,\ "name": "Laptops",\ "slug": "laptops",\ "display_mode": "products_only",\ "description": "",\ "meta_title": "Laptops",\ "meta_description": "",\ "meta_keywords": "",\ "status": 1,\ "image_url": null,\ "additional": null,\ "created_at": "2020-09-08T23:41:24.000000Z",\ "updated_at": "2020-09-08T23:41:24.000000Z"\ },\ {...},\ {...}\ ], "links": { "first": "https://example.com/api/categories?page=1", "last": "https://example.com/api/categories?page=1", "prev": null, "next": null }, "meta": { "current_page": 1, "from": 1, "last_page": 1, "path": "https://example.com/api/categories", "per_page": 10, "to": 3, "total": 3 } } ``` #### [#](https://devdocs.bagisto.com/1.x/api/categories.html#_2-get-categories-of-the-specific-page-with-limit) 2\. Get categories of the specific page with limit - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/categories?page=1&limit=10` Response ``` { "data": [\ {\ "id": 10,\ "code": null,\ "name": "Lights",\ "slug": "lights",\ "display_mode": "products_only",\ "description": "",\ "meta_title": "",\ "meta_description": "",\ "meta_keywords": "",\ "status": 1,\ "image_url": null,\ "additional": null,\ "created_at": "2020-09-24T11:44:42.000000Z",\ "updated_at": "2020-09-24T11:44:42.000000Z"\ },\ {...},\ {...},\ {...},\ {...}\ ], "links": { "first": "https://example.com/api/categories?limit=5&page=1", "last": "https://example.com/api/categories?limit=5&page=2", "prev": null, "next": "https://example.com/api/categories?limit=5&page=2" }, "meta": { "current_page": 1, "from": 1, "last_page": 2, "path": "https://example.com/api/categories", "per_page": "5", "to": 5, "total": 10 } } ``` #### [#](https://devdocs.bagisto.com/1.x/api/categories.html#_3-get-all-categories-without-pagination) 3\. Get all categories without pagination If you don't want to use the pagination and want to access all the store's categories at once, then you have to send a filter parameter named as `pagination` with value `zero`. By doing this you will get all categories objects at once in the data object and this will not give you link and meta objects. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/categories?pagination=0` Response ``` { "data": [\ {\ "id": 10,\ "code": null,\ "name": "Lights",\ "slug": "lights",\ "display_mode": "products_only",\ "description": "",\ "meta_title": "",\ "meta_description": "",\ "meta_keywords": "",\ "status": 1,\ "image_url": null,\ "additional": null,\ "created_at": "2020-09-24T11:44:42.000000Z",\ "updated_at": "2020-09-24T11:44:42.000000Z"\ },\ {...},\ {...},\ {...},\ {...},\ {...},\ {...},\ {...},\ {...},\ {...}\ ] } ``` ## [#](https://devdocs.bagisto.com/1.x/api/categories.html#get-category-by-id) Get category by id For fetching any specific category, you have to provide the category's id as an input parameter. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET /api/categories/{id}` - Params | Name | Info | Type | | ---- | ------------- | ------ | | id | Category's id | Number | ### [#](https://devdocs.bagisto.com/1.x/api/categories.html#examples-2) Examples #### [#](https://devdocs.bagisto.com/1.x/api/categories.html#_1-let-s-try-to-fetch-category-by-id) 1\. Let's try to fetch category by id - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/categories/6` Response ``` { "data": { "id": 6, "code": null, "name": "Kitchen Appliances", "slug": "kitchen-appliances", "display_mode": "products_only", "description": "", "meta_title": "", "meta_description": "", "meta_keywords": "", "status": 1, "image_url": null, "additional": null, "created_at": "2020-09-24T11:42:17.000000Z", "updated_at": "2020-09-24T11:42:17.000000Z" } } ``` ## [#](https://devdocs.bagisto.com/1.x/api/categories.html#get-descendant-categories-of-specific-category) Get descendant categories of specific category This api request will fetch all the descendant categories based on the `parent_id`. - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET /api/descendant-categories(?parent_id)` - Params | Name | Info | Type | | --------- | ------------------------------------ | ------ | | parent_id | Parent id of the descendant category | Number | ### [#](https://devdocs.bagisto.com/1.x/api/categories.html#examples-3) Examples #### [#](https://devdocs.bagisto.com/1.x/api/categories.html#_1-get-data-based-on-the-parent-id-which-have-descendant-categories) 1\. Get data based on the `parent_id` which have descendant categories - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/descendant-categories?parent_id=2` Response ``` { "data": [\ {\ "id": 3,\ "code": null,\ "name": "Bike Accessories",\ "slug": "bike-accessories",\ "display_mode": "products_only",\ "description": "",\ "meta_title": "",\ "meta_description": "",\ "meta_keywords": "",\ "status": 1,\ "image_url": null,\ "additional": null,\ "created_at": "2020-09-22T07:16:32.000000Z",\ "updated_at": "2020-09-24T13:08:21.000000Z"\ },\ {\ "id": 11,\ "code": null,\ "name": "Bike Tyres",\ "slug": "bike-tyres",\ "display_mode": "products_only",\ "description": "",\ "meta_title": "",\ "meta_description": "",\ "meta_keywords": "",\ "status": 1,\ "image_url": null,\ "additional": null,\ "created_at": "2020-09-24T13:20:01.000000Z",\ "updated_at": "2020-09-24T13:20:01.000000Z"\ }\ ] } ``` #### [#](https://devdocs.bagisto.com/1.x/api/categories.html#_2-let-s-try-with-parent-id-which-have-no-descendant-categories) 2\. Let's try with `parent_id` which have no descendant categories - Headers | Key | Value | | ------ | ---------------- | | Accept | application/json | - Request `GET http(s)://example.com/api/descendant-categories?parent_id=3` Response ``` { "data": [] } ``` [Products](https://devdocs.bagisto.com/1.x/api/products.html)[Attributes](https://devdocs.bagisto.com/1.x/api/attributes.html) ## Bagisto Address API Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/api/addresses.html#addresses) Addresses In this section, we will use all the addresses' API. We will check the creation of address, fetching of addresses, and updation of address. ## [#](https://devdocs.bagisto.com/1.x/api/addresses.html#create-a-new-address) Create a new address To add an address, you have to use the `addresses/create` endpoint url and have to pass the address fields in the request payload. This `addresses/create` API call resource will create a new address of the customer, only if that customer has logged in the store. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `POST /api/addresses/create` - Params | Name | Info | Type | | ------------ | ------------ | ------ | | address1 | Address | Array | | city | City | String | | country | Country | String | | country_name | Country Name | String | | phone | Phone | String | | postcode | Post Code | String | | state | State | String | ### [#](https://devdocs.bagisto.com/1.x/api/addresses.html#examples) Examples Let's take an example of creating an address, - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `POST http(s)://example.com/api/addresses/create` - Params | Name | Value | | ------------ | ----------------- | | address1 | \['Clock Tower'\] | | city | Dehradun | | country | IN | | country_name | India | | phone | 0123456798 | | postcode | 248001 | | state | UT | ``` { "address1": [\ "Clock Tower"\ ], "city": "Dehradun", "country": "IN", "country_name": "India", "phone": "0123456798", "postcode": "248001", "state": "UT" } ``` Response ``` { "message":"Address has been created successfully.", "data": {...} // This contains the data you send to the api. } ``` ## [#](https://devdocs.bagisto.com/1.x/api/addresses.html#get-all-addresses) Get all addresses To get all the address of a customer, that customer must be logged in to the store. You can achieve this job by using `addresses` API call resource. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET /api/addresses` ### [#](https://devdocs.bagisto.com/1.x/api/addresses.html#examples-2) Examples Let's take an example, - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/api/addresses` Response ``` { "data": [\ {\ "id": 3,\ "address1": [...],\ "country": "IN",\ "country_name": "India",\ "state": "UT",\ "city": "Dehradun",\ "postcode": 248001,\ "phone": "01345679",\ },\ {\ "id": 2,\ "address1": [...],\ "country": "IN",\ "country_name": "India",\ "state": "UP",\ "city": "Noida",\ "postcode": 201301,\ "phone": "012345679",\ },\ ] } ``` ## [#](https://devdocs.bagisto.com/1.x/api/addresses.html#get-address-by-id) Get address by id To get the customer's specific address, you have to pass an `address_id` as a request payload like `addresses/{address_id}` in API URL. By using this resource and request payload, you will get only a single object under the `data` object in response. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET /api/addresses/{address_id}` - Params | Name | Info | Type | | ---------- | ------- | ------ | | address_id | Address | Number | ### [#](https://devdocs.bagisto.com/1.x/api/addresses.html#examples-3) Examples Let's take an example, - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/api/addresses/1` Response ``` { "data": { "id": 1, "address1": [\ "Block H-ARP Park, Sector 63 "\ ], "country": "IN", "country_name": "India", "state": "UP", "city": "Noida", "postcode": 201301, "phone": "0132456789", "created_at": { "date": "", "timezone_type": 3, "timezone": "Asia/Kolkata" }, "updated_at": { "date": "", "timezone_type": 3, "timezone": "Asia/Kolkata" }, } } ``` ## [#](https://devdocs.bagisto.com/1.x/api/addresses.html#update-address) Update address To update the customer's specific address, you have to pass an `address_id` as a request payload like `addresses/{address_id}` in API URL. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `PUT /api/addresses/1` - Params | Name | Info | Type | | ------------ | ------------ | ------ | | address1 | Address | Array | | city | City | String | | country | Country | String | | country_name | Country Name | String | | phone | Phone | String | | postcode | Post Code | String | | state | State | String | ### [#](https://devdocs.bagisto.com/1.x/api/addresses.html#examples-4) Examples - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `PUT http(s)://example.com/api/addresses/1` - Params ``` { "id": 1, "address1": [\ "Clock Tower"\ ], "city": "New Delhi", "country": "IN", "country_name": "India", "phone": "9876543210", "postcode": "248001", "state": "DL" } ``` Response ``` { "message":"Your address has been updated successfully.", "data": {...} // Address' detail. } ``` [Locales](https://devdocs.bagisto.com/1.x/api/locales.html)[Products](https://devdocs.bagisto.com/1.x/api/products.html) ## Bagisto Docker Setup Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#docker) Docker - [Introduction](https://devdocs.bagisto.com/2.1/introduction/docker.html#introduction) - [Docker Setup for Bagisto](https://devdocs.bagisto.com/2.1/introduction/docker.html#docker-setup-for-bagisto) - [1\. Using Bagisto Docker Image from Docker Hub](https://devdocs.bagisto.com/2.1/introduction/docker.html#_1-using-bagisto-docker-image-from-docker-hub) - [2\. Using Bagisto GitHub Docker Repository](https://devdocs.bagisto.com/2.1/introduction/docker.html#_2-using-bagisto-github-docker-repository) ## [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#introduction) Introduction [Docker(opens new window)](https://www.docker.com/) is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. Docker can also be used for defining and running multi-container Docker applications using the Docker Compose tool. With the help of Docker Compose, you can define containers to be built, their configuration, links, volumes, ports, etc., in a single file, and it gets launched by a single command. You can also add multiple servers and services just by adding them to the Docker Compose configuration file. This configuration file is in [YAML(opens new window)](https://en.wikipedia.org/wiki/YAML) format. #### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#application-data-and-database-volume-persistence) Application Data and Database Volume Persistence It is recommended to keep your application files and database data volume on the Docker host and mount them on the running container. This ensures that the application and database data persistence even in the case of containers' failure or termination. In this way, even if you destroy containers, your data won't get lost unless you remove them forcefully. This compose configuration file mounts the application directory **`app`** and database volume **`dbvolume`** from the host to running Docker containers at the time of containers' launch. ### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#docker-setup-for-bagisto) Docker Setup for Bagisto You can configure Bagisto using Docker in two different ways: 1. **Using Bagisto Docker Image from Docker Hub** 2. **Using Bagisto GitHub Docker Repository** Both approaches allow you to set up the application quickly, managing all system requirements like Apache, MySQL, and PHPMyAdmin within isolated containers. Below is a detailed guide for each method. ### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#_1-using-bagisto-docker-image-from-docker-hub) 1\. **Using Bagisto Docker Image from Docker Hub** Follow the steps below to set up Bagisto using Docker Hub. This approach provides a pre-configured Docker image of Bagisto, allowing for a quick and easy installation. #### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#step-1-pull-bagisto-docker-image) Step 1: Pull Bagisto Docker Image To pull the Bagisto Docker image from Docker Hub, use the following command: ``` docker pull webkul/bagisto:2.1.2 ``` #### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#step-2-run-a-new-container) Step 2: Run a New Container Once the image is pulled, you can run a new Docker container using the command below. This will bind your local port 80 to the container’s port 80, so Bagisto can be accessed via the browser. ``` docker run -it -d -p 80:80 webkul/bagisto:2.1.2 ``` > **Note:** > If port 80 is already in use, you can try using a different port. For example, you can map port 8082 on your local machine to port 80 in the container by running the following command: > > ``` > docker run -it -d -p 8082:80 webkul/bagisto:2.1.2 > > ``` > > After this, you can access the application at `http://localhost:8082/` instead of `http://localhost:80`. #### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#step-3-access-bagisto-in-your-browser) Step 3: Access Bagisto in Your Browser After the container is up and running, open your browser and navigate to `http://localhost`. This will load the Bagisto setup. #### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#step-4-admin-login-credentials) Step 4: Admin Login Credentials Use the following credentials to log in to the Bagisto admin panel: - **Admin Username**: `admin@example.com` - **Admin Password**: `admin123` ### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#_2-using-bagisto-github-docker-repository) 2\. **Using Bagisto GitHub Docker Repository** #### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#system-requirements) System Requirements The Bagisto GitHub Docker repository automatically handles the system requirements for running Bagisto, including the necessary Apache and MySQL configurations. Before proceeding, ensure that you have the latest version of **Docker** and **Docker Compose** installed. You can find installation instructions for your operating system at the following links: - [Docker Installation Guide(opens new window)](https://docs.docker.com/install/) - [Docker Compose Installation Guide(opens new window)](https://docs.docker.com/compose/install/) #### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#docker-configuration) Docker Configuration 1. **Adjust Ports and Paths** Open the `docker-compose.yml` file and configure the ports for Apache, MySQL, and PHPMyAdmin. You can also specify the volumes and MySQL credentials. Here's an example configuration: ``` version: '3.1' services: bagisto-php-apache: build: args: container_project_path: /var/www/html/ uid: 1000 # Add your UID user: $USER context: . dockerfile: ./Dockerfile image: bagisto-php-apache ports: - 80:80 # Adjust Apache port volumes: - ./workspace/:/var/www/html/ bagisto-mysql: image: mysql:8.0 command: --default-authentication-plugin=mysql_native_password restart: always environment: MYSQL_ROOT_HOST: '%' MYSQL_ROOT_PASSWORD: root ports: - 3306:3306 # Adjust MySQL port volumes: - ./.configs/mysql-data:/var/lib/mysql/ bagisto-phpmyadmin: image: phpmyadmin:latest restart: always environment: PMA_HOST: bagisto-mysql PMA_USER: root PMA_PASSWORD: root ports: - 8080:80 # Adjust PHPMyAdmin port volumes: mysql-data: ``` 2. **Running the Setup** After adjusting the configurations, execute the following command to start the Docker containers: ``` sh setup.sh ``` #### [#](https://devdocs.bagisto.com/2.1/introduction/docker.html#accessing-bagisto) Accessing Bagisto - **Admin Panel** Access the admin panel at: `http(s)://your_server_endpoint/admin/login` Use the default credentials: - **Email**: `admin@example.com` - **Password**: `admin123` - **Customer Registration** Register and log in as a customer at: `http(s)://your_server_endpoint/customer/register` [Installation](https://devdocs.bagisto.com/2.1/introduction/installation.html)[Architecture concepts](https://devdocs.bagisto.com/2.1/architecture) ## Bagisto Order APIs Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/api/orders.html#orders) Orders In this section, we will see all the APIs which are related to order. As after order placement tracking of order is also important. ## [#](https://devdocs.bagisto.com/1.x/api/orders.html#get-all-orders) Get all orders You can get all the orders of the Bagisto store. To get the orders of the store, the customer must be logged in to the Bagisto Store. You can achieve this job by using `orders` API call resource. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET /api/orders(?limit,page,pagination)` - Params | Name | Info | Type | | ---------- | -------------------------------------------- | ------ | | limit | Maximum number of records in each request | Number | | page | Records for specific page based on the limit | Number | | pagination | Will display all the records if set to `0` | Number | TIP If you are using pagination and want to know more info about responses then check the [explanation](https://devdocs.bagisto.com/1.x/api/explanation) portion. ### [#](https://devdocs.bagisto.com/1.x/api/orders.html#examples) Examples #### [#](https://devdocs.bagisto.com/1.x/api/orders.html#_1-records-for-specific-page) 1\. Records for specific page - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/api/orders?page=1` TIP If you didn't use the page (?page=x) filter, then it returns the data of the first page by default. `GET http(s)://example.com/api/orders` Response ``` { "data": [\ {...},\ {...},\ ...\ {...}\ ], "links": { "first": "https://example.com/api/orders?page=1", "last": "https://example.com/api/orders?page=2", "prev": null, "next": "https://example.com/api/orders?page=2" }, "meta": { "current_page": 1, "from": 1, "last_page": 2, "path": "https://example.com/api/orders", "per_page": 10, "to": 10, "total": 11 } } ``` #### [#](https://devdocs.bagisto.com/1.x/api/orders.html#_2-records-for-specific-page-with-limit) 2\. Records for specific page with limit - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/public/api/orders?limit=5&page=2` Response ``` { "data": [\ {...},\ {...},\ {...},\ {...},\ {...}\ ] "links": { "first": "https://example.com/api/orders?limit=5&page=1", "last": "https://example.com/api/orders?limit=5&page=3", "prev": "https://example.com/api/orders?limit=5&page=1", "next": "https://example.com/api/orders?limit=5&page=3" }, "meta": { "current_page": 2, "from": 6, "last_page": 3, "path": "https://example.com/api/orders", "per_page": "5", "to": 10, "total": 11 } } ``` #### [#](https://devdocs.bagisto.com/1.x/api/orders.html#_3-get-all-orders-without-pagination) 3\. Get all orders without pagination, You can also get all the orders at once from the Bagisto store without pagination. To get the orders, the customer must be logged in to the Bagisto store. For this, you have to pass `pagination=0` in the query parameter with the `orders` resource in the API URL. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/public/api/orders?pagination=0` Response ``` { "data": [\ {...},\ {...},\ {...},\ ...\ {...}\ ] } ``` ![bagisto_orders_no_pag](https://devdocs.bagisto.com/assets/img/bagisto_orders_no_pag.eb8fd609.jpg){:class="screenshot-dimension center"} ## [#](https://devdocs.bagisto.com/1.x/api/orders.html#get-order-by-id) Get order by id To get the specific order details, you have to pass an `order_id` as a request payload in the API URL. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET /api/orders/{order_id}` - Params | Name | Info | Type | | -------- | ---------- | ------ | | order_id | Order's ID | Number | ### [#](https://devdocs.bagisto.com/1.x/api/orders.html#examples-2) Examples Let's fetch specific order, - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/api/order/3` Response ``` { "data": { "id": 3, "status": "pending", "status_label": "Pending", "channel_name": "Default", "customer_email": "peterdoe@example.com", "customer_first_name": "Peter", "customer_last_name": "Doe", "shipping_method": "flatrate_flatrate", "shipping_title": "Flat Rate - Flat Rate", "payment_title": "Cash On Delivery", "total_qty_ordered": 2, "grand_total": "80.0000", "customer": {...}, "shipping_address": {...}, "billing_address": {...}, "items": [\ {...},\ {...}\ ], "invoices": [], "shipments": [], } } } ``` ![bagisto_orders_id](https://devdocs.bagisto.com/assets/img/bagisto_orders_id.47d67a0d.jpg) ## [#](https://devdocs.bagisto.com/1.x/api/orders.html#get-orders-by-customer-s-id) Get orders by customer's id To get all the orders of a specific customer, you have to pass a `customer_id` as a query parameter like `orders?customer_id={id}` in API URL. To use this API call customer authentication is required means that customers must be logged-in to the store. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/public/api/orders(?customer_id,limit,page,pagination)` - Params | Name | Info | Type | | ----------- | -------------------------------------------- | ------ | | customer_id | Cutomer's ID | Number | | limit | Maximum number of records in each request | Number | | page | Records for specific page based on the limit | Number | | pagination | Will display all the records if set to `0` | Number | ### [#](https://devdocs.bagisto.com/1.x/api/orders.html#examples-3) Examples #### [#](https://devdocs.bagisto.com/1.x/api/orders.html#_1-to-get-all-the-results-without-pagination) 1\. To get all the results without pagination - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/public/api/orders?customer_id=2&pagination=0` Response ``` { "data": [\ {\ "id": 3,\ "status": "pending",\ "customer_email": "peterdoe@webkul.com",\ "customer_first_name": "Peter",\ "customer_last_name": "Doe",\ "shipping_method": "flatrate_flatrate",\ "shipping_title": "Flat Rate - Flat Rate",\ "payment_title": "Cash On Delivery",\ "total_qty_ordered": 2,\ "grand_total": "80.0000",\ "customer": {...},\ "shipping_address": {...},\ "billing_address": {...},\ "items": [{...},{...},{...}],\ },\ {\ "id": 2,\ "status": "pending",\ "customer_email": "peterdoe@webkul.com",\ "customer_first_name": "Peter",\ "customer_last_name": "Doe",\ "shipping_method": "flatrate_flatrate",\ "shipping_title": "Flat Rate - Flat Rate",\ "payment_title": "Cash On Delivery",\ "total_qty_ordered": 5,\ "grand_total": "400.0000",\ "customer": {...},\ "shipping_address": {...},\ "billing_address": {...},\ "items": [{...},{...},{...}],\ }\ ] } ``` #### [#](https://devdocs.bagisto.com/1.x/api/orders.html#_2-get-all-orders-by-customer-s-id-with-pagination) 2\. Get all orders by customer's id with pagination - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/api/orders?customer_id=2&limit=5&page=1` Response ``` { "data": [\ {...}\ ], "links": { "first": "https://example.com/api/orders?customer_id=2&limit=1&page=1", "last": "https://example.com/api/orders?customer_id=2&limit=1&page=1", "prev": "https://example.com/api/orders?customer_id=2&limit=1&page=1", "next": null }, "meta": { "current_page": 2, "from": 2, "last_page": 2, "path": "https://example.com/api/orders", "per_page": "1", "to": 2, "total": 2 } } ``` [Shopping Cart](https://devdocs.bagisto.com/1.x/api/cart.html)[Invoices](https://devdocs.bagisto.com/1.x/api/invoices.html) ## Bagisto Installation Guide This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#installation) Installation - [Install Using GUI Installer](https://devdocs.bagisto.com/2.3/introduction/installation.html#install-using-gui-installer) - [Install Using Composer](https://devdocs.bagisto.com/2.3/introduction/installation.html#install-using-composer) - [Start Using Bagisto](https://devdocs.bagisto.com/2.3/introduction/installation.html#start-using-bagisto) - [On a Production Server](https://devdocs.bagisto.com/2.3/introduction/installation.html#on-a-production-server) - [On Your Local Server](https://devdocs.bagisto.com/2.3/introduction/installation.html#on-your-local-server) - [Login as an Admin](https://devdocs.bagisto.com/2.3/introduction/installation.html#login-as-an-admin) - [Login as a Customer](https://devdocs.bagisto.com/2.3/introduction/installation.html#login-as-a-customer) - [Installation of Mobile App](https://devdocs.bagisto.com/2.3/introduction/installation.html#installation-of-mobile-app) - [Clone the repository](https://devdocs.bagisto.com/2.3/introduction/installation.html#clone-the-repository) - [Install dependencies](https://devdocs.bagisto.com/2.3/introduction/installation.html#install-dependencies) - [Generate Required files](https://devdocs.bagisto.com/2.3/introduction/installation.html#generate-required-files) - [Connect a device or emulator](https://devdocs.bagisto.com/2.3/introduction/installation.html#connect-a-device-or-emulator) - [Run the Project](https://devdocs.bagisto.com/2.3/introduction/installation.html#run-the-project) - [Minimum Versions](https://devdocs.bagisto.com/2.3/introduction/installation.html#minimum-versions) - [Configurations Steps](https://devdocs.bagisto.com/2.3/introduction/installation.html#configurations-steps) - [For Setup](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-setup) - [For Theme](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-theme) - [For Push Notification Service](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-push-notification-service) - [For Application Title](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-application-title) - [For Splash Screen](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-splash-screen) - [For App Icon](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-app-icon) - [API Documentation](https://devdocs.bagisto.com/2.3/introduction/installation.html#api-documentation) - [Contributing](https://devdocs.bagisto.com/2.3/introduction/installation.html#contributing) - [License](https://devdocs.bagisto.com/2.3/introduction/installation.html#license) ## [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#install-using-gui-installer) Install Using GUI Installer To install Bagisto using our GUI installer, you can follow any of the following methods: #### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#method-1) Method 1: - Choose the directory where you want to install Bagisto. Open your terminal and navigate to this directory. - Once you are in the desired directory, run the following command in your terminal to install Bagisto: ``` composer create-project bagisto/bagisto ``` - Configure your HTTP server to point to the **`public/`** directory of the project. - Open your browser and access the following URL: ``` http://localhost/bagisto/public/ ``` This will launch the Bagisto installer. #### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#method-2) Method 2: Otherwise you can download the zip file and install it using the following steps: - [Download Bagisto(opens new window)](https://bagisto.com/en/download/) from our website. - Extract the contents of the downloaded - Navigate to the project root directory. - Run the following command: ``` composer create ``` - Configure your HTTP server to point to the **`public/`** directory of the project. - Open your browser and access the following URL: ``` http://localhost/bagisto/public/ ``` This will launch the Bagisto installer. WARNING Ensure that Composer is installed on your system ## [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#install-using-composer) Install Using Composer To install Bagisto using Composer, use the following steps: - Choose the directory where you want to install Bagisto. Open your terminal and navigate to this directory. - Once you are in the desired directory, run the following command in your terminal to install Bagisto: - Run the following command: ``` composer create-project bagisto/bagisto ``` - Run the following command: ``` php artisan bagisto:install ``` WARNING During the installation process, if the **`.env`** file doesn't exist, the installer will prompt you to provide the necessary information. - Follow the prompts during the installation process to provide the following details: ``` - Please Enter the Application Name : - Please Enter the APP URL : - Please enter the application URL: - Please select the default locale : - Please enter the default currency : - Please choose the Allowed Locales for your channels : - Please choose the Allowed Currencies for your channels : - Please select the Database Connection : - Please enter the Database Host : - Please enter the Database Port Number : - Please enter the Database Name : - Please enter the Database Prefix : - Please enter the Database Username : - Please enter the Database Password : ``` - For Create your admin credentials ``` - Enter the Name of Admin User : - Enter the Email address of the Admin User : - Configure the Password for admin user : - Please select if you want some sample products after installation: ``` ## [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#start-using-bagisto) Start Using Bagisto ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#on-a-production-server) On a Production Server To access Bagisto on a production server, open your domain in a web browser. For example: ``` https://example.com/ ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#on-your-local-server) On Your Local Server To access Bagisto on your local server, follow these steps: 1. Configure your HTTP server to point to the **`public/`** directory of the project. 2. Run the following command: ``` php artisan serve ``` 3. Open your browser and access the provided local server URL. ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#login-as-an-admin) Login as an Admin To log in as an admin, visit **`https://example.com/admin/`**. If you used the **`php artisan bagisto:install`** command, use the following credentials: ``` Email: admin@example.com Password: admin123 ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#login-as-a-customer) Login as a Customer To log in as a customer, you can directly register on **`https://example.com/customer/register`**. After registration, you can log in using your credentials on the domain. ## [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#installation-of-mobile-app) Installation of Mobile App Before beginning with the installation, you will need the following with the mentioned versions - Bagisto Version - v2.0.0 - Android Studio Version - Flamingo \| 2022.2.1 - Flutter Version - 3.10.1 - Dart - 3.0.1 - Xcode - 14.3 - Swift - 5 Make sure you have installed the API module and set this up properly on your bagisto. Note It is recommended that you run a simple Hello World program in Flutter first before proceeding further so that you are sure that the environment is properly set up. ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#clone-the-repository) Clone the repository - Open your terminal or command prompt - Navigate to the directory where you want to save the project - Use the git clone command followed by the repository URL ``` git clone https://github.com/bagisto/opensource-ecommerce-mobile-app.git ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#install-dependencies) Install dependencies - Navigate to the project's directory ``` cd ``` - Run the following command to install the required packages ``` flutter pub get ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#generate-required-files) Generate Required files - Navigate to the project's directory ``` cd ``` - Run the following command to generate the required files ``` flutter pub run build_runner build --delete-conflicting-outputs ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#connect-a-device-or-emulator) Connect a device or emulator - Physical Device 1. Enable USB debugging on your device 2. Connect it to your computer using a USB cable. - Emulator 1. Start an Android or iOS emulator using your preferred IDE or tools. ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#run-the-project) Run the Project - Use the following command to build and run the project ``` flutter run ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#minimum-versions) Minimum Versions - Android: 21 - iOS: 12 ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#configurations-steps) Configurations Steps ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-setup) For Setup Change the baseUrl as per your store **Path:** lib/utils/server_configuration.dart ``` static const String baseUrl = ‘....’; ``` Note Add the value of the complete URL ending with the GraphQL API endpoint. E.g - https://example.com/graphql ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-theme) For Theme Change the Theme for your app **Path:** lib/utils/mobikul_theme.dart ``` static const Color primaryColor = Color(***********); static const Color accentColor = Color(***********); ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-push-notification-service) For Push Notification Service - Android Replace "google-services.json". - iOS Replace "GoogleService-Info.plist". Note Helpful Articles Android https://mobikul.com/knowledgebase/generating-google-service-file-enable-fcm-firebase-cloud-messaging-android-application/ iOS https://mobikul.com/knowledgebase/generating-new-googleservice-info-plist-file-fcm-based-project-ios-app/ ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-application-title) For Application Title - Android 1. **Path:** android/app/src/main/AndroidManifest.xml 2. **Change app name:** android:label="\*\*\*\*\*\*\*\*\*\*\*" - iOS 1. Go to the general tab and identity change the display name to your app name Note For Homepage Header Title - Go to ‘assets/language/en.json’ (Note: Here, “en” in en.json refers to the languages that would be supported within the application) ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-splash-screen) For Splash Screen - For adding Lottie as Splash Screen 1. **Path:** assets/lottie/splash_screen.json 2. After updating the Lottie file, update the ‘splashLottie’ in lib/utils/assets_constants. ``` static const String splashLottie = "assets/lottie/splash_screen.json"; ``` - For adding an Image as a Splash Screen 1. **Path:** assets/images/splash.png 2. After updating the Image file, update the ‘splashImage’ in lib/utils/assets_constants. ``` static const String splashImage = "assets/images/splash.png"; ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#for-app-icon) For App Icon - **Android:** Open the android folder in Android Studio and then right click app > new > Image Asset set Image. - **iOS:** Replace the icons over the path > ios/Runner/Assets.xcassets/AppIcon.appiconset ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#api-documentation) API Documentation For the API Documentation, please go through - https://github.com/bagisto/headless-ecommerce/ ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#contributing) Contributing Contributions are welcome! Follow the contribution guidelines to get started. ### [#](https://devdocs.bagisto.com/2.3/introduction/installation.html#license) License Bagisto is open-sourced software licensed under the MIT license. [Requirements](https://devdocs.bagisto.com/2.3/introduction/requirements.html)[Docker](https://devdocs.bagisto.com/2.3/introduction/docker.html) ## Bagisto Events Guide This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/advanced/events.html#events) Events - [Introduction](https://devdocs.bagisto.com/2.3/advanced/events.html#introduction) - [Creating an Event Class](https://devdocs.bagisto.com/2.3/advanced/events.html#creating-an-event-class) - [Using Package Generator](https://devdocs.bagisto.com/2.3/advanced/events.html#using-package-generator) - [Manually Registering Events](https://devdocs.bagisto.com/2.3/advanced/events.html#manually-registering-events) - [Manually Registering Listeners](https://devdocs.bagisto.com/2.3/advanced/events.html#manually-registering-listeners) - [Specifying Events](https://devdocs.bagisto.com/2.3/advanced/events.html#specifying-events) - [Events Fired in Bagisto](https://devdocs.bagisto.com/2.3/advanced/events.html#events-fired-in-bagisto) - [Events Listen in Bagisto](https://devdocs.bagisto.com/2.3/advanced/events.html#events-listen-in-bagisto) - [Listening to Existing Events](https://devdocs.bagisto.com/2.3/advanced/events.html#listening-to-existing-events) - [Registering a Listener](https://devdocs.bagisto.com/2.3/advanced/events.html#registering-a-listener) ## [#](https://devdocs.bagisto.com/2.3/advanced/events.html#introduction) Introduction Event Listeners in Bagisto are a way to implement the observer pattern, where listeners respond to events that occur in the application. Events can be thought of as announcements made by the application, and listeners are the actions taken in response to those announcements. All event classes in Bagisto are stored in the `Providers` folder, and the listeners are stored in the `Listeners` folder. In Bagisto, events and listeners are organized in a clear and structured manner: - Events are typically stored in the Events folder. - Listeners are stored in the Listeners folder. This organization makes it easy to manage and locate the event-driven components of your application. To learn in detail about Controllers, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/events). ## [#](https://devdocs.bagisto.com/2.3/advanced/events.html#creating-an-event-class) Creating an Event Class ### [#](https://devdocs.bagisto.com/2.3/advanced/events.html#using-package-generator) Using Package Generator If you have the Bagisto Package Generator installed, you can use the following command to create a new event class in the `packages/Webkul/CustomEvent/src/Events` directory: ``` php artisan package:make-event CustomEvent Webkul/CustomEvent ``` If the event class already exists, you can use the --force option to overwrite it: ``` php artisan package:make-event CustomEvent Webkul/CustomEvent --force ``` Alternatively, if you don't have the package generator, you can create the file manually by creating a new class in the `packages/Webkul/CustomEvent/src/Events` directory. ### [#](https://devdocs.bagisto.com/2.3/advanced/events.html#manually-registering-events) Manually Registering Events In Bagisto, you register events manually in the `boot` method of your `EventServiceProvider.php` file. Here is an example of how to register events: ``` /** * Register any other events for your application. * * @return void */ public function boot() { //... Event::listen('event.name', 'path-upto-listener@function'); } ``` In this example, `event.name` is the name of the event, and `path-upto-listener@function` is the listener method that will handle the event. ### [#](https://devdocs.bagisto.com/2.3/advanced/events.html#manually-registering-listeners) Manually Registering Listeners When registering events, you specify the listener function to be executed when an event is triggered. Here is an example of how to register a listener: ``` class EventServiceProvider extends ServiceProvider { /** * Bootstrap services. * * @return void */ public function boot() { //... Event::listen('checkout.order.save.after', 'Webkul\Admin\Listeners\Order@sendNewOrderMail'); } } ``` In this example, the `checkout.order.save.after` event will trigger the `sendNewOrderMail` method of the `Order` listener in the `Webkul\Admin\Listeners` namespace. ## [#](https://devdocs.bagisto.com/2.3/advanced/events.html#specifying-events) Specifying Events In Bagisto, events are typically fired before and after the execution of CRUD operations. This allows listeners to perform additional actions, such as logging, notifications, or data manipulation, at specific points in the lifecycle of an operation. For example, you might have events fired during product creation, updating, or deletion. Here’s an example of firing events before and after saving an order: ``` namespace Webkul\Sales\Repositories; use Webkul\Sales\Contracts\Order; class OrderRepository extends Repository { public function create(array $data) { Event::dispatch('sales.order.create.before', $data); $order = parent::create($data); Event::dispatch('sales.order.create.after', $order); return $order; } } ``` ## [#](https://devdocs.bagisto.com/2.3/advanced/events.html#events-fired-in-bagisto) Events Fired in Bagisto In Bagisto, there are several events fired throughout its operations, allowing developers to hook into specific points in the application's lifecycle to customize behavior or add functionality. Here's a list of events that are fired in Bagisto, which you can listen to and handle as needed by creating event listeners: | Events Name | Functionality | Arguments | | -------------------------------------------------- | ----------------------------------------------------------------- | ------------------------- | | catalog.attribute.create.before | This event will be fired before attribute gets created. | - | | catalog.attribute.create.after | This event will be fired after attribute gets created. | `attribute` | | catalog.attribute.update.before | This event will be fired before attribute gets updated. | - | | catalog.attribute.update.after | This event will be fired after attribute gets updated. | `$attribute` | | catalog.attribute.delete.before | This event will be fired before attribute gets deleted. | `$id` | | catalog.attribute.delete.after | This event will be fired after attribute gets deleted. | `$id` | | catalog.attribute_family.create.before | This event will be fired before attribute family gets created. | - | | catalog.attribute_family.create.after | This event will be fired after attribute family gets created. | `attribute_family` | | catalog.attribute_family.update.before | This event will be fired before updating attribute family. | `$id` | | catalog.attribute_family.update.after | This event will be fired after updating attribute family. | `$attributeFamily` | | catalog.attribute_family.delete.before | This event will be fired before deleting attribute family. | `$id` | | catalog.attribute_family.delete.after | This event will be fired after deleting attribute family. | `$id` | | catalog.category.create.before | This event will be fired before creating category. | - | | catalog.category.create.after | This event will be fired after creating category. | `$category` | | catalog.category.update.before | This event will be fired before updating category. | `$id` | | catalog.category.update.after | This event will be fired after updating category. | `$category` | | catalog.category.delete.before | This event will be fired before deleting category. | `$id` | | catalog.category.delete.after | This event will be fired after deleting category. | `$id` | | catalog.categories.mass-update.before | This event will be fired before bulk category update. | `$categoryId` | | catalog.categories.mass-update.after | This event will be fired after bulk category update. | `$category` | | catalog.product.create.before | This event will be fired before product gets created. | - | | catalog.product.create.after | This event will be fired after product gets created. | `$product` | | catalog.product.update.before | This event will be fired before product gets updated. | `$id` | | catalog.product.update.after | This event will be fired after product gets updated. | `$product` | | catalog.product.delete.before | This event will be fired before product gets deleted. | `$id` | | catalog.product.delete.after | This event will be fired after product gets deleted. | `$id` | | products.datagrid.sync | This event will be fired to synicing datagrid product. | `true` | | cms.page.create.before | This event will be fired before cms page gets created. | - | | cms.page.create.after | This event will be fired after cms page gets created. | `$page` | | cms.page.update.before | This event will be fired before cms page gets updated. | `$id` | | cms.page.update.after | This event will be fired after cms page gets updated. | `$page` | | cms.page.delete.before | This event will be fired before cms page gets deleted. | `$id` | | cms.page.delete.after | This event will be fired after cms page gets deleted. | `id` | | customer.addresses.create.before | This event will be fired before customer address gets created. | - | | customer.addresses.create.after | This event will be fired after customer address gets created. | `$address` | | customer.addresses.update.before | This event will be fired before customer address gets updated. | `$id` | | customer.addresses.update.after | This event will be fired after customer address gets updated. | `$address` | | customer.addresses.delete.before | This event will be fired before customer address gets deleted. | `$id` | | customer.addresses.delete.after | This event will be fired after customer address gets deleted. | `$id` | | customer.registration.before | This event will be fired before customer gets created. | - | | customer.registration.after | This event will be fired after customer gets created. | - | | customer.update.before | This event will be fired before customer gets updated. | `$id` | | customer.update.after | This event will be fired after customer gets updated. | `$customer` | | customer.password.update.after | This event will be fired after customer password gets updated. | `$customer` | | customer.note.create.before | This event will be fired before customer note gets created. | `$id` | | customer.note.create.after | This event will be fired after customer note gets created. | `$customerNote` | | customer.subscription.before | This event will be fired before customer gets subscription. | - | | customer.subscription.after | This event will be fired after customer gets subscription. | `$subscription` | | customer.after.login | This event will be fired after customer login. | `auth()->guard()->user()` | | customer.delete.before | This event will be fired before customer gets deleted. | `$customer` | | customer.delete.after | This event will be fired after customer gets deleted. | `$customer` | | customer.customer_group.create.before | This event will be fired before customer group gets created. | - | | customer.customer_group.create.after | This event will be fired after customer group gets created. | `$customerGroup` | | customer.customer_group.update.before | This event will be fired before customer group gets updated. | `$id` | | customer.customer_group.update.after | This event will be fired after customer group gets updated. | `$customerGroup` | | customer.customer_group.delete.before | This event will be fired before customer group gets deleted. | `$id` | | customer.customer_group.delete.after | This event will be fired after customer group gets deleted. | `$id` | | customer.review.update.before | This event will be fired before customer review gets updated. | `$id` | | customer.review.update.after | This event will be fired after customer review gets updated. | `$review` | | customer.review.delete.before | This event will be fired before customer review gets deleted. | `$id` | | customer.review.delete.after | This event will be fired after customer review gets deleted. | `$id` | | customer.account.gdpr-request.create.before | This event will be fired before gdpr request created. | - | | customer.gdpr-request.create.after | This event will be fired after gdpr request created. | `$gdprRequest` | | customer.account.gdpr-request.update.before | This event will be fired before gdpr request updated. | - | | customer.account.gdpr-request.update.after | This event will be fired after gdpr request updated. | `$gdprRequest` | | customer.gdpr-request.update.after | This event will be fired after gdpr request updated. | `$gdprRequest` | | customer.gdpr-request.update.before | This event will be fired after gdpr request updated. | - | | marketing.search_seo.sitemap.create.before | This event will be fired before sitemaps gets created. | - | | marketing.search_seo.sitemap.create.after | This event will be fired after sitemaps gets created. | `$sitemap` | | marketing.search_seo.sitemap.update.before | This event will be fired before sitemaps gets updated. | `$id` | | marketing.search_seo.sitemap.update.after | This event will be fired after sitemaps gets updated. | `$sitemap` | | marketing.search_seo.sitemap.delete.before | This event will be fired before sitemaps gets deleted. | `$id` | | marketing.search_seo.sitemap.delete.after | This event will be fired after sitemaps gets deleted. | `$id` | | marketing.search_seo.search_synonyms.create.before | This event will be fired before search synonyms created | - | | marketing.search_seo.search_synonyms.create.after | This event will be fired after search synonyms created | `$searchSynonym` | | marketing.search_seo.search_synonyms.update.before | This event will be fired before synonyms gets updated. | `$id` | | marketing.search_seo.search_synonyms.update.after | This event will be fired after synonyms gets updated. | `$searchSynonym` | | marketing.search_seo.search_synonyms.delete.before | This event will be fired before synonyms gets deleted. | `$id` | | marketing.search_seo.search_synonyms.delete.after | This event will be fired before synonyms gets deleted. | `$id` | | marketing.search_seo.search_terms.create.before | This event will be fired before search search terms created | - | | marketing.search_seo.search_terms.create.after | This event will be fired after search search terms created | `$searchTerm` | | marketing.search_seo.search_terms.update.before | This event will be fired before search search terms updated | `$id` | | marketing.search_seo.search_terms.update.after | This event will be fired after search search terms updated | `$searchTerm` | | marketing.search_seo.search_terms.delete.before | This event will be fired before search search terms gets deleted | `$id` | | marketing.search_seo.search_terms.delete.after | This event will be fired after search search terms gets deleted | `$id` | | marketing.search_seo.url_rewrites.create.before | This event will be fired before search url rewrites gets created | - | | marketing.search_seo.url_rewrites.create.after | This event will be fired after search url rewrites gets created | `$urlRewrite` | | marketing.search_seo.url_rewrites.update.before | This event will be fired before search url rewrites gets updated | `$id` | | marketing.search_seo.url_rewrites.update.after | This event will be fired after search url rewrites gets updated | `$urlRewrite` | | marketing.search_seo.url_rewrites.delete.before | This event will be fired before search url rewrites gets deleted | `$id` | | marketing.search_seo.url_rewrites.delete.after | This event will be fired after search url rewrites gets deleted | `$id` | | marketing.campaigns.create.before | This event will be fired before campaigns gets created. | - | | marketing.campaigns.create.after | This event will be fired after campaigns gets created. | `$campaign` | | marketing.campaigns.update.before | This event will be fired before campaigns gets updated. | `$id` | | marketing.campaigns.update.after | This event will be fired after campaigns gets updated. | `$campaign` | | marketing.campaigns.delete.before | This event will be fired before campaigns gets deleted. | `$id` | | marketing.campaigns.delete.after | This event will be fired after campaigns gets deleted. | `$id` | | marketing.events.create.before | This event will be fired before marketing event gets created. | - | | marketing.events.create.after | This event will be fired after marketing event gets created. | `$event` | | marketing.events.update.before | This event will be fired before marketing event gets updated. | `$id` | | marketing.events.update.after | This event will be fired after marketing event gets updated. | `$event` | | marketing.events.delete.before | This event will be fired before marketing event gets deleted. | `$id` | | marketing.events.delete.after | This event will be fired after marketing event gets deleted. | `$id` | | marketing.templates.create.before | This event will be fired before templates gets created. | - | | marketing.templates.create.after | This event will be fired after templates gets created. | `$template` | | marketing.templates.update.before | This event will be fired before templates gets updated. | `$id` | | marketing.templates.update.after | This event will be fired after templates gets updated. | `$template` | | marketing.templates.delete.before | This event will be fired before templates gets deleted. | `$id` | | marketing.templates.delete.after | This event will be fired after templates gets deleted. | `$id` | | promotions.cart_rule.create.before | This event will be fired before cart rule gets created. | - | | promotions.cart_rule.create.after | This event will be fired after cart rule gets created. | `$cartRule` | | promotions.cart_rule.update.before | This event will be fired before cart rule gets updated. | `$id` | | promotions.cart_rule.update.after | This event will be fired after cart rule gets updated. | `$cartRule` | | promotions.cart_rule.delete.before | This event will be fired before cart rule gets deleted. | `$id` | | promotions.cart_rule.delete.after | This event will be fired after cart rule gets deleted. | `$id` | | promotions.catalog_rule.create.before | This event will be fired before catalog rule gets created. | - | | promotions.catalog_rule.create.after | This event will be fired after catalog rule gets created. | `$catalogRule` | | promotions.catalog_rule.update.before | This event will be fired before catalog rule gets updated. | `$id` | | promotions.catalog_rule.update.after | This event will be fired after catalog rule gets updated. | `$catalogRule` | | promotions.catalog_rule.delete.before | This event will be fired before catalog rule gets deleted. | `$id` | | promotions.catalog_rule.delete.after | This event will be fired after catalog rule gets deleted. | `$id` | | sales.order.comment.create.before | This event will be fired before order comment gets created. | - | | sales.order.comment.create.after | This event will be fired after order comment gets created. | `$comment` | | core.channel.create.before | This event will be fired before channel gets created. | - | | core.channel.create.after | This event will be fired after channel gets created. | `$channel` | | core.channel.update.before | This event will be fired before channel gets updated. | `$id` | | core.channel.update.after | This event will be fired after channel gets updated. | `$channel` | | core.channel.delete.before | This event will be fired before channel gets deleted. | `$id` | | core.channel.delete.after | This event will be fired after channel gets deleted. | `$id` | | core.exchange_rate.create.before | This event will be fired before exchange rate gets created. | - | | core.exchange_rate.create.after | This event will be fired after exchange rate gets created. | | | core.exchange_rate.update.before | This event will be fired before exchange rate gets updated. | `request()->id` | | core.exchange_rate.update.after | This event will be fired after exchange rate gets updated. | `$exchangeRate` | | core.exchange_rate.delete.before | This event will be fired before exchange rate gets deleted. | `$id` | | core.exchange_rate.delete.after | This event will be fired after exchange rate gets deleted. | `$id` | | inventory.inventory_source.create.before | This event will be fired before inventory source gets created. | - | | inventory.inventory_source.create.after | This event will be fired after inventory source gets created. | `$inventorySource` | | inventory.inventory_source.update.before | This event will be fired before inventory source gets updated. | `$id` | | inventory.inventory_source.update.after | This event will be fired after inventory source gets updated. | `$inventorySource` | | inventory.inventory_source.delete.before | This event will be fired before inventory source gets deleted. | `$id` | | inventory.inventory_source.delete.after | This event will be fired after inventory source gets deleted. | `$id` | | user.role.create.before | This event will be fired before role gets created. | - | | user.role.create.after | This event will be fired after role gets created. | `$role` | | user.role.update.before | This event will be fired before role gets updated. | `$id` | | user.role.update.after | This event will be fired after role gets updated. | `$role` | | user.role.delete.before | This event will be fired before role gets deleted. | `$id` | | user.role.delete.after | This event will be fired after role gets deleted. | `$id` | | theme_customization.create.before | This event will be fired before theme customization gets created. | - | | theme_customization.create.after | This event will be fired after theme customization gets created. | `$id` | | theme_customization.update.before | This event will be fired before theme customization gets updated. | `$id` | | theme_customization.update.after | This event will be fired after theme customization gets updated. | `$theme` | | theme_customization.delete.before | This event will be fired before theme customization gets deleted. | `$id` | | theme_customization.delete.after | This event will be fired after theme customization gets deleted. | `$id` | | user.admin.create.before | This event will be fired before admin gets created. | - | | user.admin.create.after | This event will be fired after admin gets created. | `$admin` | | user.admin.update.before | This event will be fired before admin gets updated. | `$id` | | user.admin.update.after | This event will be fired after admin gets updated. | `$admin` | | admin.password.update.after | This event will be fired after admin password gets updated. | `$admin` | | user.admin.delete.before | This event will be fired before admin gets deleted. | `$id` | | user.admin.delete.after | This event will be fired after admin gets deleted. | `$id` | | tax.category.create.before | This event will be fired before tax category gets created. | - | | tax.category.create.after | This event will be fired after tax category gets created. | `$taxCategory` | | tax.category.update.before | This event will be fired before tax category gets updated. | `$id` | | tax.category.update.after | This event will be fired after tax category gets updated. | `$taxCategory` | | tax.category.delete.before | This event will be fired before tax category gets deleted. | `$id` | | tax.category.delete.after | This event will be fired after tax category gets deleted. | `$id` | | tax.rate.create.before | This event will be fired before tax rate gets created. | - | | tax.rate.create.after | This event will be fired after tax rate gets created. | `$taxRate` | | tax.rate.update.before | This event will be fired before tax rate gets updated. | `$id` | | tax.rate.update.after | This event will be fired after tax rate gets updated. | `$taxRate` | | tax.rate.delete.before | This event will be fired before tax rate gets deleted. | `$id` | | tax.rate.delete.after | This event will be fired after tax rate gets deleted. | `$id` | | checkout.cart.delete.before | This event will be fired before cart item gets deleted. | `$itemId` | | checkout.cart.delete.after | This event will be fired after cart item gets deleted. | `$itemId` | | checkout.cart.add.before | This event will be fired before cart item gets created. | `$product->id` | | checkout.cart.add.after | This event will be fired after cart item gets created. | `$this->cart` | | checkout.cart.update.before | This event will be fired before cart item gets updated. | `$item` | | checkout.cart.update.after | This event will be fired after cart item gets updated. | `$item` | | checkout.cart.collect.totals.before | This event will be fired before collecting cart totals. | `$this->cart` | | checkout.cart.collect.totals.after | This event will be fired after collecting cart totals. | `$this->cart` | | checkout.cart.calculate.items.tax.before | This event will be fired before calculating cart items tax. | `$this->cart` | | checkout.cart.calculate.items.tax.after | This event will be fired after calculating cart items tax. | `$this->cart` | | core.configuration.save.before | This event will be fired before core configuration gets saved. | - | | core.configuration.save.after | This event will be fired after core configuration gets saved. | - | | core.currency.create.before | This event will be fired before currency gets created. | - | | core.currency.create.after | This event will be fired after currency gets created. | `$currency` | | core.currency.update.before | This event will be fired before currency gets updated. | `$id` | | core.currency.update.after | This event will be fired after currency gets updated. | `$currency` | | core.currency.delete.before | This event will be fired before currency gets deleted. | `$id` | | core.currency.delete.after | This event will be fired after currency gets deleted. | `$id` | | core.locale.create.before | This event will be fired before locale gets created. | - | | core.locale.create.after | This event will be fired after locale gets created. | `$locale` | | core.locale.update.before | This event will be fired before locale gets updated. | `$id` | | core.locale.update.after | This event will be fired after locale gets updated. | `$locale` | | core.locale.delete.before | This event will be fired before locale gets deleted. | `$id` | | core.locale.delete.after | This event will be fired after locale gets deleted. | `$id` | | sales.invoice.save.before | This event will be fired before invoice gets saved. | `$data` | | sales.invoice.save.after | This event will be fired after invoice gets saved. | `$invoice` | | checkout.order.save.before | This event will be fired before order gets saved. | `[$data]` | | checkout.order.save.after | This event will be fired after order gets saved. | `$order` | | checkout.order.orderitem.save.before | This event will be fired before order item gets saved. | `$item` | | checkout.order.orderitem.save.after | This event will be fired after order item gets saved. | `$orderItem` | | sales.order.cancel.before | This event will be fired before order gets canceled. | `$order` | | sales.order.cancel.after | This event will be fired after order gets canceled. | `$order` | | sales.order.update-status.before | This event will be fired before order status gets updated. | `$order` | | sales.order.update-status.after | This event will be fired after order status gets updated. | `$order` | | sales.refund.save.before | This event will be fired before order refund gets saved. | `$data` | | sales.refund.save.after | This event will be fired after order refund gets saved. | `$refund` | | sales.shipment.save.before | This event will be fired before shipment gets saved. | `$data` | | sales.shipment.save.after | This event will be fired after shipment gets saved. | `$shipment` | | checkout.load.index | This event will be fired on checkout page load. | - | ## [#](https://devdocs.bagisto.com/2.3/advanced/events.html#events-listen-in-bagisto) Events Listen in Bagisto - Event listen in bagisto is given below with their functionality. | Events name | functionality | | ------------------------------------------------- | ------------------------------------------------------------------------ | | bagisto.shop.layout.body.after | Listing this event to load css of shop layout. | | bagisto.admin.layout.head | Listing this event to load css of admin layout. | | checkout.order.save.after | Listing this event to send notification of new order. | | sales.order.update-status.after | Listing this event to send notification of when order status is changed. | | sales.invoice.save.after | Listing this event to add paypal smart button. | | bagisto.shop.customers.login_form_controls.before | Listing this event to add social login buttons. | | bagisto.shop.products.view.compare.after | Listing this event to add social share buttons. | ## [#](https://devdocs.bagisto.com/2.3/advanced/events.html#listening-to-existing-events) Listening to Existing Events Bagisto uses events and listeners to implement the observer pattern, allowing you to respond to various actions and events within the application. You can listen to specific events and execute custom code when those events are triggered. ### [#](https://devdocs.bagisto.com/2.3/advanced/events.html#registering-a-listener) Registering a Listener Open the `EventServiceProvider.php` file located in the `Providers` directory of your Bagisto application. This file is where you register event listeners. Inside the `boot()` method of `EventServiceProvider.php`, use the `Event::listen` method to register your listener. This method takes the event name and a callback function or a class method that will handle the event. ``` Event::listen('checkout.order.save.after', 'Webkul\Notification\Listeners\Order@createOrder'); ``` In the example above, we are listening to the `checkout.order.save.after` event and specifying the `createOrder` function from the `Order` listener class in the `Webkul\Notification\Listeners` namespace. Replace `'checkout.order.save.after'` with the specific event you want to listen to. In this example, it listens to the event triggered after saving an order during checkout. By registering the listener, you have associated the **`createOrder`** function with the **`checkout.order.save.after`** event. Whenever this event is triggered, the specified function will be executed. You can modify the listener function according to your requirements to perform the desired operation. [Product Type](https://devdocs.bagisto.com/2.3/advanced/create-product-type.html)[Helpers](https://devdocs.bagisto.com/2.3/advanced/helpers.html) ## Bagisto Transaction APIs Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/api/transactions.html#transactions) Transactions In this section, we will see all the APIs which are related to transactions. In Bagisto, we save all the transactions done by the customers using the Paypal Smart Button option. WARNING These are all transactions that are saved in the database after the payment done by the customers using the Paypal Smart Button option. ## [#](https://devdocs.bagisto.com/1.x/api/transactions.html#get-all-transactions) Get all transactions You can get all the transaction data from the Bagisto store. To get the data from the store, the customer must be authenticated. You can achieve this job by using the `transactions` API call resource. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET /api/transactions(?limit,page,pagination)` - Params | Name | Info | Type | | ---------- | -------------------------------------------- | ------ | | limit | Maximum number of records in each request | Number | | page | Records for specific page based on the limit | Number | | pagination | Will display all the records if set to `0` | Number | TIP If you are using pagination and want to know more info about responses then check the [explanation](https://devdocs.bagisto.com/1.x/api/explanation) portion. ### [#](https://devdocs.bagisto.com/1.x/api/transactions.html#examples) Examples #### [#](https://devdocs.bagisto.com/1.x/api/transactions.html#_1-records-for-specific-page) 1\. Records for specific page - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/api/transactions?page=1` TIP If you didn't use the page (?page=x) filter, then it returns the data of the first page by default. `GET http(s)://example.com/api/transactions` Response ``` { "data": [\ {\ "id": 1,\ "transaction_id": "47427618SF330010G",\ "status": "COMPLETED",\ "type": "CAPTURE",\ "payment_method": "paypal_smart_button",\ "data": "{\"0\": {\"items\": [{\"sku\": \"12\", \"name\": \"Soft Toy\", \"category\": \"PHYSICAL_GOODS\", \"quantity\": \"1\", \"unit_amount\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}}], \"payee\": {\"merchant_id\": \"85PGX7H6T2ZLW\", \"email_address\": \"prachiwebkul-facilitator@gmail.com\"}, \"amount\": {\"value\": \"150.00\", \"breakdown\": {\"shipping\": {\"value\": \"0.00\", \"currency_code\": \"USD\"}, \"tax_total\": {\"value\": \"0.00\", \"currency_code\": \"USD\"}, \"item_total\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}}, \"currency_code\": \"USD\"}, \"payments\": {\"captures\": [{\"id\": \"2U5068420K488272L\", \"links\": [{\"rel\": \"self\", \"href\": \"https://api.sandbox.paypal.com/v2/payments/captures/2U5068420K488272L\", \"method\": \"GET\"}, {\"rel\": \"refund\", \"href\": \"https://api.sandbox.paypal.com/v2/payments/captures/2U5068420K488272L/refund\", \"method\": \"POST\"}, {\"rel\": \"up\", \"href\": \"https://api.sandbox.paypal.com/v2/checkout/orders/47427618SF330010G\", \"method\": \"GET\"}], \"amount\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}, \"status\": \"COMPLETED\", \"create_time\": \"2021-04-09T09:28:03Z\", \"update_time\": \"2021-04-09T09:28:03Z\", \"final_capture\": true, \"seller_protection\": {\"status\": \"ELIGIBLE\", \"dispute_categories\": [\"ITEM_NOT_RECEIVED\", \"UNAUTHORIZED_TRANSACTION\"]}, \"seller_receivable_breakdown\": {\"net_amount\": {\"value\": \"143.85\", \"currency_code\": \"USD\"}, \"paypal_fee\": {\"value\": \"6.15\", \"currency_code\": \"USD\"}, \"gross_amount\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}}}]}, \"shipping\": {\"name\": {\"full_name\": \"John Doe\"}, \"address\": {\"postal_code\": \"110045\", \"admin_area_1\": \"DL\", \"admin_area_2\": \"New Delhi\", \"country_code\": \"IN\", \"address_line_1\": \"Dwarka\"}}, \"reference_id\": \"default\", \"soft_descriptor\": \"PAYPAL *TESTFACILIT\"}, \"name\": {\"surname\": \"Doe\", \"given_name\": \"John\"}, \"address\": {\"postal_code\": \"110045\", \"admin_area_1\": \"DL\", \"admin_area_2\": \"New Delhi\", \"country_code\": \"IN\", \"address_line_1\": \"Dwarka\"}, \"payer_id\": \"8KC42JLS656PQ\", \"email_address\": \"sb-eyqoq4881652@personal.example.com\"}",\ "updated_at": "2021-04-09T09:28:08.000000Z",\ "created_at": "2021-04-09T09:28:08.000000Z"\ }\ ], "links": { "first": "https://example.com/api/transactions?page=1", "last": "https://example.com/api/transactions?page=1", "prev": null, "next": null }, "meta": { "current_page": 1, "from": 1, "last_page": 1, "links": [\ {\ "url": null,\ "label": "« Previous",\ "active": false\ },\ {\ "url": "https://example.com/api/transactions?page=1",\ "label": "1",\ "active": true\ },\ {\ "url": null,\ "label": "Next »",\ "active": false\ }\ ], "path": "https://example.com/api/transactions", "per_page": 10, "to": 1, "total": 1 } } ``` #### [#](https://devdocs.bagisto.com/1.x/api/transactions.html#_2-get-all-transactions-without-pagination) 2\. Get all transactions without pagination You can also get all the transaction data at once from the Bagisto store without pagination. To get the data, the customer must be authenticated. For this, you have to pass `pagination=0` in the query parameter with the `transactions` resource in the API URL. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/public/api/transactions?pagination=0` Response ``` { "data": [\ {\ "id": 1,\ "transaction_id": "47427618SF330010G",\ "status": "COMPLETED",\ "type": "CAPTURE",\ "payment_method": "paypal_smart_button",\ "data": "{\"0\": {\"items\": [{\"sku\": \"12\", \"name\": \"Soft Toy\", \"category\": \"PHYSICAL_GOODS\", \"quantity\": \"1\", \"unit_amount\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}}], \"payee\": {\"merchant_id\": \"85PGX7H6T2ZLW\", \"email_address\": \"prachiwebkul-facilitator@gmail.com\"}, \"amount\": {\"value\": \"150.00\", \"breakdown\": {\"shipping\": {\"value\": \"0.00\", \"currency_code\": \"USD\"}, \"tax_total\": {\"value\": \"0.00\", \"currency_code\": \"USD\"}, \"item_total\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}}, \"currency_code\": \"USD\"}, \"payments\": {\"captures\": [{\"id\": \"2U5068420K488272L\", \"links\": [{\"rel\": \"self\", \"href\": \"https://api.sandbox.paypal.com/v2/payments/captures/2U5068420K488272L\", \"method\": \"GET\"}, {\"rel\": \"refund\", \"href\": \"https://api.sandbox.paypal.com/v2/payments/captures/2U5068420K488272L/refund\", \"method\": \"POST\"}, {\"rel\": \"up\", \"href\": \"https://api.sandbox.paypal.com/v2/checkout/orders/47427618SF330010G\", \"method\": \"GET\"}], \"amount\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}, \"status\": \"COMPLETED\", \"create_time\": \"2021-04-09T09:28:03Z\", \"update_time\": \"2021-04-09T09:28:03Z\", \"final_capture\": true, \"seller_protection\": {\"status\": \"ELIGIBLE\", \"dispute_categories\": [\"ITEM_NOT_RECEIVED\", \"UNAUTHORIZED_TRANSACTION\"]}, \"seller_receivable_breakdown\": {\"net_amount\": {\"value\": \"143.85\", \"currency_code\": \"USD\"}, \"paypal_fee\": {\"value\": \"6.15\", \"currency_code\": \"USD\"}, \"gross_amount\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}}}]}, \"shipping\": {\"name\": {\"full_name\": \"John Doe\"}, \"address\": {\"postal_code\": \"110045\", \"admin_area_1\": \"DL\", \"admin_area_2\": \"New Delhi\", \"country_code\": \"IN\", \"address_line_1\": \"Dwarka\"}}, \"reference_id\": \"default\", \"soft_descriptor\": \"PAYPAL *TESTFACILIT\"}, \"name\": {\"surname\": \"Doe\", \"given_name\": \"John\"}, \"address\": {\"postal_code\": \"110045\", \"admin_area_1\": \"DL\", \"admin_area_2\": \"New Delhi\", \"country_code\": \"IN\", \"address_line_1\": \"Dwarka\"}, \"payer_id\": \"8KC42JLS656PQ\", \"email_address\": \"sb-eyqoq4881652@personal.example.com\"}",\ "updated_at": "2021-04-09T09:28:08.000000Z",\ "created_at": "2021-04-09T09:28:08.000000Z"\ }\ ] } ``` ## [#](https://devdocs.bagisto.com/1.x/api/transactions.html#get-transaction-by-id) Get transaction by id To get the specific transaction details, you have to pass an `transaction_id` as a request payload in the API URL. - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET /api/transactions/{transaction_id}` - Params | Name | Info | Type | | -------------- | ---------------- | ------ | | transaction_id | Transaction's ID | Number | ### [#](https://devdocs.bagisto.com/1.x/api/transactions.html#examples-2) Examples Let's fetch specific transaction, - Headers | Key | Value | Info | | ------------- | --------------------- | ------------------------------------ | | Accept | application/json | | | Authorization | Bearer `token-string` | Use only when you pass `?token=true` | - Request `GET http(s)://example.com/api/transactions/1` Response ``` { "id": 1, "transaction_id": "47427618SF330010G", "status": "COMPLETED", "type": "CAPTURE", "payment_method": "paypal_smart_button", "data": "{\"0\": {\"items\": [{\"sku\": \"12\", \"name\": \"Soft Toy\", \"category\": \"PHYSICAL_GOODS\", \"quantity\": \"1\", \"unit_amount\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}}], \"payee\": {\"merchant_id\": \"85PGX7H6T2ZLW\", \"email_address\": \"prachiwebkul-facilitator@gmail.com\"}, \"amount\": {\"value\": \"150.00\", \"breakdown\": {\"shipping\": {\"value\": \"0.00\", \"currency_code\": \"USD\"}, \"tax_total\": {\"value\": \"0.00\", \"currency_code\": \"USD\"}, \"item_total\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}}, \"currency_code\": \"USD\"}, \"payments\": {\"captures\": [{\"id\": \"2U5068420K488272L\", \"links\": [{\"rel\": \"self\", \"href\": \"https://api.sandbox.paypal.com/v2/payments/captures/2U5068420K488272L\", \"method\": \"GET\"}, {\"rel\": \"refund\", \"href\": \"https://api.sandbox.paypal.com/v2/payments/captures/2U5068420K488272L/refund\", \"method\": \"POST\"}, {\"rel\": \"up\", \"href\": \"https://api.sandbox.paypal.com/v2/checkout/orders/47427618SF330010G\", \"method\": \"GET\"}], \"amount\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}, \"status\": \"COMPLETED\", \"create_time\": \"2021-04-09T09:28:03Z\", \"update_time\": \"2021-04-09T09:28:03Z\", \"final_capture\": true, \"seller_protection\": {\"status\": \"ELIGIBLE\", \"dispute_categories\": [\"ITEM_NOT_RECEIVED\", \"UNAUTHORIZED_TRANSACTION\"]}, \"seller_receivable_breakdown\": {\"net_amount\": {\"value\": \"143.85\", \"currency_code\": \"USD\"}, \"paypal_fee\": {\"value\": \"6.15\", \"currency_code\": \"USD\"}, \"gross_amount\": {\"value\": \"150.00\", \"currency_code\": \"USD\"}}}]}, \"shipping\": {\"name\": {\"full_name\": \"John Doe\"}, \"address\": {\"postal_code\": \"110045\", \"admin_area_1\": \"DL\", \"admin_area_2\": \"New Delhi\", \"country_code\": \"IN\", \"address_line_1\": \"Dwarka\"}}, \"reference_id\": \"default\", \"soft_descriptor\": \"PAYPAL *TESTFACILIT\"}, \"name\": {\"surname\": \"Doe\", \"given_name\": \"John\"}, \"address\": {\"postal_code\": \"110045\", \"admin_area_1\": \"DL\", \"admin_area_2\": \"New Delhi\", \"country_code\": \"IN\", \"address_line_1\": \"Dwarka\"}, \"payer_id\": \"8KC42JLS656PQ\", \"email_address\": \"sb-eyqoq4881652@personal.example.com\"}", "updated_at": "2021-04-09T09:28:08.000000Z", "created_at": "2021-04-09T09:28:08.000000Z" } ``` [Shipments](https://devdocs.bagisto.com/1.x/api/shipments.html)[Reviews](https://devdocs.bagisto.com/1.x/api/reviews.html) ## Bagisto Helper Methods Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#helpers) Helpers - [Introduction](https://devdocs.bagisto.com/2.x/advanced/helpers.html#introduction) - [Core Helpers](https://devdocs.bagisto.com/2.x/advanced/helpers.html#core-helpers) - [Get the version number of the Bagisto.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-the-version-number-of-the-bagisto) - [Get all channels](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-all-channels) - [Get current channel models](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-current-channel-models) - [Set the current channel](https://devdocs.bagisto.com/2.x/advanced/helpers.html#set-the-current-channel) - [Get current channel code](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-current-channel-code) - [Get default channel models](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-default-channel-models) - [Set the default channel](https://devdocs.bagisto.com/2.x/advanced/helpers.html#set-the-default-channel) - [Get the default channel code configured in config/app.php.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-the-default-channel-code-configured-in-config-app-php) - [Get default locale code from default channel](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-default-locale-code-from-default-channel) - [Get channel from request](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-channel-from-request) - [Get channel code from request](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-channel-code-from-request) - [Get the channel name](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-the-channel-name) - [Get all locales](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-all-locales) - [Get current locale](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-current-locale) - [Get locale from request](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-locale-from-request) - [Get locale code from request](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-locale-code-from-request) - [Check requested locale code in requested channel.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#check-requested-locale-code-in-requested-channel) - [Get all currencies](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-all-currencies) - [Get base currency model](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-base-currency-model) - [Get base channel's currency code](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-base-channel-s-currency-code) - [Get base channel's currency model](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-base-channel-s-currency-model) - [Get base channel's currency code](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-base-channel-s-currency-code) - [Set current currency](https://devdocs.bagisto.com/2.x/advanced/helpers.html#set-current-currency) - [Get current channel's currency model](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-current-channel-s-currency-model) - [Get exchange rates](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-exchange-rates) - [Converts price.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#converts-price) - [Converts to base price](https://devdocs.bagisto.com/2.x/advanced/helpers.html#converts-to-base-price) - [Format and convert price with currency symbol](https://devdocs.bagisto.com/2.x/advanced/helpers.html#format-and-convert-price-with-currency-symbol) - [Get currency symbol from currency code](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-currency-symbol-from-currency-code) - [Format and convert price with currency symbol](https://devdocs.bagisto.com/2.x/advanced/helpers.html#format-and-convert-price-with-currency-symbol) - [Format price with base currency symbol.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#format-price-with-base-currency-symbol) - [Checks if current date of the given channel (in the channel timezone) is within the range](https://devdocs.bagisto.com/2.x/advanced/helpers.html#checks-if-current-date-of-the-given-channel-in-the-channel-timezone-is-within-the-range) - [Get channel timestamp, timestamp will be builded with channel timezone settings.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-channel-timestamp-timestamp-will-be-builded-with-channel-timezone-settings) - [Check whether sql date is empty.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#check-whether-sql-date-is-empty) - [Format date using current channel.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#format-date-using-current-channel) - [Retrieve information from configuration](https://devdocs.bagisto.com/2.x/advanced/helpers.html#retrieve-information-from-configuration) - [Retrieve all countries](https://devdocs.bagisto.com/2.x/advanced/helpers.html#retrieve-all-countries) - [Get country name by code](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-country-name-by-code) - [Retrieve all country states](https://devdocs.bagisto.com/2.x/advanced/helpers.html#retrieve-all-country-states) - [Retrieve all grouped states by country code.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#retrieve-all-grouped-states-by-country-code) - [Get states by country code.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-states-by-country-code) - [Get guest customer group](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-guest-customer-group) - [Is country required](https://devdocs.bagisto.com/2.x/advanced/helpers.html#is-country-required) - [Is state required](https://devdocs.bagisto.com/2.x/advanced/helpers.html#is-state-required) - [Is postcode required.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#is-postcode-required) - [Week range](https://devdocs.bagisto.com/2.x/advanced/helpers.html#week-range) - [Method to sort through the acl items and put them in order](https://devdocs.bagisto.com/2.x/advanced/helpers.html#method-to-sort-through-the-acl-items-and-put-them-in-order) - [Get config field](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-config-field) - [Convert to associative array](https://devdocs.bagisto.com/2.x/advanced/helpers.html#convert-to-associative-array) - [Array set](https://devdocs.bagisto.com/2.x/advanced/helpers.html#array-set) - [Convert empty strings to null.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#convert-empty-strings-to-null) - [Create singleton object through single facade.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#create-singleton-object-through-single-facade) - [Returns a string as selector part for identifying elements in views.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#returns-a-string-as-selector-part-for-identifying-elements-in-views) - [Get tax category through Id.](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-tax-category-through-id) - [Get Shop email sender details](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-shop-email-sender-details) - [Get Admin email details](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-admin-email-details) - [Get core config values](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-core-config-values) - [Get default config](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-default-config) - [Get max upload size from the php.ini file](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-max-upload-size-from-the-php-ini-file) ## [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#introduction) Introduction Bagisto provides a range of helper methods in its packages to streamline and simplify the development process. These helpers are designed to offer utility functions that facilitate common tasks, reducing the amount of boilerplate code developers need to write and enhancing overall productivity. ## [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#core-helpers) Core Helpers The core helper methods are part of the Core class in the `Webkul\Core` namespace. These methods provide essential functionality that can be utilized across different parts of the application, making development more efficient and consistent. Let's explore some common methods: ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-the-version-number-of-the-bagisto) Get the version number of the Bagisto. To get the version number of your Bagisto application, you can use the `core()->version()` method as shown below: ``` core()->version() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-all-channels) Get all channels The `core()->getAllChannels()` method is a helper function in Bagisto that retrieves all the available channels in the application. Channels in Bagisto represent different storefronts or websites, allowing for multi-channel retailing from a single Bagisto installation. This method is useful for obtaining a list of all configured channels, which can be utilized in various parts of the application. To get all the channels in your Bagisto application, you can use the `core()->getAllChannels()` method as shown below ``` core()->getAllChannels() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-current-channel-models) Get current channel models The `core()->getCurrentChannel()` method is a helper function in Bagisto that retrieves the current channel being accessed in the application. Channels in Bagisto represent different storefronts or websites, allowing for multi-channel retailing from a single installation. This method is useful for obtaining details about the specific channel currently in use. ``` core()->getCurrentChannel() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#set-the-current-channel) Set the current channel The `core()->setCurrentChannel($channel)` method is a helper function in Bagisto that allows you to set the current channel being accessed in the application. This can be useful in scenarios where you need to dynamically change the active channel based on certain conditions. ``` core()->setCurrentChannel($channel) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-current-channel-code) Get current channel code The `core()->getCurrentChannelCode()` method is a helper function in Bagisto that retrieves the code of the currently active channel. This is particularly useful when you need to identify the channel context in which your application is operating. ``` core()->getCurrentChannelCode() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-default-channel-models) Get default channel models The `core()->getDefaultChannel()` method in Bagisto is a helper function that retrieves the default channel model. This is useful when you need to access the default channel's details, such as its configuration, settings, and associated models. ``` core()->getDefaultChannel() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#set-the-default-channel) Set the default channel Setting the default channel in Bagisto typically involves configuration settings rather than a direct method call like `core()->setDefaultChannel()`. Normally, you would define the default channel in your configuration files or through administrative settings in Bagisto's admin panel. Here’s a general approach to setting the default channel: ``` core()->setDefaultChannel() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-the-default-channel-code-configured-in-config-app-php) Get the default channel code configured in `config/app.php`. To retrieve the default channel code configured in config/app.php using Bagisto's helper function `core()->getDefaultChannelCode()`, you typically need to ensure that Bagisto explicitly defines this helper function to access configuration settings directly related to channels. Here’s how you would typically use it: ``` core()->getDefaultChannelCode() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-default-locale-code-from-default-channel) Get default locale code from default channel The function `core()->getDefaultLocaleCodeFromDefaultChannel()` retrieves the locale code for the default language set in the default channel of Bagisto. This can be useful for ensuring that content is displayed in the correct language based on the default settings of the e-commerce platform. ``` core()->getDefaultLocaleCodeFromDefaultChannel() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-channel-from-request) Get channel from request The function `core()->getRequestedChannel()` retrieves the current channel from the request. This is useful in a multi-channel environment where different settings, configurations, or customizations might be needed based on the channel from which the request originated. ``` core()->getRequestedChannel() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-channel-code-from-request) Get channel code from request The function `core()->getRequestedChannelCode()` retrieves the code of the current channel from the request. This helps identify which channel the request is associated with, allowing for channel-specific processing or configurations in a multi-channel setup. ``` core()->getRequestedChannelCode() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-the-channel-name) Get the channel name The function `core()->getChannelName()` retrieves the name of the current channel. This is useful for displaying or logging the name of the channel that is currently active or being accessed. ``` core()->getChannelName() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-all-locales) Get all locales The function `core()->getChannelName()` retrieves the name of the current channel. This is useful for displaying or logging the name of the channel that is currently active or being accessed. ``` core()->getAllLocales() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-current-locale) Get current locale The function `core()->getCurrentLocale()` retrieves the current locale being used. This is useful for determining the language and regional settings that are currently active, allowing for appropriate content and formatting adjustments based on the locale. ``` core()->getCurrentLocale() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-locale-from-request) Get locale from request The function `core()->getRequestedLocale()` retrieves the locale from the current request. This is useful for determining the language and regional settings that the user has requested, allowing the application to display content in the appropriate language and format. ``` core()->getRequestedLocale() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-locale-code-from-request) Get locale code from request The function `core()->getRequestedLocaleCode($localeKey = 'locale', $fallback = true)` retrieves the locale code from the current request. - `$localeKey (default is 'locale')`: Specifies the key to look for in the request to get the locale code. - `$fallback (default is true)`: If set to true, it will provide a fallback locale code if the requested locale is not found. ``` core()->getRequestedLocaleCode($localeKey = 'locale', $fallback = true) ``` Here if you want to use admin locale, you can pass it as an argument. This function is useful for obtaining the locale code based on user requests, with the option to fall back to a default or administrative locale if necessary. ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#check-requested-locale-code-in-requested-channel) Check requested locale code in requested channel. The function `core()->getRequestedLocaleCodeInRequestedChannel()` checks and retrieves the locale code from the current request within the context of the requested channel. This ensures that the locale code being used is valid and applicable for the specified channel, allowing for accurate localization based on both the channel and the user's request. ``` core()->getRequestedLocaleCodeInRequestedChannel() ``` If not found, then set channel default locale code. ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-all-currencies) Get all currencies The function `core()->getAllCurrencies()` retrieves a list of all available currencies in the system. This can be useful for displaying currency options to users, configuring pricing, or handling multi-currency setups in an e-commerce platform. ``` core()->getAllCurrencies() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-base-currency-model) Get base currency model The function `core()->getBaseCurrency()` retrieves the base currency model used in the application. This is typically the default currency against which other currencies are converted or displayed in multi-currency environments within an e-commerce platform. ``` core()->getBaseCurrency() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-base-channel-s-currency-code) Get base channel's currency code The function `core()->getBaseCurrencyCode()` retrieves the currency code of the base channel, which is essential for operations involving currency management and display within an e-commerce application. ``` core()->getBaseCurrencyCode() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-base-channel-s-currency-model) Get base channel's currency model The function `core()->getChannelBaseCurrency()` retrieves the currency model of the base channel in Bagisto. This is useful for accessing detailed information about the currency, such as its code, symbol, conversion rates, and other attributes related to currency management within the e-commerce platform. ``` core()->getChannelBaseCurrency() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-base-channel-s-currency-code-2) Get base channel's currency code This function `core()->getChannelBaseCurrencyCode()` retrieves the currency code of the base channel, which is essential for operations involving currency management and display within an e-commerce application. ``` core()->getChannelBaseCurrencyCode() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#set-current-currency) Set current currency To set the current currency in Bagisto using the `core()->setCurrentCurrency()` method, you typically need to pass the desired currency code as an argument. Here's how you can do it: ``` core()->setCurrentCurrency() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-current-channel-s-currency-model) Get current channel's currency model ``` core()->getCurrentCurrency() ``` - **Get current channel's currency code.** To retrieve the current channel's currency model in Bagisto, you should use the `core()->getCurrentCurrency()` method. Here's how you can use it: ``` core()->getCurrentCurrencyCode() ``` This function call retrieves the currency model of the current channel, allowing you to access attributes such as the currency code, symbol, exchange rates, and other relevant information related to currency management within your e-commerce application. ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-exchange-rates) Get exchange rates To get exchange rates in Bagisto, you typically need to specify the base currency and the target currency for which you want to retrieve the exchange rate. Here's how you can achieve this: ``` core()->getExchangeRate() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#converts-price) Converts price. The `core()->convertPrice()` function in Bagisto is used to convert a given amount from the base currency to a specified target currency. Here's how you can use it: ``` $amount = 100; // Replace with the amount you want to convert $targetCurrencyCode = 'EUR'; // Replace with the target currency code $convertedAmount = core()->convertPrice($amount, $targetCurrencyCode); ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#converts-to-base-price) Converts to base price The `core()->convertToBasePrice()` function in Bagisto is used to convert a given amount from a specified currency (target currency) to the base currency of the application. Here's how you can use it: ``` $amount = 200; // Replace with the amount you want to convert to the base currency $targetCurrencyCode = 'EUR'; // Replace with the target currency code $baseAmount = core()->convertToBasePrice($amount, $targetCurrencyCode); ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#format-and-convert-price-with-currency-symbol) Format and convert price with currency symbol To format and convert a price to the base currency while including the currency symbol, you typically need to use formatting functions along with conversion. Here’s how you can achieve this in Bagisto: ``` core()->convertToBasePrice($amount) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-currency-symbol-from-currency-code) Get currency symbol from currency code To get the currency symbol from a currency code in Bagisto, you typically use the `currencySymbol()` method with the currency code as an argument. Here's how you can do it: ``` core()->currencySymbol($amount) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#format-and-convert-price-with-currency-symbol-2) Format and convert price with currency symbol To format and convert a price with a currency symbol in Bagisto, you can use the `core()->formatPrice()` method. Here’s how you can use it: ``` $price = 100; // Replace with the price you want to format and convert $currencyCode = 'USD'; // Replace with the currency code you want to use, if different from the default $formattedPrice = core()->formatPrice($price, $currencyCode); ``` This function retrieves the formatted price as a string with the currency symbol based on the provided or default currency code. ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#format-price-with-base-currency-symbol) Format price with base currency symbol. In Bagisto, if you want to format a price with the base currency symbol, considering the option to encode it, you would typically handle it like this: This method also give ability to encode the base currency symbol and its optional. ``` core()->formatBasePrice($price, $isEncoded = false) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#checks-if-current-date-of-the-given-channel-in-the-channel-timezone-is-within-the-range) Checks if current date of the given channel (in the channel timezone) is within the range The `core()->isChannelDateInInterval($dateFrom = null, $dateTo = null)` function in Bagisto checks if the current date of the given channel (considering the channel's timezone) falls within the specified date range. ``` core()->isChannelDateInInterval($dateFrom = null, $dateTo = null) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-channel-timestamp-timestamp-will-be-builded-with-channel-timezone-settings) Get channel timestamp, timestamp will be builded with channel timezone settings. To retrieve a timestamp that adheres to a specific channel's timezone settings in Bagisto, you typically use the `core()->channelTimeStamp($channel)` function. Here's how you can implement it: ``` core()->channelTimeStamp($channel) ``` Ensure that the $channel variable is correctly instantiated with the channel object before passing it to `core()->channelTimeStamp()`. This method ensures that timestamps align with the timezone settings defined for each channel in your Bagisto application. ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#check-whether-sql-date-is-empty) Check whether sql date is empty. In Bagisto, there isn't a specific `core()->is_empty_date()` function predefined. However, if you need to check whether a SQL date field is empty or null in PHP, you can do it as follows ``` core()->is_empty_date($date) ``` This function retrieves the date in the specified format, adjusted according to the timezone and locale settings of the current channel in Bagisto ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#format-date-using-current-channel) Format date using current channel. In Bagisto, you can format a date using the current channel's timezone and locale using the `core()->formatDate()` function. Here's how you can use it ``` core()->formatDate($date = null, $format = 'd-m-Y H:i:s') ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#retrieve-information-from-configuration) Retrieve information from configuration In Bagisto, to retrieve information from configuration using `core()->getConfigData()`, you can fetch specific configuration fields based on the provided parameters. Here’s how you can use it ``` core()->getConfigData($field, $channel = null, $locale = null) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#retrieve-all-countries) Retrieve all countries To retrieve all countries in Bagisto, you can use the `core()->countries()` function. Here's how you can fetch and utilize this data: ``` core()->countries() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-country-name-by-code) Get country name by code To get the country name by its ISO 3166-1 alpha-2 code in Bagisto, you can use the `core()->country_name($code)` function. Here's how you can use it ``` core()->country_name($code) ``` This function retrieves the full name of the country based on its ISO 3166-1 alpha-2 code ($code). ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#retrieve-all-country-states) Retrieve all country states To retrieve all states (or provinces) of a specific country in Bagisto, you can use the `core()->states($countryCode)` function. Here's how you can use it ``` core()->states($countryCode) ``` This function returns a collection of state objects for the specified country ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#retrieve-all-grouped-states-by-country-code) Retrieve all grouped states by country code. In Bagisto, to retrieve all states grouped by country code, you can use the `core()->groupedStatesByCountries()` function. This function organizes states or provinces by their respective countries. Here's how you can use it: ``` core()->groupedStatesByCountries() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-states-by-country-code) Get states by country code. To retrieve states (or provinces) by country code in Bagisto, you can use the `core()->findStateByCountryCode($countryCode, $stateCode = null)` function. Here’s how you can use it ``` core()->findStateByCountryCode($countryCode = null, $stateCode = null) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-guest-customer-group) Get guest customer group In Bagisto, to get the guest customer group, you can use the `core()->getGuestCustomerGroup()` function. Here's how you can use it ``` core()->getGuestCustomerGroup() ``` This function retrieves the guest customer group configured in your Bagisto application. It returns an object representing the guest customer group ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#is-country-required) Is country required In Bagisto, to check if a country selection is required (typically in address forms or checkout processes), you can use the `core()->isCountryRequired()` function. Here's how you can use it: ``` core()->isCountryRequired() ``` This function returns a boolean (true or false) indicating whether the country selection is mandatory ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#is-state-required) Is state required In Bagisto, to check if a state or province selection is required (typically in address forms or checkout processes), you can use the `core()->isStateRequired()` function. Here's how you can use it: ``` core()->isStateRequired() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#is-postcode-required) Is postcode required. This function returns a boolean (true or false) indicating whether the postcode (or ZIP code) selection is mandatory. ``` core()->isPostCodeRequired() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#week-range) Week range In Bagisto, there isn't a specific `core()->xWeekRange()` function predefined. However, if you need to calculate a date range based on a given date and the number of weeks before or after that date, you can achieve this using PHP's DateTime and DateInterval classes. Here’s how you can calculate a week range ``` core()->xWeekRange($date, $day) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#method-to-sort-through-the-acl-items-and-put-them-in-order) Method to sort through the acl items and put them in order In Bagisto, there isn't a specific `core()->sortItems()` function predefined for sorting ACL items directly. However, you can implement a custom function to sort ACL items based on your specific criteria ``` core()->sortItems($items) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-config-field) Get config field You can retrieve a specific configuration field value using a method like `core()->getConfigField($fieldName)` ``` core()->getConfigField($fieldName) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#convert-to-associative-array) Convert to associative array In Bagisto, there isn't a specific `core()->convertToAssociativeArray()` function predefined for converting items into associative arrays directly. However, you can easily achieve this using PHP's array functions and loops. Here's a straightforward way to convert a list of items into an associative array based on a key: ``` core()->convertToAssociativeArray($items) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#array-set) Array set There is a helper function array_set() that allows you to set a value within a nested array using a dot-notation key. ``` core()->array_set($array, $key, $value) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#convert-empty-strings-to-null) Convert empty strings to null. `convertEmptyStringsToNull` function is designed to convert empty strings ('') or the string 'null' to null within an array. Let's break down the function and how it works: ``` core()->convertEmptyStringsToNull($array) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#create-singleton-object-through-single-facade) Create singleton object through single facade. By using getSingletonInstance() method in Bagisto you can Create singleton object through single facade. ``` core()->getSingletonInstance($className) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#returns-a-string-as-selector-part-for-identifying-elements-in-views) Returns a string as selector part for identifying elements in views. The `taxRateAsIdentifier` function provided is a helper function in Bagisto that generates a string identifier based on a tax rate. Here’s a breakdown of how it works and how you can use it in your Bagisto application: It Returns a string as selector part for identifying elements in views. ``` core()->taxRateAsIdentifier(float $taxRate) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-tax-category-through-id) Get tax category through Id. To retrieve a tax category by its ID using a method like `core()->getTaxCategoryById($id)` in Bagisto or Laravel, you typically need to access the appropriate repository or model where tax categories are stored. Here’s how you can implement such a method assuming you are working within the Bagisto framework ``` core()->getTaxCategoryById($id) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-shop-email-sender-details) Get Shop email sender details To retrieve the shop email sender details in Bagisto or Laravel, you typically need to access configuration settings where these details are stored, such as in the environment configuration or a dedicated settings repository. Here’s a conceptual implementation of how you might achieve this functionality: ``` core()->getSenderEmailDetails() ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-admin-email-details) Get Admin email details To retrieve the admin email details in Bagisto, you typically need to access the configuration settings where these details are stored. Here’s how you can conceptualize and implement the `core()->getAdminEmailDetails()` function: ``` core()->getAdminEmailDetails() ``` By implementing `getAdminEmailDetails()` in your Bagisto application, you can efficiently retrieve and utilize the configured admin details for various administrative functionalities, ensuring clarity and reliability in your communication processes. ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-core-config-values) Get core config values To retrieve core configuration values in Bagisto application using a method like `core()->getCoreConfig($field, $channel, $locale)`, you would typically access configuration settings specific to your application's setup. Here’s a conceptual implementation for such a method: ``` core()->getCoreConfig($field, $channel, $locale) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-default-config) Get default config By using the `getDefaultConfig($field)` method, you can achieve the default config. ``` core()->getDefaultConfig($field) ``` ### [#](https://devdocs.bagisto.com/2.x/advanced/helpers.html#get-max-upload-size-from-the-php-ini-file) Get max upload size from the php.ini file By using the `getMaxUploadSize` method, you can achieve the maximum upload size. ``` core()->getMaxUploadSize() ``` These core helper methods provide various functionalities to simplify common tasks and streamline development in Bagisto. [Events Listeners](https://devdocs.bagisto.com/2.x/advanced/events.html)[Override Core Models](https://devdocs.bagisto.com/2.x/advanced/override-core-model.html) ## Blade File Tracer Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/themes/tracer.html#blade-file-tracer) Blade file tracer - [Introduction](https://devdocs.bagisto.com/1.x/themes/tracer.html#introduction) - [Configuration](https://devdocs.bagisto.com/1.x/themes/tracer.html#configuration) ## [#](https://devdocs.bagisto.com/1.x/themes/tracer.html#introduction) Introduction When you want to change or create a theme it can become difficult to find out which part contains the code that you need to work on. This is why we added the blade file tracer as it will help developers, contributors & partners who deal with Bagisto to find the blade file of the templates/views and understand the structure of the project. ## [#](https://devdocs.bagisto.com/1.x/themes/tracer.html#configuration) Configuration Let’s start to make this easier with just a simple config change. Go to your Bagisto root directory and open the file **config/view.php**, inside this file change the `tracer` value to `true`. ``` /* |-------------------------------------------------------------------------- | Blade File Tracer |-------------------------------------------------------------------------- | | Shows blade file path in front | */ 'tracer' => true, ``` Now return to your Bagisto root directory and run the following commands ``` php artisan view:clear php artisan config:cache ``` Now you are ready to visit your Storefront & Admin, you will see the blade file hint path in each block of your template. [Themes](https://devdocs.bagisto.com/1.x/themes)[Create a store theme](https://devdocs.bagisto.com/1.x/themes/create-store-theme.html) ## Bagisto Sail Documentation This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#sail) Sail - [Introduction](https://devdocs.bagisto.com/2.3/introduction/sail.html#introduction) - [Installing Dependencies](https://devdocs.bagisto.com/2.3/introduction/sail.html#installing-dependencies) - [Available Services](https://devdocs.bagisto.com/2.3/introduction/sail.html#available-services) - [Environment Configuration](https://devdocs.bagisto.com/2.3/introduction/sail.html#environment-configuration) - [MySQL Configuration](https://devdocs.bagisto.com/2.3/introduction/sail.html#mysql-configuration) - [Redis Configuration](https://devdocs.bagisto.com/2.3/introduction/sail.html#redis-configuration) - [MailPit Configuration](https://devdocs.bagisto.com/2.3/introduction/sail.html#mailpit-configuration) - [Elasticsearch Configuration](https://devdocs.bagisto.com/2.3/introduction/sail.html#elasticsearch-configuration) - [Building and Running Containers](https://devdocs.bagisto.com/2.3/introduction/sail.html#building-and-running-containers) - [Installing Bagisto](https://devdocs.bagisto.com/2.3/introduction/sail.html#installing-bagisto) ## [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#introduction) Introduction [Laravel Sail(opens new window)](https://laravel.com/docs/11.x/sail) is a lightweight CLI tool that simplifies the setup and management of Laravel's Docker development environment. It provides pre-configured Docker containers for services like PHP, MySQL, Redis, and Mailhog, allowing developers to quickly create a local environment for Laravel applications without manual configuration. Sail supports multiple PHP versions and is ideal for consistent and isolated local development, making it easier to run and manage Laravel-based projects, including Bagisto. ## [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#installing-dependencies) Installing Dependencies To install Composer dependencies on a fresh clone of your project, the default PHP version is 8.3. However, you may switch to a Bagisto-supported PHP version by using one of the following: - `laravelsail/php81-composer:latest` - `laravelsail/php82-composer:latest` - `laravelsail/php83-composer:latest` When changing the PHP version, remember to update the Dockerfile context in the `docker-compose` file accordingly. For more details, refer to the [Laravel Sail documentation on PHP versions(opens new window)](https://laravel.com/docs/11.x/sail#sail-php-versions). ``` docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ laravelsail/php83-composer:latest \ composer require laravel/sail --dev --ignore-platform-reqs ``` If you are working on an existing project with a dependency manager installed, you can easily set up Laravel Sail by running the following command: ``` composer require laravel/sail --dev ``` ## [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#available-services) Available Services The docker-compose file includes the following services for Bagisto: - Laravel - MySQL - Redis - Elasticsearch - Kibana - MailPit For detailed information about these services, please refer to the [Laravel Sail Documentation(opens new window)](https://laravel.com/docs/11.x/sail#introduction). ## [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#environment-configuration) Environment Configuration Before starting Bagisto, you'll need to configure the following services in your `.env` file: ### [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#mysql-configuration) MySQL Configuration These credentials will be used to create the database when the container starts for the first time: ``` DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=bagisto DB_USERNAME=sail DB_PASSWORD=password DB_PREFIX= ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#redis-configuration) Redis Configuration ``` REDIS_HOST=redis REDIS_PASSWORD=null REDIS_PORT=6379 ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#mailpit-configuration) MailPit Configuration ``` MAIL_MAILER=smtp MAIL_HOST=mailpit MAIL_PORT=1025 MAIL_USERNAME= MAIL_PASSWORD= MAIL_ENCRYPTION=tls ``` ### [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#elasticsearch-configuration) Elasticsearch Configuration ``` ELASTICSEARCH_HOST=http://elasticsearch:9200 ``` ## [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#building-and-running-containers) Building and Running Containers 1. Build the container (use `--no-cache` for a fresh build): ``` vendor/bin/sail build --no-cache ``` 2. Start the containers in detached mode: ``` vendor/bin/sail up -d ``` ## [#](https://devdocs.bagisto.com/2.3/introduction/sail.html#installing-bagisto) Installing Bagisto If this is your first time running the container, you'll need to install Bagisto: ``` vendor/bin/sail artisan bagisto:install ``` During the installation process, you'll be prompted for various credentials. The system will suggest default values based on your `.env` file configurations. For consistency, it's recommended to use the same credentials you specified in your `.env` file, even though this may seem redundant. Because some environment variables are used to create services (like MySQL), and we are now reconnecting with the following credentials. [Docker](https://devdocs.bagisto.com/2.3/introduction/docker.html)[Architecture concepts](https://devdocs.bagisto.com/2.3/architecture) ## Bagisto Load Balancing Guide This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#load-balancing) Load Balancing - [Introduction](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#introduction) - [Bagisto with ALB Setup on AWS](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#bagisto-with-alb-setup-on-aws) - [Dedicated Database Server Setup](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#dedicated-database-server-setup) - [S3 Bucket Configuration for Bagisto](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#s3-bucket-configuration-for-bagisto) - [Bagisto Server Setup](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#bagisto-server-setup) - [Create AMI for Bagisto Application](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#create-ami-for-bagisto-application) - [Configure Target Group](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#configure-target-group) - [Create and Configure Application Load Balancer (ALB)](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#create-and-configure-application-load-balancer-alb) - [Verify and Test the Entire Setup](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#verify-and-test-the-entire-setup) ## [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#introduction) Introduction This guide provides a step-by-step approach to deploying Bagisto on AWS with an Application Load Balancer (ALB) for improved scalability and high availability. By setting up a dedicated database server, integrating Amazon S3 for media storage, and configuring an AMI-based auto-scaling setup, you can ensure that Bagisto can handle increased traffic efficiently. The process includes: - Setting up a dedicated MySQL server for better performance. - Deploying Bagisto on multiple EC2 instances behind a Load Balancer. - Using Amazon S3 for storage instead of local file storage. - Creating an AMI to easily scale new instances. - Configuring an Application Load Balancer (ALB) for traffic distribution. - Setting up SSL and domain configuration for secure access. - This setup ensures a scalable, fault-tolerant, and high-performance Bagisto application. 🚀 ## [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#bagisto-with-alb-setup-on-aws) Bagisto with ALB Setup on AWS ### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#dedicated-database-server-setup) Dedicated Database Server Setup #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#launch-ec2-instance-for-mysql-database) Launch EC2 Instance for MySQL Database - Launch an EC2 instance for MySQL database. - Assign an Elastic IP to the EC2 instance. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#install-and-configure-mysql-server) install and Configure MySQL Server - SSH into the EC2 instance and run `apt-get update`. - Install MySQL server: ``` sudo apt-get install mysql-server ``` - Secure the MySQL installation and create the database: ``` sudo mysql -u root -p CREATE DATABASE bagistodb; CREATE USER 'bagistouser'@'localhost' IDENTIFIED BY ''; GRANT ALL ON bagistodb.* TO 'bagistouser'@'localhost' WITH GRANT OPTION; SET GLOBAL log_bin_trust_function_creators = 1; FLUSH PRIVILEGES; EXIT; ``` #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#update-mysql-bind-address) Update MySQL Bind Address - Modify the bind address from 127.0.0.1 to 0.0.0.0 in /etc/mysql/mysql.conf.d/mysqld.cnf. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#restart-mysql-server) Restart MySQL Server - Restart the MySQL service: ``` sudo systemctl restart mysql ``` #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#open-mysql-port-3306-in-security-group) Open MySQL Port (3306) in Security Group - Modify the security group for this EC2 instance to allow inbound traffic on port 3306. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#verify-database-connectivity) Verify Database Connectivity - Test connectivity using `telnet 3306` from your system ### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#s3-bucket-configuration-for-bagisto) S3 Bucket Configuration for Bagisto #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#create-s3-bucket) Create S3 Bucket - Follow the documentation [S3 Bucket and Policy Setup for Bagisto(opens new window)](https://bagisto.com/en/s3-bucket-and-policy-setup-for-bagisto-amazon-s3-extension) to create an S3 bucket. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#configure-iam-role-for-s3-access) Configure IAM Role for S3 Access - Create an IAM role with the required permissions to allow Bagisto to interact with S3. Use the Access Key ID, Secret Key, Bucket Name, Region, and Bucket URL. ### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#bagisto-server-setup) Bagisto Server Setup #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#launch-ec2-instance-for-bagisto-application) Launch EC2 Instance for Bagisto Application - Launch a new EC2 instance for the Bagisto application. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#install-mysql-client) Install MySQL Client - SSH into the EC2 instance and install the MySQL client: ``` sudo apt-get install mysql-client-8.0 ``` #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#install-bagisto) Install Bagisto - Follow the steps from the [Bagisto setup guide on AWS(opens new window)](https://cloudkul.com/blog/how-to-setup-bagisto-on-aws/) but skip step 7 (Install MySQL Server) as it is already done in the dedicated DB server. - Use the latest [composer commands(opens new window)](https://getcomposer.org/download/) #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#configure-bagisto-database-connection) Configure Bagisto Database Connection - Use the following database details: - Host: `` - User: `bagistouser` - Dbname: `bagistodb` - Password: `` #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#install-s3-integration-module) Install S3 Integration Module - Install and configure the S3 module for Bagisto using the IAM credentials. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#access-bagisto-admin-panel) Access Bagisto Admin Panel - Visit the admin panel at: `http:///admin` to complete configurations. ### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#create-ami-for-bagisto-application) Create AMI for Bagisto Application #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#create-ami-from-bagisto-ec2-instance) Create AMI from Bagisto EC2 Instance - Go to **Instances > Actions > Image and templates > Create Image**. ![Create Image](https://devdocs.bagisto.com/assets/img/create-image-ec2.8b5ede7a.png) - Enter the image name and click **Create Image**. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#wait-for-ami-to-be-available) Wait for AMI to Be Available - Monitor the status of the AMI in the AMI section. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#launch-instances-from-ami) Launch Instances from AMI - Once the AMI is available, go to AMIs and launch as many instances as required in the target group. ### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#configure-target-group) Configure Target Group #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#create-target-group) Create Target Group - Go to Target Groups and click Create Target Group. - Choose Instances as the target type and give it a name. ![Target Group](https://devdocs.bagisto.com/assets/img/target-group.98f7415d.png) #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#register-instances-in-the-target-group) Register Instances in the Target Group - Choose the instances to be added to the target group ![Create Target Group](https://devdocs.bagisto.com/assets/img/create-target-group.9b7b3385.png) #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#configure-load-balancing-algorithm) Configure Load Balancing Algorithm - After creating the target group, go to Attributes and choose the desired load-balancing algorithm (default: round-robin). Enable stickiness. ### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#create-and-configure-application-load-balancer-alb) Create and Configure Application Load Balancer (ALB) #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#create-alb) Create ALB - Go to **Load Balancers** and click **Create Load Balancer**. - Choose **Application Load Balancer** and provide the following configurations: - **Internet-facing**. - Select all **Availability Zones**. - Choose the target group created earlier and configure the listener on **port 80 (HTTP)**. ![Create Load Balancer](https://devdocs.bagisto.com/assets/img/create-loadbalancer.1f352060.png) ![Create Load Balancer](https://devdocs.bagisto.com/assets/img/loadbalancer-port.9e77b96d.png) ![Create Load Balancer](https://devdocs.bagisto.com/assets/img/loadbalancer-port-80.540ede6d.png) #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#adjust-security-groups) Adjust Security Groups - Modify the security groups to allow necessary traffic (e.g., HTTP/HTTPS). #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#verify-load-balancer-configuration) Verify Load Balancer Configuration - Copy the **DNS name** of the load balancer and verify it. - Configure the **domain name** (CNAME) to point to this load balancer DNS for production use. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#set-up-ssl-on-load-balancer) Set Up SSL on Load Balancer - Configure the ALB listener to use HTTPS (port 443), ensuring that an SSL certificate is installed. ![Load Balancer Result](https://devdocs.bagisto.com/assets/img/loadbalancer-result.9c0b7fbd.png) ### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#verify-and-test-the-entire-setup) Verify and Test the Entire Setup #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#test-load-balancer) Test Load Balancer - Confirm that the load balancer is distributing traffic across the registered instances. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#verify-domain-configuration) Verify Domain Configuration - Ensure the domain is resolving correctly to the load balancer. #### [#](https://devdocs.bagisto.com/2.3/performance/loadbalancing.html#test-bagisto-functionality) Test Bagisto Functionality - Access the Bagisto application and verify that the S3 integration is working, the application can connect to the MySQL database, and all features are functional. **Bagisto with ALB Setup on AWS is Successfully Configured!** The Bagisto application is now running behind an Application Load Balancer (ALB) with a dedicated MySQL database and S3 integration for storage. The load balancer is efficiently distributing traffic across multiple instances, ensuring high availability and scalability. [Laravel Octane](https://devdocs.bagisto.com/2.3/performance/octane.html)[Bagisto APIs](https://devdocs.bagisto.com/2.3/api) ## Bagisto v2.3 Requirements This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/introduction/requirements.html#requirements) Requirements - [Server Configuration](https://devdocs.bagisto.com/2.3/introduction/requirements.html#server-configuration) - [PHP Extensions](https://devdocs.bagisto.com/2.3/introduction/requirements.html#php-extensions) - [PHP Configuration](https://devdocs.bagisto.com/2.3/introduction/requirements.html#php-configuration) - [Apache Configuration](https://devdocs.bagisto.com/2.3/introduction/requirements.html#apache-configuration) - [Nginx Configuration](https://devdocs.bagisto.com/2.3/introduction/requirements.html#nginx-configuration) - [Supported Database Servers](https://devdocs.bagisto.com/2.3/introduction/requirements.html#supported-database-servers) ## [#](https://devdocs.bagisto.com/2.3/introduction/requirements.html#server-configuration) Server Configuration - **Server**: Apache 2 or NGINX - **RAM**: 4GB or higher - **Node**: 23.10.0 LTS or higher - **PHP**: 8.2 or higher - **Composer**: 2.5 or higher ## [#](https://devdocs.bagisto.com/2.3/introduction/requirements.html#php-extensions) PHP Extensions Ensure the following extensions are installed and enabled. You can check using the **`phpinfo()`** page or the **`php -m`** command. - **php-intl extension**: This extension is required for internationalization support in Bagisto. - **php-gd extension**: The **`php-gd`** extension must be properly installed to ensure correct image functionality in the project. If not installed correctly, image-related features may not work as expected. Note It is important to ensure proper installation of the **`php-gd`** extension to avoid any issues with image manipulation in Bagisto. ## [#](https://devdocs.bagisto.com/2.3/introduction/requirements.html#php-configuration) PHP Configuration Open your **`php.ini`** file and modify the following settings. - **memory_limit**: Set the **`memory_limit`** directive to **`4G`** or higher to ensure sufficient memory allocation for the application. - **max_execution_time**: Adjust the **`max_execution_time`** directive to **`360`** or higher. This value determines the maximum time (in seconds) a script is allowed to run. Increasing this value ensures that longer operations, such as import/export processes, can be completed successfully. - **date.timezone**: Set the **`date.timezone`** directive to your specific timezone. For example, **`Asia/Kolkata`**. This ensures that date and time-related functions work accurately based on the specified timezone. ``` memory_limit = 4G max_execution_time = 360 date.timezone = Asia/Kolkata <- Change this to your own timezone. ``` Remember to restart your web server Whenever you make changes to the PHP configuration file, be sure to restart Apache or NGINX to apply the modifications. ## [#](https://devdocs.bagisto.com/2.3/introduction/requirements.html#apache-configuration) Apache Configuration To serve Bagisto using Apache, make sure your virtual host is properly configured. Below is a basic `VirtualHost` example suitable for local development: ``` ServerAdmin webmaster@localhost DocumentRoot /var/www/html/bagisto/public Options Indexes FollowSymLinks AllowOverride All Require all granted ``` Note Ensure `DocumentRoot` points to the `public` directory of your Bagisto installation. `AllowOverride All` is essential for Laravel’s `.htaccess` to function correctly. ## [#](https://devdocs.bagisto.com/2.3/introduction/requirements.html#nginx-configuration) Nginx Configuration If you are deploying your Bagisto application to a server that is running Nginx, you may use the following configuration file as a starting point for configuring your web server. Most likely, this file will need to be customized depending on your server's configuration. Please ensure, like the configuration below, your web server directs all requests to your application's `public/index.php` file. You should never attempt to move the `index.php` file to your project's root, as serving the application from the project root will expose many sensitive configuration files to the public Internet: ``` server { listen 80; listen [::]:80; server_name example.com; root /srv/example.com/public; add_header X-Frame-Options "SAMEORIGIN"; add_header X-Content-Type-Options "nosniff"; index index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location ~* ^\/(?!cache).*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|webp|woff|woff2)$ { expires max; access_log off; add_header Cache-Control "public"; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ ^/index\.php(/|$) { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; fastcgi_hide_header X-Powered-By; } location ~ /\.(?!well-known).* { deny all; } } ``` ## [#](https://devdocs.bagisto.com/2.3/introduction/requirements.html#supported-database-servers) Supported Database Servers Bagisto supports the following database servers: - **MySQL**: Version 8.0.32 or higher is recommended for optimal performance and compatibility. - **Database Collation**: The recommended collation for the database is **`utf8mb4_unicode_ci`**, which ensures proper handling of Unicode characters and multilingual support. [Introduction](https://devdocs.bagisto.com/2.3/introduction)[Installation](https://devdocs.bagisto.com/2.3/introduction/installation.html) ## DataGrid Implementation Guide Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/1.x/advanced/datagrid.html#datagrid) DataGrid DataGrid is just a concept of displaying your database records in tabular format. We have implemented this in Bagisto either you can use it to display data in tabular format or write code from scratch to display data in tabular format. In addition to DataGrid, we have implemented additional features such as sorting, filtering, mass action. You may refer to the table below for detailed information about the features. Let us take a sample of one DataGrid, ``` select('id') ->addSelect('id', 'code', 'admin_name', 'type', 'is_required', 'is_unique', 'value_per_locale', 'value_per_channel'); $this->setQueryBuilder($queryBuilder); } /** * Add columns. */ public function addColumns() { $this->addColumn([\ 'index' => 'id',\ 'label' => trans('admin::app.datagrid.id'),\ 'type' => 'number',\ 'searchable' => false,\ 'sortable' => true,\ 'filterable' => true\ ]); $this->addColumn([\ 'index' => 'code',\ 'label' => trans('admin::app.datagrid.code'),\ 'type' => 'string',\ 'searchable' => true,\ 'sortable' => true,\ 'filterable' => true\ ]); $this->addColumn([\ 'index' => 'admin_name',\ 'label' => trans('admin::app.datagrid.admin-name'),\ 'type' => 'string',\ 'searchable' => true,\ 'sortable' => true,\ 'filterable' => true\ ]); $this->addColumn([\ 'index' => 'type',\ 'label' => trans('admin::app.datagrid.type'),\ 'type' => 'string',\ 'sortable' => true,\ 'searchable' => true,\ 'filterable' => true\ ]); $this->addColumn([\ 'index' => 'is_required',\ 'label' => trans('admin::app.datagrid.required'),\ 'type' => 'boolean',\ 'sortable' => true,\ 'searchable' => false,\ 'wrapper' => function ($value) {\ if ($value->is_required == 1)\ return 'True';\ else\ return 'False';\ }\ ]); $this->addColumn([\ 'index' => 'is_unique',\ 'label' => trans('admin::app.datagrid.unique'),\ 'type' => 'boolean',\ 'sortable' => true,\ 'searchable' => false,\ 'filterable' => true,\ 'wrapper' => function ($value) {\ if ($value->is_unique == 1)\ return 'True';\ else\ return 'False';\ }\ ]); $this->addColumn([\ 'index' => 'value_per_locale',\ 'label' => trans('admin::app.datagrid.per-locale'),\ 'type' => 'boolean',\ 'sortable' => true,\ 'searchable' => false,\ 'filterable' => true,\ 'wrapper' => function ($value) {\ if ($value->value_per_locale == 1)\ return 'True';\ else\ return 'False';\ }\ ]); $this->addColumn([\ 'index' => 'value_per_channel',\ 'label' => trans('admin::app.datagrid.per-channel'),\ 'type' => 'boolean',\ 'sortable' => true,\ 'searchable' => false,\ 'filterable' => true,\ 'wrapper' => function ($value) {\ if ($value->value_per_channel == 1)\ return 'True';\ else\ return 'False';\ }\ ]); } /** * Prepare actions. */ public function prepareActions() { $this->addAction([\ 'title' => trans('admin::app.datagrid.edit'),\ 'method' => 'GET',\ 'route' => 'admin.catalog.attributes.edit',\ 'icon' => 'icon pencil-lg-icon'\ ]); $this->addAction([\ 'title' => trans('admin::app.datagrid.delete'),\ 'method' => 'POST',\ 'route' => 'admin.catalog.attributes.delete',\ 'icon' => 'icon trash-icon'\ ]); } /** * Prepare mass actions. */ public function prepareMassActions() { $this->addMassAction([\ 'type' => 'delete',\ 'action' => route('admin.catalog.attributes.massdelete'),\ 'label' => 'Delete',\ 'method' => 'DELETE'\ ]); } } ``` ## [#](https://devdocs.bagisto.com/1.x/advanced/datagrid.html#global-properties-of-datagrid) Global properties of DataGrid As you see the above sample Datagrid, now let us discuss some properties, | Name | Functionality | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | index | This property is defined in the grid, and the value assigned to this property must be unique i.e. `id`, so that data will be uniquely identified and operations performed will be based on your index value. | | sortOrder | The `sortOrder` key is used to arrange the results in ascending or descending order, we have to set the sort order variable to `asc` or `desc`. | | queryBuilder | It is used to perform database operations in your application. | | enableMassAction | This accepts boolean values `true` or `false` to enable or disable the mass action in Datagrid. | | enableAction | This accepts boolean values `true` or `false` to enable or disable the action column of Datagrid. | | paginate | While creating your grid file you have to declare paginate property and set it to `true` to allow pagination on your page. | | itemsPerPage | The `itemsPerPage` key is used to display the number of items per page. | | enableFilterMap | This accepts boolean values `true` or `false` to enable or disable the filter on the basis of columns. | ## [#](https://devdocs.bagisto.com/1.x/advanced/datagrid.html#steps-to-create-datagrid) Steps to create DataGrid You can create a DataGrid in two ways. 1. By using Bagisto Package Generator ( **Recommended**) 2. By manually setting up all files ( **Expert Level**) ### [#](https://devdocs.bagisto.com/1.x/advanced/datagrid.html#_1-by-using-bagisto-package-generator) 1\. By using Bagisto Package Generator This command will create a new data grid class in `packages/ACME/TestPackage/src/Datagrids` directory., ``` php artisan package:make-datagrid TestDataGrid ACME/TestPackage ``` If data grid class already present then you can use force command for overwriting. ``` php artisan package:make-datagrid TestDataGrid ACME/TestPackage --force ``` This will generate whole directory structures. You don't need to do manually. ### [#](https://devdocs.bagisto.com/1.x/advanced/datagrid.html#_2-by-manually-setting-up-all-files) 2\. By manually setting up all files 1. We assume that you have created package let's say `ACME\TestPackage` with the below directory structure. ``` - ACME/TestPackage/ - publishable/assets - css/ - images/ - js/ - src/ - Config/ - acl.php - admin-menu.php - Console/ - Commands/ - Contracts/ - Database/ - Migrations/ - Seeders/ - Events/ - Http/ - Controllers/ - Admin/ - TestPackageController.php - Shop/ - TestPackageController.php - Middleware/ - Requests/ - admin-routes.php - shop-routes.php - Listeners/ - Mail/ - Models/ - Providers/ - TestPackageServiceProvider.php - TestPackageProvider.php - Repositories/ - Resources/ - assets/ - images/ - js/ - app.js - sass/ - admin.scss - default.scss - velocity.scss - lang/ - views/ - admin/ - layouts/ - style.blade.php - index.blade.php - shop/ - default/ - index.blade.php - velocity/ - index.blade.php - package.json - webpack.mix.js ``` 2. Create a folder **Datagrids** in your package inside `src` folder, inside **Datagrids** folder, create a class let's say `TestDataGrid.php` that extends DataGrid class from Webkul `Ui` package. 3. We have created `DataGrid` abstract class in Webkul `Ui` package. In the DataGrid abstract class, a list of properties and methods are declared. So, while creating your own DataGrid you need to only extends the `Webkul\Ui\DataGrid\DataGrid` abstract class inside your `TestDataGrid.php` class. 4. In `Webkul\Ui\DataGrid\DataGrid.php` abstract class, two abstract methods are declared `prepareQueryBuilder()` and `addColumns()`. We can prepare grid by defining these two methods - `prepareQueryBuilder()`: In this method, records are retrieved through queries that is applicable on database and stored in a collection. When records are retrieved, `$this->setQueryBuilder($queryBuilder)` setQueryBuilder method is called. - `setQueryBuilder()`: This method is written in DataGrid abstract class of Webkul `Ui` package. This is used for setting the `$queryBuilder`. ``` public function prepareQueryBuilder() { $queryBuilder = DB::table('attributes') ->select('id') ->addSelect('id', 'code', 'admin_name', 'type', 'is_required', 'is_unique', 'value_per_locale', 'value_per_channel'); $this->setQueryBuilder($queryBuilder); } ``` - `addColumns()`: In this method, the columns are created which are displayed in the grid. In this method, the parameter accepts the array in key-value pairs. Some of the essential keys are described below, | Name | functionality | | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | index | This key is defined in the grid, and the value assigned to this key must be unique, so that data will be uniquely identified and operations performed will be based on your index value. | | label | In this key, the name of the column is defined. | | type | This key accepts the type of data in column. | | searchable | This accepts boolean values `true` or `false` to make the column searchable. | | sortable | This accepts boolean values `true` or `false` to make the column sortable. | | filterable | This accepts boolean values `true` or `false` to make the column filterable. | | wrapper | Perform actions based on condition satisfied or some customization to value. | ``` public function addColumns() { $this->addColumn([\ 'index' => 'id',\ 'label' => trans('admin::app.datagrid.id'),\ 'type' => 'number',\ 'searchable' => false,\ 'sortable' => true,\ 'filterable' => true\ ]); $this->addColumn([\ 'index' => 'code',\ 'label' => trans('admin::app.datagrid.code'),\ 'type' => 'string',\ 'searchable' => true,\ 'sortable' => true,\ 'filterable' => true\ ]); } ``` - `prepareActions()`: Additionally, this method is defined when there is a need to perform any action such as edit or delete on the grid. In this method, `addAction()` is called to define particular action. - `addAction()`: It is used for adding actions (like `edit`, `delete`, etc) to each row generated by Datagrid. | Name | Functionality | | ------ | ------------------------------------------------------------------------ | | title | The text to be displayed in written here. | | method | HTTP methods are declared. | | route | This key accepts the route of icon. | | icon | Class of icon to be displayed in action column you may prefer text also. | ``` public function prepareActions() { $this->addAction([\ 'title' => trans('admin::app.datagrid.edit'),\ 'method' => 'GET',\ 'route' => 'admin.catalog.attributes.edit',\ 'icon' => 'icon pencil-lg-icon'\ ]); $this->addAction([\ 'title' => trans('admin::app.datagrid.delete'),\ 'method' => 'POST',\ 'route' => 'admin.catalog.attributes.delete',\ 'icon' => 'icon trash-icon'\ ]); } ``` WARNING - Use JavaScript with wrapper property set to true when needed. - Return static blade files loaded with scripts in it with caution. ## [#](https://devdocs.bagisto.com/1.x/advanced/datagrid.html#multiple-datagrids) Multiple DataGrids As the default Datagrid will handle only a single request at a time which means filtration, sorting and many other operations will get conflicted when you try to implement the multiple DataGrids. To overcome this we have provided a trait `ProvideDataGridPlus` in the namespace `Webkul\Ui\DataGrid\Traits`. - Just take any of the Datagrid, let say `ProductDataGrid` in the namespace `Webkul\Admin\DataGrids`, ``` namespace Webkul\Admin\DataGrids; class ProductDataGrid extends DataGrid { ... } ``` - Import the `ProvideDataGridPlus` trait in the mentioned class, ``` namespace Webkul\Admin\DataGrids; use Webkul\Ui\DataGrid\Traits\ProvideDataGridPlus; class ProductDataGrid extends DataGrid { use ProvideDataGridPlus; ... } ``` - After that `toJson()` method will be available in the Datagrid instance which will provide data to the component. - Now you need to create one route and method from where the response will come. Let us take an example of the product listing page. Now go to `ProductController` in the namespace `Webkul\Product\Http\Controllers`, there is an index method, just use the `toJson`. ``` use Webkul\Admin\DataGrids\ProductDataGrid; class ProductController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\View\View */ public function index() { if (request()->ajax()) { return app(ProductDataGrid::class)->toJson(); } return view($this->_config['view']); } ... } ``` - Now, in the view portion use this component i.e. `datagrid-plus` and add the url from where it will load the json data, ```
... ...
``` - Done, your datagrid is ready. [Create your own product type](https://devdocs.bagisto.com/1.x/advanced/create-product-type.html)[Events](https://devdocs.bagisto.com/1.x/advanced/events.html) ## Bagisto Event Handling Heads up: You are viewing outdated documentation for Bagisto. Please consider upgrading to [v2.3](https://devdocs.bagisto.com/2.3/prologue) for the latest information. # [#](https://devdocs.bagisto.com/2.x/advanced/events.html#events) Events - [Introduction](https://devdocs.bagisto.com/2.x/advanced/events.html#introduction) - [Creating an Event Class](https://devdocs.bagisto.com/2.x/advanced/events.html#creating-an-event-class) - [Using Package Generator](https://devdocs.bagisto.com/2.x/advanced/events.html#using-package-generator) - [Manually Registering Events](https://devdocs.bagisto.com/2.x/advanced/events.html#manually-registering-events) - [Manually Registering Listeners](https://devdocs.bagisto.com/2.x/advanced/events.html#manually-registering-listeners) - [Specifying Events](https://devdocs.bagisto.com/2.x/advanced/events.html#specifying-events) - [Events Fired in Bagisto](https://devdocs.bagisto.com/2.x/advanced/events.html#events-fired-in-bagisto) - [Events Listen in Bagisto](https://devdocs.bagisto.com/2.x/advanced/events.html#events-listen-in-bagisto) - [Listening to Existing Events](https://devdocs.bagisto.com/2.x/advanced/events.html#listening-to-existing-events) - [Registering a Listener](https://devdocs.bagisto.com/2.x/advanced/events.html#registering-a-listener) ## [#](https://devdocs.bagisto.com/2.x/advanced/events.html#introduction) Introduction Event Listeners in Bagisto are a way to implement the observer pattern, where listeners respond to events that occur in the application. Events can be thought of as announcements made by the application, and listeners are the actions taken in response to those announcements. All event classes in Bagisto are stored in the `Providers` folder, and the listeners are stored in the `Listeners` folder. In Bagisto, events and listeners are organized in a clear and structured manner: - Events are typically stored in the Events folder. - Listeners are stored in the Listeners folder. This organization makes it easy to manage and locate the event-driven components of your application. To learn in detail about Controllers, you can visit the Laravel documentation [here(opens new window)](https://laravel.com/docs/11.x/events). ## [#](https://devdocs.bagisto.com/2.x/advanced/events.html#creating-an-event-class) Creating an Event Class ### [#](https://devdocs.bagisto.com/2.x/advanced/events.html#using-package-generator) Using Package Generator If you have the Bagisto Package Generator installed, you can use the following command to create a new event class in the `packages/Webkul/Blog/src/Events` directory: ``` php artisan package:make-event BlogEvent Webkul/Blog ``` If the event class already exists, you can use the --force option to overwrite it: ``` php artisan package:make-event BlogEvent Webkul/Blog --force ``` Alternatively, if you don't have the package generator, you can create the file manually by creating a new class in the `packages/Webkul/Blog/src/Events` directory. ### [#](https://devdocs.bagisto.com/2.x/advanced/events.html#manually-registering-events) Manually Registering Events In Bagisto, you register events manually in the `boot` method of your `EventServiceProvider.php` file. Here is an example of how to register events: ``` /** * Register any other events for your application. * * @return void */ public function boot() { //... Event::listen('event.name', 'path-upto-listener@function'); } ``` In this example, `event.name` is the name of the event, and `path-upto-listener@function` is the listener method that will handle the event. ### [#](https://devdocs.bagisto.com/2.x/advanced/events.html#manually-registering-listeners) Manually Registering Listeners When registering events, you specify the listener function to be executed when an event is triggered. Here is an example of how to register a listener: ``` class EventServiceProvider extends ServiceProvider { /** * Bootstrap services. * * @return void */ public function boot() { //... Event::listen('checkout.order.save.after', 'Webkul\Admin\Listeners\Order@sendNewOrderMail'); } } ``` In this example, the `checkout.order.save.after` event will trigger the `sendNewOrderMail` method of the `Order` listener in the `Webkul\Admin\Listeners` namespace. ## [#](https://devdocs.bagisto.com/2.x/advanced/events.html#specifying-events) Specifying Events In Bagisto, events are typically fired before and after the execution of CRUD operations. This allows listeners to perform additional actions, such as logging, notifications, or data manipulation, at specific points in the lifecycle of an operation. For example, you might have events fired during product creation, updating, or deletion. Here’s an example of firing events before and after saving an order: ``` namespace Webkul\Sales\Repositories; use Webkul\Sales\Contracts\Order; class OrderRepository extends Repository { public function create(array $data) { Event::dispatch('sales.order.create.before', $data); $order = parent::create($data); Event::dispatch('sales.order.create.after', $order); return $order; } } ``` ## [#](https://devdocs.bagisto.com/2.x/advanced/events.html#events-fired-in-bagisto) Events Fired in Bagisto In Bagisto, there are several events fired throughout its operations, allowing developers to hook into specific points in the application's lifecycle to customize behavior or add functionality. Here's a list of events that are fired in Bagisto, which you can listen to and handle as needed by creating event listeners: | Events name | Functionality | | ---------------------------------------- | ----------------------------------------------------------------- | | catalog.attribute.create.before | This event will be fired before attribute gets created. | | catalog.attribute.create.after | This event will be fired after attribute gets created. | | catalog.attribute.update.before | This event will be fired before attribute gets updated. | | catalog.attribute.update.after | This event will be fired after attribute gets updated. | | catalog.attribute.delete.before | This event will be fired before attribute gets deleted. | | catalog.attribute.delete.after | This event will be fired after attribute gets deleted. | | catalog.attribute_family.create.before | This event will be fired before attribute family gets created. | | catalog.attribute_family.create.after | This event will be fired after attribute family gets created. | | catalog.attribute_family.update.before | This event will be fired before updating attribute family. | | catalog.attribute_family.update.after | This event will be fired after updating attribute family. | | catalog.attribute_family.delete.before | This event will be fired before deleting attribute family. | | catalog.attribute_family.delete.after | This event will be fired after deleting attribute family. | | catalog.category.create.before | This event will be fired before creating category. | | catalog.category.create.after | This event will be fired after creating category. | | catalog.category.update.before | This event will be fired before updating category. | | catalog.category.update.after | This event will be fired after updating category. | | catalog.category.delete.before | This event will be fired before deleting category. | | catalog.category.delete.after | This event will be fired after deleting category. | | catalog.categories.mass-update.before | This event will be fired before bulk category update. | | catalog.categories.mass-update.after | This event will be fired after bulk category update. | | catalog.product.create.before | This event will be fired before product gets created. | | catalog.product.create.after | This event will be fired after product gets created. | | catalog.product.update.before | This event will be fired before product gets updated. | | catalog.product.update.after | This event will be fired after product gets updated. | | catalog.product.delete.before | This event will be fired before product gets deleted. | | catalog.product.delete.after | This event will be fired after product gets deleted. | | products.datagrid.sync | This event will be fired to synicing datagrid product. | | cms.pages.create.before | This event will be fired before cms page gets created. | | cms.pages.create.after | This event will be fired after cms page gets created. | | cms.pages.update.before | This event will be fired before cms page gets updated. | | cms.pages.update.after | This event will be fired after cms page gets updated. | | cms.pages.delete.before | This event will be fired before cms page gets deleted. | | cms.pages.delete.after | This event will be fired after cms page gets deleted. | | customer.addresses.create.before | This event will be fired before customer address gets created. | | customer.addresses.create.after | This event will be fired after customer address gets created. | | customer.addresses.update.before | This event will be fired before customer address gets updated. | | customer.addresses.update.after | This event will be fired after customer address gets updated. | | customer.addresses.delete.before | This event will be fired before customer address gets deleted. | | customer.addresses.delete.after | This event will be fired after customer address gets deleted. | | customer.registration.before | This event will be fired before customer gets created. | | customer.registration.after | This event will be fired after customer gets created. | | customer.login.after | This event will be fired after customer gets login. | | customer.logout.after | This event will be fired after customer gets logout. | | customer.update.before | This event will be fired before customer gets updated. | | customer.update.after | This event will be fired after customer gets updated. | | customer.password.update.after | This event will be fired after customer password gets updated. | | customer.note-created.after | This event will be fired after customer note gets created. | | customer.subscription.before | This event will be fired before customer gets subscription. | | customer.subscription.after | This event will be fired after customer gets subscription. | | customer.delete.before | This event will be fired before customer gets deleted. | | customer.delete.after | This event will be fired after customer gets deleted. | | customer.customer_group.create.before | This event will be fired before customer group gets created. | | customer.customer_group.create.after | This event will be fired after customer group gets created. | | customer.customer_group.update.before | This event will be fired before customer group gets updated. | | customer.customer_group.update.after | This event will be fired after customer group gets updated. | | customer.customer_group.delete.before | This event will be fired before customer group gets deleted. | | customer.customer_group.delete.after | This event will be fired after customer group gets deleted. | | customer.review.update.before | This event will be fired before customer review gets updated. | | customer.review.update.after | This event will be fired after customer review gets updated. | | customer.review.delete.before | This event will be fired before customer review gets deleted. | | customer.review.delete.after | This event will be fired after customer review gets deleted. | | marketing.sitemaps.create.before | This event will be fired before sitemaps gets created. | | marketing.sitemaps.create.after | This event will be fired after sitemaps gets created. | | marketing.sitemaps.update.before | This event will be fired before sitemaps gets updated. | | marketing.sitemaps.update.after | This event will be fired after sitemaps gets updated. | | marketing.sitemaps.delete.before | This event will be fired before sitemaps gets deleted. | | marketing.sitemaps.delete.after | This event will be fired after sitemaps gets deleted. | | marketing.campaigns.create.before | This event will be fired before campaigns gets created. | | marketing.campaigns.create.after | This event will be fired after campaigns gets created. | | marketing.campaigns.update.before | This event will be fired before campaigns gets updated. | | marketing.campaigns.update.after | This event will be fired after campaigns gets updated. | | marketing.campaigns.delete.before | This event will be fired before campaigns gets deleted. | | marketing.campaigns.delete.after | This event will be fired after campaigns gets deleted. | | marketing.events.create.before | This event will be fired before marketing event gets created. | | marketing.events.create.after | This event will be fired after marketing event gets created. | | marketing.events.update.before | This event will be fired before marketing event gets updated. | | marketing.events.update.after | This event will be fired after marketing event gets updated. | | marketing.events.delete.before | This event will be fired before marketing event gets deleted. | | marketing.events.delete.after | This event will be fired after marketing event gets deleted. | | marketing.templates.create.before | This event will be fired before templates gets created. | | marketing.templates.create.after | This event will be fired after templates gets created. | | marketing.templates.update.before | This event will be fired before templates gets updated. | | marketing.templates.update.after | This event will be fired after templates gets updated. | | marketing.templates.delete.before | This event will be fired before templates gets deleted. | | marketing.templates.delete.after | This event will be fired after templates gets deleted. | | promotions.cart_rule.create.before | This event will be fired before cart rule gets created. | | promotions.cart_rule.create.after | This event will be fired after cart rule gets created. | | promotions.cart_rule.update.before | This event will be fired before cart rule gets updated. | | promotions.cart_rule.update.after | This event will be fired after cart rule gets updated. | | promotions.cart_rule.delete.before | This event will be fired before cart rule gets deleted. | | promotions.cart_rule.delete.after | This event will be fired after cart rule gets deleted. | | promotions.catalog_rule.create.before | This event will be fired before catalog rule gets created. | | promotions.catalog_rule.create.after | This event will be fired after catalog rule gets created. | | promotions.catalog_rule.update.before | This event will be fired before catalog rule gets updated. | | promotions.catalog_rule.update.after | This event will be fired after catalog rule gets updated. | | promotions.catalog_rule.delete.before | This event will be fired before catalog rule gets deleted. | | promotions.catalog_rule.delete.after | This event will be fired after catalog rule gets deleted. | | sales.order.comment.create.before | This event will be fired before order comment gets created. | | sales.order.comment.create.after | This event will be fired after order comment gets created. | | core.channel.create.before | This event will be fired before channel gets created. | | core.channel.create.after | This event will be fired after channel gets created. | | core.channel.update.before | This event will be fired before channel gets updated. | | core.channel.update.after | This event will be fired after channel gets updated. | | core.channel.delete.before | This event will be fired before channel gets deleted. | | core.channel.delete.after | This event will be fired after channel gets deleted. | | core.exchange_rate.create.before | This event will be fired before exchange rate gets created. | | core.exchange_rate.create.after | This event will be fired after exchange rate gets created. | | core.exchange_rate.update.before | This event will be fired before exchange rate gets updated. | | core.exchange_rate.update.after | This event will be fired after exchange rate gets updated. | | core.exchange_rate.delete.before | This event will be fired before exchange rate gets deleted. | | core.exchange_rate.delete.after | This event will be fired after exchange rate gets deleted. | | inventory.inventory_source.create.before | This event will be fired before inventory source gets created. | | inventory.inventory_source.create.after | This event will be fired after inventory source gets created. | | inventory.inventory_source.update.before | This event will be fired before inventory source gets updated. | | inventory.inventory_source.update.after | This event will be fired after inventory source gets updated. | | inventory.inventory_source.delete.before | This event will be fired before inventory source gets deleted. | | inventory.inventory_source.delete.after | This event will be fired after inventory source gets deleted. | | user.role.create.before | This event will be fired before role gets created. | | user.role.create.after | This event will be fired after role gets created. | | user.role.update.before | This event will be fired before role gets updated. | | user.role.update.after | This event will be fired after role gets updated. | | user.role.delete.before | This event will be fired before role gets deleted. | | user.role.delete.after | This event will be fired after role gets deleted. | | theme_customization.create.before | This event will be fired before theme customization gets created. | | theme_customization.create.after | This event will be fired after theme customization gets created. | | theme_customization.update.before | This event will be fired before theme customization gets updated. | | theme_customization.update.after | This event will be fired after theme customization gets updated. | | theme_customization.delete.before | This event will be fired before theme customization gets deleted. | | theme_customization.delete.after | This event will be fired after theme customization gets deleted. | | user.admin.create.before | This event will be fired before admin gets created. | | user.admin.create.after | This event will be fired after admin gets created. | | user.admin.update.before | This event will be fired before admin gets updated. | | user.admin.update.after | This event will be fired after admin gets updated. | | admin.password.update.after | This event will be fired after admin password gets updated. | | user.admin.delete.before | This event will be fired before admin gets deleted. | | user.admin.delete.after | This event will be fired after admin gets deleted. | | tax.category.create.before | This event will be fired before tax category gets created. | | tax.category.create.after | This event will be fired after tax category gets created. | | tax.category.update.before | This event will be fired before tax category gets updated. | | tax.category.update.after | This event will be fired after tax category gets updated. | | tax.category.delete.before | This event will be fired before tax category gets deleted. | | tax.category.delete.after | This event will be fired after tax category gets deleted. | | tax.rate.create.before | This event will be fired before tax rate gets created. | | tax.rate.create.after | This event will be fired after tax rate gets created. | | tax.rate.update.before | This event will be fired before tax rate gets updated. | | tax.rate.update.after | This event will be fired after tax rate gets updated. | | tax.rate.delete.before | This event will be fired before tax rate gets deleted. | | tax.rate.delete.after | This event will be fired after tax rate gets deleted. | | checkout.cart.delete.before | This event will be fired before cart item gets deleted. | | checkout.cart.delete.after | This event will be fired after cart item gets deleted. | | checkout.cart.delete.all.before | This event will be fired before all cart items gets deleted. | | checkout.cart.delete.all.after | This event will be fired after all cart item gets deleted. | | checkout.cart.add.before | This event will be fired before cart item gets created. | | checkout.cart.add.after | This event will be fired after cart item gets created. | | checkout.cart.update.before | This event will be fired before cart item gets updated. | | checkout.cart.update.after | This event will be fired after cart item gets updated. | | checkout.cart.collect.totals.before | This event will be fired before collecting cart totals. | | checkout.cart.collect.totals.after | This event will be fired after collecting cart totals. | | checkout.cart.calculate.items.tax.before | This event will be fired before calculating cart items tax. | | checkout.cart.calculate.items.tax.after | This event will be fired after calculating cart items tax. | | core.configuration.save.before | This event will be fired before core configuration gets saved. | | core.configuration.save.after | This event will be fired after core configuration gets saved. | | core.currency.create.before | This event will be fired before currency gets created. | | core.currency.create.after | This event will be fired after currency gets created. | | core.currency.update.before | This event will be fired before currency gets updated. | | core.currency.update.after | This event will be fired after currency gets updated. | | core.currency.delete.before | This event will be fired before currency gets deleted. | | core.currency.delete.after | This event will be fired after currency gets deleted. | | core.locale.create.before | This event will be fired before locale gets created. | | core.locale.create.after | This event will be fired after locale gets created. | | core.locale.update.before | This event will be fired before locale gets updated. | | core.locale.update.after | This event will be fired after locale gets updated. | | core.locale.delete.before | This event will be fired before locale gets deleted. | | core.locale.delete.after | This event will be fired after locale gets deleted. | | sales.invoice.save.before | This event will be fired before invoice gets saved. | | sales.invoice.save.after | This event will be fired after invoice gets saved. | | checkout.order.save.before | This event will be fired before order gets saved. | | checkout.order.save.after | This event will be fired after order gets saved. | | checkout.order.orderitem.save.before | This event will be fired before order item gets saved. | | checkout.order.orderitem.save.after | This event will be fired after order item gets saved. | | sales.order.cancel.before | This event will be fired before order gets canceled. | | sales.order.cancel.after | This event will be fired after order gets canceled. | | sales.order.update-status.before | This event will be fired before order status gets updated. | | sales.order.update-status.after | This event will be fired after order status gets updated. | | sales.refund.save.before | This event will be fired before order refund gets saved. | | sales.refund.save.after | This event will be fired after order refund gets saved. | | sales.shipment.save.before | This event will be fired before shipment gets saved. | | sales.shipment.save.after | This event will be fired after shipment gets saved. | | checkout.load.index | This event will be fired on checkout page load. | | shop.item.buy-now | This event will be fired directly on the Buy Now product. | ## [#](https://devdocs.bagisto.com/2.x/advanced/events.html#events-listen-in-bagisto) Events Listen in Bagisto - Event listen in bagisto is given below with their functionality. | Events name | functionality | | ------------------------------------------------- | ------------------------------------------------------------------------ | | bagisto.shop.layout.body.after | Listing this event to load css of shop layout. | | bagisto.admin.layout.head | Listing this event to load css of admin layout. | | checkout.order.save.after | Listing this event to send notification of new order. | | sales.order.update-status.after | Listing this event to send notification of when order status is changed. | | sales.invoice.save.after | Listing this event to add paypal smart button. | | bagisto.shop.customers.login_form_controls.before | Listing this event to add social login buttons. | | bagisto.shop.products.view.compare.after | Listing this event to add social share buttons. | ## [#](https://devdocs.bagisto.com/2.x/advanced/events.html#listening-to-existing-events) Listening to Existing Events Bagisto uses events and listeners to implement the observer pattern, allowing you to respond to various actions and events within the application. You can listen to specific events and execute custom code when those events are triggered. ### [#](https://devdocs.bagisto.com/2.x/advanced/events.html#registering-a-listener) Registering a Listener Open the `EventServiceProvider.php` file located in the `Providers` directory of your Bagisto application. This file is where you register event listeners. Inside the `boot()` method of `EventServiceProvider.php`, use the `Event::listen` method to register your listener. This method takes the event name and a callback function or a class method that will handle the event. ``` Event::listen('checkout.order.save.after', 'Webkul\Notification\Listeners\Order@createOrder'); ``` In the example above, we are listening to the `checkout.order.save.after` event and specifying the `createOrder` function from the `Order` listener class in the `Webkul\Notification\Listeners` namespace. Replace `'checkout.order.save.after'` with the specific event you want to listen to. In this example, it listens to the event triggered after saving an order during checkout. By registering the listener, you have associated the **`createOrder`** function with the **`checkout.order.save.after`** event. Whenever this event is triggered, the specified function will be executed. You can modify the listener function according to your requirements to perform the desired operation. [Product Type](https://devdocs.bagisto.com/2.x/advanced/create-product-type.html)[Helpers](https://devdocs.bagisto.com/2.x/advanced/helpers.html) ## Bagisto DataGrid Guide This is the documentation for the current version (v2.3) of Bagisto. Stay informed and make the most of Bagisto's capabilities. # [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#datagrid) DataGrid - [Introduction](https://devdocs.bagisto.com/2.3/packages/datagrid.html#introduction) - [Global Properties of DataGrid](https://devdocs.bagisto.com/2.3/packages/datagrid.html#global-properties-of-datagrid) - [How DataGrid Works](https://devdocs.bagisto.com/2.3/packages/datagrid.html#how-datagrid-works) - [Setting Up DataGrid](https://devdocs.bagisto.com/2.3/packages/datagrid.html#setting-up-datagrid) - [Create the DataGrids Folder](https://devdocs.bagisto.com/2.3/packages/datagrid.html#create-the-datagrids-folder) - [Define the PostDataGrid Class](https://devdocs.bagisto.com/2.3/packages/datagrid.html#define-the-postdatagrid-class) - [Displaying DataGrid](https://devdocs.bagisto.com/2.3/packages/datagrid.html#displaying-datagrid) - [Render DataGrid](https://devdocs.bagisto.com/2.3/packages/datagrid.html#render-datagrid) - [Sample DataGrid](https://devdocs.bagisto.com/2.3/packages/datagrid.html#sample-datagrid) - [DataGrid Customization](https://devdocs.bagisto.com/2.3/packages/datagrid.html#datagrid-customization) - [Available Column Types](https://devdocs.bagisto.com/2.3/packages/datagrid.html#available-column-types) - [Integer Column Type](https://devdocs.bagisto.com/2.3/packages/datagrid.html#integer-column-type) - [Decimal Column Type](https://devdocs.bagisto.com/2.3/packages/datagrid.html#decimal-column-type) - [Supported Input Formats:](https://devdocs.bagisto.com/2.3/packages/datagrid.html#supported-input-formats) - [String Column Type](https://devdocs.bagisto.com/2.3/packages/datagrid.html#string-column-type) - [Boolean Column Type](https://devdocs.bagisto.com/2.3/packages/datagrid.html#boolean-column-type) - [Date Column Type](https://devdocs.bagisto.com/2.3/packages/datagrid.html#date-column-type) - [DateTime Column Type](https://devdocs.bagisto.com/2.3/packages/datagrid.html#datetime-column-type) - [Aggregate Type Column](https://devdocs.bagisto.com/2.3/packages/datagrid.html#aggregate-type-column) ## [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#introduction) Introduction A DataGrid is a powerful tool for displaying database records in a tabular format, making it easier to present and manage large amounts of data in an organized manner. In Bagisto, the DataGrid feature enables you to display data efficiently, with built-in functionalities like sorting, filtering, and mass actions. These additional features enhance the basic functionality of DataGrid, allowing you to interact with and manage data seamlessly. Whether you use the pre-built DataGrid or write your own custom implementation, Bagisto’s DataGrid provides a robust solution for data presentation and manipulation. ## [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#global-properties-of-datagrid) Global Properties of DataGrid The DataGrid in Bagisto has several global properties that enhance its functionality and customization. Below are the key properties and their purposes: | Property | Functionality | | -------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | **`primaryColumn`** | Specifies the primary identifier column for the data grid, typically set to `'id'` for unique identification of data entries. | | **`queryBuilder`** | Manages the database query operations for fetching data based on configured criteria. | | **`columns`** | Array defining the columns to be displayed in the data grid. | | **`sortColumn`** | Optional. Specifies the default column used for sorting data in the grid. | | **`sortOrder`** | Specifies the default order ('asc' or 'desc') for sorting data in the grid. | | **`actions`** | Array containing configurations for actions that can be performed on individual data grid entries. | | **`massActions`** | Array defining actions that can be applied to multiple entries simultaneously in the data grid. | | **`paginator`** | Stores an instance of `LengthAwarePaginator` for managing pagination of grid data. | | **`itemsPerPage`** | Specifies the default number of items to display per page in the data grid. | | **`perPageOptions`** | Array of options allowing users to select different numbers of items per page. | | **`exportable`** | Boolean indicating whether the data grid can exported. | | **`exportFile`** | Stores metadata related to exported data if `exportable` is enabled. | ## [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#how-datagrid-works) How DataGrid Works The **`DataGrid`** abstract class is created in the **`Webkul\DataGrid`** package. In the abstract class, a list of properties and methods are declared. To create your own DataGrid, you need to extend the **`Webkul\DataGrid\DataGrid`** abstract class. In **`Webkul\DataGrid\DataGrid\DataGrid.php`** abstract class, two abstract methods are declared **`prepareQueryBuilder()`** and **`prepareColumns()`**. You can prepare your grid by defining these two methods. - **`prepareQueryBuilder()`**: In this method, records are retrieved through queries applicable to the database and stored in a collection. When records are retrieved, the **`setQueryBuilder()`** method is called. ``` public function prepareQueryBuilder() { $queryBuilder = DB::table('posts') ->select('id', 'title', 'status', 'created_at', 'updated_at' ); return $queryBuilder; } ``` - **`prepareColumns()`**: In this method, columns are created which are displayed in the grid. The parameter accepts an array in key-value pairs. Some of the essential keys are described below: | Key | Functionality | | ------------------------- | --------------------------------------------------------------------------------------------- | | **`index`** | Specifies the column's index, used to identify the column within the grid. | | **`label`** | Specifies the label of the column, typically used as the column header in the grid. | | **`type`** | Specifies the type of data contained in the column. | | **`searchable`** | Accepts boolean values ( `true` or `false`) to indicate if the column can be searched. | | **`filterable`** | Accepts boolean values ( `true` or `false`) to indicate if the column can be filtered. | | **`filterableType`** | Specifies the type of filter that can be applied to the column, if filterable. | | **`filterableOptions`** | Array of options that can be used to filter the column's data. | | **`allowMultipleValues`** | Accepts boolean values ( `true` or `false`) to indicate if the column allows multiple values. | | **`sortable`** | Accepts boolean values ( `true` or `false`) to indicate if the column can be sorted. | | **`visibility`** | Accepts boolean values ( `true` or `false`) to indicate if the column is visible. | | **`closure`** | Used to apply custom actions or conditions to the column's value. | | **`columnName`** | Specifies the fully qualified table column name associated with the grid column. | ``` public function prepareColumns() { $this->addColumn([\ 'index' => 'status',\ 'label' => trans('shop::app.customers.account.orders.status.title'),\ 'type' => 'string',\ 'searchable' => true,\ 'filterable' => true,\ 'filterable_type' => 'dropdown',\ 'filterable_options' => [\ [\ 'label' => trans('shop::app.customers.account.orders.status.options.processing'),\ 'value' => Order::STATUS_PROCESSING,\ ],\ [\ 'label' => trans('shop::app.customers.account.orders.status.options.completed'),\ 'value' => Order::STATUS_COMPLETED,\ ],\ [\ 'label' => trans('shop::app.customers.account.orders.status.options.canceled'),\ 'value' => Order::STATUS_CANCELED,\ ],\ [\ 'label' => trans('shop::app.customers.account.orders.status.options.closed'),\ 'value' => Order::STATUS_CLOSED,\ ],\ [\ 'label' => trans('shop::app.customers.account.orders.status.options.pending'),\ 'value' => Order::STATUS_PENDING,\ ],\ [\ 'label' => trans('shop::app.customers.account.orders.status.options.pending-payment'),\ 'value' => Order::STATUS_PENDING_PAYMENT,\ ],\ [\ 'label' => trans('shop::app.customers.account.orders.status.options.fraud'),\ 'value' => Order::STATUS_FRAUD,\ ],\ ],\ 'sortable' => true,\ 'closure' => function ($row) {\ switch ($row->status) {\ case Order::STATUS_PROCESSING:\ return '

'.trans('shop::app.customers.account.orders.status.options.processing').'

';\ \ case Order::STATUS_COMPLETED:\ return '

'.trans('shop::app.customers.account.orders.status.options.completed').'

';\ \ case Order::STATUS_CANCELED:\ return '

'.trans('shop::app.customers.account.orders.status.options.canceled').'

';\ \ case Order::STATUS_CLOSED:\ return '

'.trans('shop::app.customers.account.orders.status.options.closed').'

';\ \ case Order::STATUS_PENDING:\ return '

'.trans('shop::app.customers.account.orders.status.options.pending').'

';\ \ case Order::STATUS_PENDING_PAYMENT:\ return '

'.trans('shop::app.customers.account.orders.status.options.pending-payment').'

';\ \ case Order::STATUS_FRAUD:\ return '

'.trans('shop::app.customers.account.orders.status.options.fraud').'

';\ }\ },\ ]); } ``` - **`prepareActions()`**: This method is defined when there is a need to perform any action such as edit or delete on the grid. In this method, the **`addAction()`** method is called to define a particular action. - **`addAction()`**: This method is used for adding actions (like **`edit`**, **`delete`**, etc.) to each row generated by the DataGrid. | Key | Functionality | | ------------ | -------------------------------------------------------------------- | | **`icon`** | This key accept class of your icon. | | **`title`** | This key accept title of action column. | | **`method`** | This key accept HTTP methods to perform specific action(GET/DELETE). | | **`url`** | This key accepts the route of the specific action. | ``` public function prepareActions() { $this->addAction([\ 'icon' => 'icon-edit'\ 'title' => trans('blog::app.admin.datagrid.edit'),\ 'method' => 'GET',\ 'url' => function ($row) {\ return route('admin.blog.edit', $row->id);\ },\ ]); } ``` ## [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#setting-up-datagrid) Setting Up DataGrid ### [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#create-the-datagrids-folder) Create the DataGrids Folder First, navigate to the `src` folder of your package. Within this folder, create a new directory called `DataGrids`. Inside this new directory, create a file named `PostDataGrid.php`. The folder structure should look like this: ``` └── packages └── Webkul └── Blog └── src ├── ... └── DataGrids └── PostDataGrid.php ``` ### [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#define-the-postdatagrid-class) Define the PostDataGrid Class Open the `PostDataGrid.php` file and add the following code to define the `PostDataGrid` class. This class will extend the base DataGrid class provided by Bagisto and set up the necessary configurations for your data grid. ``` namespace Webkul\Blog\DataGrids; use Webkul\DataGrid\DataGrid; use Illuminate\Support\Facades\DB; class PostDataGrid extends DataGrid { // ... } ``` ### [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#displaying-datagrid) Displaying DataGrid Open the `Admin/PostController.php` file in your package and locate the index method. In this method, you will use the `toJson()` method from your DataGrid class to return the data grid as JSON when the request is an AJAX call. ``` use Webkul\Blog\DataGrids\PostDataGrid; class PostController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\View\View */ public function index() { if (request()->ajax()) { return datagrid(PostDataGrid::class)->process(); } return view('blog::admin.index'); } // ... } ``` ### [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#render-datagrid) Render DataGrid Open the view file `views/admin/index.blade.php`. In this view, you will use the `datagrid` Blade component and specify the URL from which it will load the `JSON` data. Update the index.blade.php file as shown below: ``` ``` Make sure the route `admin.blog.index` is defined in your `web.php` file, so that it points to the index method of the PostController: With these steps, your DataGrid is now ready to be used. WARNING Make sure to copy the sample code provided below to your own **`PostDataGrid.php`** file, as we have already included all the necessary methods and functions there. This code can be used later as an example for your implementation. ### [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#sample-datagrid) Sample DataGrid Here's an improved version of the provided DataGrid sample: ``` select('id', 'title', 'status', 'created_at', 'updated_at' ); return $queryBuilder; } /** * Prepare columns. * * @return void */ public function prepareColumns() { $this->addColumn([\ 'index' => 'id',\ 'label' => trans('blog::app.admin.datagrid.id'),\ 'type' => 'string',\ 'searchable' => false,\ 'filterable' => true,\ 'sortable' => true,\ ]); $this->addColumn([\ 'index' => 'title',\ 'label' => trans('blog::app.admin.datagrid.title'),\ 'type' => 'string',\ 'searchable' => true,\ 'sortable' => true,\ 'filterable' => false,\ 'closure' => function ($value) {\ return substr($value->title, 0, 20);\ },\ ]); $this->addColumn([\ 'index' => 'status',\ 'label' => trans('blog::app.admin.datagrid.status'),\ 'type' => 'boolean',\ 'sortable' => true,\ 'searchable' => false,\ 'filterable' => true,\ 'closure' => function ($value) {\ if ($value->status) {\ return '

'.trans('blog::app.admin.datagrid.active').'

';\ }\ \ return '

'.trans('blog::app.admin.datagrid.inactive').'

';\ },\ ]); $this->addColumn([\ 'index' => 'created_at',\ 'label' => trans('blog::app.admin.datagrid.created_at'),\ 'type' => 'datetime',\ 'filterable' => true,\ 'filterable_type' => 'datetime_range',\ 'sortable' => true,\ ]); $this->addColumn([\ 'index' => 'updated_at',\ 'label' => trans('blog::app.admin.datagrid.updated_at'),\ 'type' => 'datetime',\ 'filterable' => true,\ 'filterable_type' => 'datetime_range',\ 'sortable' => true,\ ]); } /** * Prepare actions. * * @return void */ public function prepareActions() { $this->addAction([\ 'icon' => 'icon-edit',\ 'title' => trans('blog::app.admin.datagrid.edit'),\ 'method' => 'GET',\ 'url' => function ($row) {\ return route('admin.blog.edit', $row->id);\ },\ ]); $this->addAction([\ 'icon' => 'icon-delete',\ 'title' => trans('blog::app.admin.datagrid.delete'),\ 'method' => 'DELETE',\ 'url' => function ($row) {\ return route('admin.blog.delete', $row->id);\ },\ ]); } /** * Prepare mass actions. * * @return void */ public function prepareMassActions() { $this->addMassAction([\ 'title' => trans('blog::app.admin.datagrid.mass-update'),\ 'url' => route('admin.blog.mass_update'),\ 'method' => 'POST',\ 'options' => [\ [\ 'label' => trans('blog::app.admin.datagrid.active'),\ 'value' => 1,\ ], [\ 'label' => trans('blog::app.admin.datagrid.inactive'),\ 'value' => 0,\ ],\ ],\ ]); $this->addMassAction([\ 'title' => trans('blog::app.admin.datagrid.mass-delete'),\ 'url' => route('admin.blog.mass_delete'),\ 'method' => 'POST'\ ]); } } ``` ## [#](https://devdocs.bagisto.com/2.3/packages/datagrid.html#datagrid-customization) DataGrid Customization In Bagisto, you can customize the DataGrid to fit your specific needs. This involves extending the DataGrid template and utilizing slots to tailor the layout and functionality. Here’s how to do it: Use the `DataGrid` component in your Blade view and specify the source URL and other properties like `isMultiRow` if needed. Additionally, use the `#header` and `#body` slots to customize the content. Here’s an example of how you can extend the DataGrid template: 1. Start by extending the DataGrid template: ```