# Common Product Add-on old

**Installation of Spurtcommerce common product for Vendor Products Add-On**

**you can install this Add-on through following steps**

step 1: [<mark style="color:blue;">Setup an API (Step By Step)</mark>](#setup-an-api-step-by-step) to add extension for admin

step 2:[ <mark style="color:blue;">Admin setup</mark>](#admin-setup)

step 3: you can easily install admin storefront with[ <mark style="color:blue;">store setup</mark>](#store-setup-1)<mark style="color:blue;">**.**</mark> spurtcommerce provides 3 admin storefronts, built with[ <mark style="color:blue;">Angular</mark>](#angular)<mark style="color:blue;">,</mark>[ <mark style="color:blue;">Flutter</mark>](#flutter) and[ <mark style="color:blue;">React.</mark>](#react) &#x20;

**Along with the above steps you need to  further follow these steps below to install this Add-on for Multi-vendor platform**

step 4: [<mark style="color:blue;">Setup an API (Step By Step)</mark>](#setup-an-api-step-by-step-to-add-extension-for-multivendor)[ ](#setup-an-api-step-by-step-to-add-extension-for-multi-vendor)to add extension for multi vendor

step 5 :[ <mark style="color:blue;">Multi Vendor front end setup</mark>](#multi-vendor-frontend-setup)

step 6: you can easily install vendor storefront with[ <mark style="color:blue;">store setup</mark>](#store-setup-1)<mark style="color:blue;">**.**</mark> spurtcommerce provides 3 vendor storefronts, built with[ <mark style="color:blue;">Angular,</mark>](#angular-1) [<mark style="color:blue;">Flutter</mark> ](#store-setup-1)and [<mark style="color:blue;">React.</mark>  ](#store-setup-1)

**About Addon :**

The installation of Common Product addon will allow the Admin to convert a particular product, either their own or any vendor's as a common product, which means any vendor on the portal can sell the same product, by just updating the price at which they want to sell the product and the quantity they have of that product.

**Features**

* Make any product from your entire product list, a common product, by just enabing the toggle.&#x20;
* You can make admin products as well as Vendor products, the common product that will be available for all the vendors to sell on the online portal.
* &#x20;The vendor can sell any product that is available on the list of common products, by simply updating the price and the quantity that they have.&#x20;
* The Product detail page of a common product, will display the common products, along with the vendor's name and their price.&#x20;
* The product detail page will show the list of all the vendors that are selling the same product.

### [<mark style="color:blue;">Setup an API (Step By Step)</mark>](#setup-an-api-step-by-step)

For setting up the API, you need to execute the following steps:

* Installing an extension&#x20;
* Run the application&#x20;
* Make the build

**Step 1 : Installing an extension**

These are the steps that need to be executed for installation of the extension.

Usually spurcommerce comes packed in a zip, whose name ends in <mark style="color:green;">**"commonproduct-addOn.zip".**</mark> Extract the zip file, open api folder and open addon folder within that and copy the content of addon folder into the specified path.

&#x20;                                              **Path - \<PROJECT\_ROOT>/addon**

**Step 2 : Run the application**

After you have completed the installation of the above mentioned steps, you can run the application and also view the changes.

```
$ npm start serve
```

Once you execute the above command, add-on file will get integrated into the backend API.

**Step 3 : Make the build**

These are the steps that need to be followed for generating the build.&#x20;

To run the below command

```
$ npm run build
```

Then latest built files can be deployed into the server.

## <mark style="color:blue;">Admin Setup</mark>

These are the steps that need to be followed to do the front end admin setup.&#x20;

* Installing an extension
* Update the configuration
* Module Detail
* Run the application
* Make the build

&#x20;**Step 1 : Installing an extension**         &#x20;

These are the steps that need to be executed for installation of the extension.

&#x20;          Usually spurcommerce comes packed in a zip, whose name ends in "commonproducts.addOn.zip".&#x20;

Extract the zip file and copy the content of admin/add-ons folder into the specified path

**Path -  admin/add-ons**&#x20;

**Step 2 : Update the configuration**            &#x20;

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce config files. For this, you need to follow the steps below.&#x20;

**Update Reducer Config**

1. Import below line into the <mark style="color:green;">**add-ons/add-ons-reducer.ts**</mark>

```
 import * as fromCommonCatalog from 
 '../add-ons/marketplace/common-product/core/common-catalog/reducer/common-catalog.reducer';


```

**Add the reducer into the below object**

&#x20;  **commonCatalog:fromCommonCatalog.reducer,**

**After adding its looks like below**

&#x20;export const AddOnReducers: ActionReducerMap\<State> = {

&#x20;                    commonCatalog: fromCommonCatalog.reducer

<br>

&#x20;             };

\
**Update State Config**

&#x20;    Import below line into the <mark style="color:green;">**add-ons/add-ons-state.ts**</mark>

```
import { commonCatalogState } from
 '../add-ons/marketplace/common-product/core/common-catalog/reducer/common-catalog.state'

```

&#x20; Add the state into the below object

&#x20;           **commonCatalog: commonCatalogState**

3\)    After adding its looks like below

&#x20;               **export interface AddOnAppState {**

&#x20;   **commonCatalog: commonCatalogState**

**}**

**Step 3 : Change the routing file(catalog.routing.ts)**

Inside the <mark style="color:green;">**src/theme/default/admin/marketplace/components/manage-products/manage-products.routing.ts**</mark>

1. **Import below line**

```
   import * as marketplaceRouting from 
   '../../../../../../../add-ons/marketplace/marketplace.routing';

```

1. Add these routes below the cmsRoutes array

```
        manageProductsRoute.forEach(data => {
  if (data) {
manageProductsRoute.
push(marketplaceRouting.commonCatalogRoutes[0]);
              }
});

```

**Add this line to keep the header tab**&#x20;

<mark style="color:green;">**src/theme/default/admin/marketplace/components/header/header.component.html**</mark>

<mark style="color:green;">**Below line no:46**</mark>

```
 <li>
                        <a href="#" [routerLink]="['/vendors/manage-products/common_catalog']" [routerLinkActive]="'active'">
                              common products
                        </a>
                    </li>

```

**Step 4 : Run the application**

After you have completed the installation of the above mentioned steps, you can run the application and also view the changes.

```
 npm run large-serve

```

Once you execute the above command, add-on file will get integrated into the backend API.

**Step 5: Make the build**

These are the steps that need to be followed for generating the build.

To run the below command

```
 npm run large-build

```

Then latest built files can be deployed into the server.                              &#x20;

## [ <mark style="color:blue;">vendor frontend  Setup</mark> ](#vendor-setup)

These are the steps that need to be followed to do the front end vendor setup.&#x20;

●       Installing an extension

●      Update the configuration

●      Module Detail

●      Run the application

●      Make the build

&#x20;

**Step 1 : Installing an extension**

&#x20;

Usually spurcommerce comes packed in a zip, whose name ends in "common-product-addOn.zip".

&#x20;          Extract the zip file and copy the content of vendor/add-ons folder into the specified path

&#x20;                                                                   **Path -  vendor/add-ons**

**Step 2 : Update the configuration**

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce config files. For this, you need to follow the steps below.

&#x20; **Update Reducer Config**

1\)     Import below line into the <mark style="color:green;">**add-ons/add-ons-reducer.ts**</mark>

```
  import *as fromCommonProduct from 
  '../add-ons/CommonProduct/core/reducer/CommonProducts.reducer'

```

2\)     Add the reducer into the below object

```
         commonProducts:fromCommonProduct.reducer,
             
```

3\)     After adding its looks like below

&#x20;             **export const AddOnReducers: ActionReducerMap\<State> = {**

&#x20;                                                     **commonProducts:fromCommonProduct.reducer,**

&#x20;                                           **};**                                            &#x20;

**Update State Config add-ons/add-ons-state.ts**        &#x20;

```
import { commonProductsState } from
'../add-ons/CommonProduct/core/reducer/CommonProducts.state';
```

1\)     Add the state into the below object

```
 commonProducts:commonProductsState,

```

2\)     After adding its looks like below

&#x20;**export interface AddOnAppState {**

&#x20;                                  **commonProductst:commonProductsState,**

<br>

&#x20;                                **}**                     &#x20;

**Update Effect Config**

&#x20;

1\)     Import below line into the <mark style="color:green;">**add-ons/add-ons.effect.ts**</mark>

```
           import { commonProductsEffect } from 
           "./CommonProduct/core/effects/CommonProducts.effect";

```

2\)     Add the effect into the below object

```
  commonProductsEffect

```

3\)     After adding its looks like below

&#x20;                   **export const ADD\_ON\_EFFECT = \[**

&#x20;                                    **commonProductsEffect**

<br>

**];**

\
&#x20;  &#x20;

**Update Component Config**

```
import { CommonProductComponent } from
 "./CommonProduct/template/common-product/common-product.component";
 
```

1\)    Add the following components into the below object

```
 CommonProductComponent                                 
```

2\)     After adding its looks like below

&#x20;         **export const ADD\_ON\_COMPONENTS = \[**

&#x20;                       **CommonProductComponent**

&#x20;                                            **]**

**Step 3 : Module Detail**

**Routing**

&#x20;     In <mark style="color:green;">**src/app/default/pages/component/calalog/manage-product/manage-product.module**</mark>

&#x20;     &#x20;

1\)      Import below line

&#x20;                 &#x20;

```
 import { CommonProductComponent } from 
 '../../../../../../../add-ons/CommonProduct/template/common-product/common-product.component';
```

&#x20;        2\)  Add these routes below the Routes array

```
{
           path: 'common-product',
           component: CommonProductComponent,
           data: {
               title: 'Common Product',
               urls: [{ title: 'Home', url: '/dashboard' }, { title: 'Products', url: '/common/product' }, { title: 'common product' }]
           }
         },         
```

**Add this line to keep the header tab**&#x20;

<mark style="color:green;">**src/app/default/pages/component/catalog/layout/products.component.html**</mark>

<mark style="color:green;">**Below line no:20**</mark>

```
<a href="#" [routerLink]="['/catalog/manage-products/common-product']" class="">Common Products</a>
```

**Step 4 : Run the application**

After you have integrated the ProductVariant Module into Spurtcommerce, you can use the following command to run the application.

```
 ng serve
```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.

**Step 5 : Make the build**

&#x20;         To run the below command

```
  ng build - -prod
```

&#x20;         Then the latest built files can be deployed into the server.

## &#x20;[<mark style="color:blue;">Store Setup</mark>](#store-setup)

{% tabs %}
{% tab title="Angular" %}
These are the steps that need to be followed to do the front end store setup.

* Installing an extension&#x20;
* Update the configuration&#x20;
* Module Detail&#x20;
* Run the application&#x20;
* Make the build

**Step 1 : Installing an extension**

{% hint style="info" %}
Note

Make sure your application is running on the device or simulator, or it will not show up in the list.
{% endhint %}

These are the steps that need to be executed for installation of the extension.

\
&#x20;Usually spurcommerce comes packed in a zip, whose name ends in "commonproducts.addOn.zip".&#x20;

&#x20;               Extract the zip file and copy the content of store-angular/add-ons  folder into the specified path

&#x20;              **Path - store-angular/add-ons**

**Step 2 : Update the configuration**

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce config files. For this, you need to follow the steps below.

**Update Reducer Config**

* Import below line into the <mark style="color:green;">**add-ons/add-ons-reducer.ts**</mark>

```
import * as fromCommonProducts from 
  './CommonProducts/core/reducer/common-products.reducer';  


```

* **Add the reducer into the below object**   &#x20;

&#x20;          **commonProducts: fromCommonProducts.reducer,**

* After adding its looks like below

&#x20;         export const AddOnReducers: ActionReducerMap\<State> = {

&#x20;                                             commonProducts: fromCommonProducts.reducer,

&#x20;                                                   }

**Update State Config**

* Import below line into the <mark style="color:green;">**add-ons/add-ons-state.ts**</mark>

```
   import { commonProductsState } from       
       './CommonProduct/core/reducer/CommonProducts.state';

```

* Add the state into the below object

&#x20;                      commonProducts:commonProductState

<br>

* After adding its looks like below

&#x20;                 export interface AddOnAppState {

&#x20;             commonProducts:commonProductState         &#x20;

&#x20;              }

**Update Effect Config**

* Import below line into the <mark style="color:green;">**add-ons/add-ons.effect.ts**</mark>

```
 import { CommonProductEffect } from              
  './CommonProducts/core/effects/common-products.effect';


```

* Add the effect into the below object

&#x20;                                     commonProductsEffect

* After adding its looks like below

**export const ADD\_ON\_EFFECT = \[ commonProductsEffect ];**

**Update Component Config**

* Import below line into the <mark style="color:green;">**add-ons/add-ons.shared.component**</mark>

```
      import { ViewProductsComponent } from 
      './CommonProducts/template/view-products/view-products.component';

```

```
     import { CommonproductsComponent } from 
     './CommonProducts/template/common-products/common-products.component';

     

```

* Add the following components into the below object

&#x20;                          ViewProductsComponent,

&#x20;                          CommonproductsComponent

* After adding its looks like below

&#x20;export const ADD\_ON\_COMPONENTS = \[

&#x20;                                           ViewProductsComponent,

&#x20;                                           CommonproductsComponent

&#x20;                                 ];

&#x20; **Step 3 : Component Detail**

&#x20; The modules pertaining to viewproducts and commonproducts are listed below. You may use these modules, in any page of Spurtcommerce.&#x20;

Also, you can find the steps below to use the modules in ViewProducts and CommonProducts  in Spurtcommerce pages.&#x20;

&#x20;                            In the CommonProducts addon having two components.

1. ViewProductsComponent
2. CommonproductsComponent

ViewProductsComponent

&#x20;                       Directive&#x20;

```
<app-spurt-view-products [productId]="(productDetail.productDetails$ | async)?.productId" [productSlug]="(productDetail.productDetails$|async)?.productSlug"></app-spurt-view-products>
```

&#x20;                                     &#x20;

&#x20;                     In the above directive have one input field

&#x20;                                                 ProductId:number;

&#x20;                                                 Productslug:any;

<br>

CommonProductsComponent

&#x20;                          This is a one page component. You can configure the route for this component.

&#x20;                          This component only works with productslug,because after clicking sellers in productdetail page it redirects to the commonproducts component.

```
Syntax:
  {
 path: 'common-products/:id',
 component: CommonproductsComponent,
 pathMatch: 'full',
    data: {
          urls: [
          { title: 'Products', url: '/products' },
          { title: 'Product detail', url: '' }
                                                        ] } }

```

**Step 4 : Run the application**&#x20;

After you have integrated the Common Product Module into Spurtcommerce, you can use the following command to run the application.

```
ng serve
```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.

**Step 5 : Make the build**

To run the below command

```
ng build –prod
```

Then the latest built files can be deployed into the server.
{% endtab %}

{% tab title="React" %}
These are the steps that need to be followed to do the front end store setup.&#x20;

* Installing an extension&#x20;
* Update the configuration&#x20;
* Run the application&#x20;
* Make the build

**Step 1 : Installing an extension**

These are the steps that need to be executed for installation of the extension.

<br>

Usually spurcommerce comes packed in a zip, whose name ends in "commonproducts.addOns.zip". Extract the zip file and copy the content of store-react/addOns into the specified path as given below

**Path - addOns/CommonVendorProduct**

**Add on location:**&#x20;

<mark style="color:green;">**projectFolder->addOns**</mark>&#x20;

**After placing it it will look like this**&#x20;

<mark style="color:green;">**projectFolder->addOns->CommonVendorProduct**</mark>

**Step 2 : Update the configuration**

After the installation of the extension, you will have to update certain configurations into the default Spurtcommerce addonsconfig.js files. For this, you need to follow the steps below.

Once you finish the first Step now declare the necessary plugins in the addonconfig.js file

* Import below line into the <mark style="color:green;">**addonconfig.js**</mark>

```
import SpurtCommonvendorproductlist from
 './CommonVendorProduct/commonvendorproductlist'
 import SpurtcommonvendorproductViewMore from 
 './CommonVendorProduct/commonvendorproduct'


```

* Add the *commonvendorproduct* into the below object

```
export const AddonsComponent={
SpurtCommonvendorproductlist,
           SpurtcommonvendorproductViewMore
}

```

**Step 3 : Module Detail**

The modules pertaining to commonvendorproduct are listed below. You may use these modules, in any page of Spurtcommerce.

**SpurtcommonvendorproductViewMore Component:**

**{ConnectPlugin.SpurtcommonvendorproductViewMore &&  \<ConnectPlugin.SpurtcommonvendorproductViewMore product={product} Productslug={Productslug} />}**

<br>

**Spurtcommonvendorproduct Component:**     &#x20;

**{ConnectPlugin.Spurtcommonvendorproduct &&  \<ConnectPlugin.Spurtcommonvendorproduct product={product} Productslug={Productslug} />}**

<br>

&#x20;                   &#x20;

**Step 4 : Run the application**

After you have integrated the commonvendorproduct Module into Spurtcommerce, you can use the following command to run the application.

```
$ npm run dev
```

Once you execute the above command you can view the installed module in Spurtcommerce, within the page in which you have integrated.

**Step 5 : Make the build**

To run the below command

```
$ npm run build or yarn run build
```

Then the latest built files can be deployed into the server.
{% endtab %}

{% tab title="Flutter" %}
These are the steps that need to be followed to do the front end store setup.

* Installing an extension&#x20;
* Update the configuration&#x20;
* Module Detail&#x20;
* Run the Application&#x20;
* Make the build

**Step 1 : Installing an extension**

These are the steps that need to be executed for installation of the extension.

Extract the store-flutter folder  inside the folder go to (store-fluter → add-ons → CommonProducts folder) and copy the CommonProducts folder  and place the copied folder&#x20;

inside the project folder

**Add on location:**&#x20;

<mark style="color:green;">**projectFolder->lib->add-ons**</mark>

**After placing it it will look like this**&#x20;

<mark style="color:green;">**projectFolder->lib->add-ons->Common\_ Products**</mark>

Once you finish these steps continue to the next step

**Step 2 : Update the configuration**

After extracting the add on zip file for changing the configurations in addons.dart, you have to follow the steps below:

**Go to**&#x20;

<mark style="color:green;">**projectFolder->lib->add-ons->addonsshared.dart**</mark>

Then inside *addonsShared* array paste the following content

```
  {"CommonProduct": SpurtCommonProduct(), "data":""},
```

* After placing the above files it will look like this

**List addonsShared = \[ {"CommonProduct": SpurtCommonProduct(), "data":""},];**

Then give the following imports

```
import 'package:spurtcommerce/add-ons/CommonProducts/All-SellersList.dart';

```

Or There will be a popup for quick fix

**Step 3 : Module detail**

After executing the above mentioned steps, we have to place these below lines in the core folder to show the rating and review to the user.

**CommonProduct**&#x20;

Once you finished updating the configuration then in the <mark style="color:green;">**projectFolder->lib->core->modules->detail->details.dart**</mark> file update this line where you seem comfortable with

**findMyClass("CommonProduct", {“productId”:details\[“productId”],”details”:details}),**

Add this line to your side menu to get blogs section

**Step 4 : Run the application**

After integrating the Rating and Review Module into Spurt Commerce, you can use the following commands to run the application in terminal.

```
$ flutter run
```

Or&#x20;

In **Run** menu select **run without debugging**&#x20;

In case if throws any exception&#x20;

**$ flutter run –no-sound-null-safety**&#x20;

Once you execute the above command you can view the installed module in Spurt Commerce, within the page in which you have integrate&#x64;**.**

**Step 5 : Make the build**

&#x20;In order to build, you need to run the following commands. In order to check the application, run the following commands and build the application.

```
$flutter build
```

If you want to split the abi then

```
$flutter build –split-per-abi
```

For bundle build

```
$flutter build appbundle
```

{% endtab %}
{% endtabs %}

&#x20;

&#x20;

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spurtcommerce.com/addons/catalogue-related-addons/common-product-add-on-old.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
