# Related Products Add-on old

**About Add-on**

The Installation of Spurtcommerce Related Product Addon will enable the feature of adding related products to any product (either admin products or vendor products). When the plugin is installed, the multi-Vendor eCommerce site becomes ready for the admin to related products to a admin or vendor product and get them displayed for the visitors to view different related products in the product detail page.

**Features:**

• In the 'Add Product' form, the admin can add related products to a particular product (either admin products or vendor products).&#x20;

• They can select the products from the list of products available in the drop down. On selecting a particular product, it gets added as a related product, under the main product.&#x20;

• They can add one or more related products to any particular product. • On the storefront, related products will appear after the product details in the product detail page.&#x20;

• The Customers can navigate to the detail pages of related products.

#### [<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**&#x20;

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;">**"productrelated-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.

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**

{% hint style="info" %}
Make sure your device 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.

Usually spurcommerce comes packed in a zip, whose name ends in "<mark style="color:green;">**productrelated-addOn.zip**</mark>".&#x20;

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

&#x20;                                       **Path -  \<PROJECT\_ROOT>/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>

&#x20;     &#x20;

```
           import * as fromRelatedProducts from 
'../add-ons/marketing/related-product/core/reducer/related-product.reducer';

```

&#x20;                                               &#x20;

2\)     Add the reducer into the below object

&#x20;           **relatedProducts: fromRelatedProducts.reducer** &#x20;

3\)     **After adding its looks like below**

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

&#x20;     relatedProducts: fromRelatedProducts.reducer,

};

**Update State Config**

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

```
import { RelatedState } from 
'../add-ons/marketing/related-product/core/reducer/related-product.state';
```

&#x20;

2\)     Add the state into the below object

&#x20;relatedProducts: RelatedState,

3\)     After adding its looks like below&#x20;

**export interface AddOnAppState {**

&#x20;    **relatedProducts: RelatedState**

**}**

**Step 3 : Change the routing file**<mark style="color:green;">**(catalog.routing.ts)**</mark>

Inside the <mark style="color:green;">**src/theme/default/admin/marketing/components/manage-cross-selling/manage-cross-selling.routing.ts**</mark>&#x20;

1\)     Import below line

```
   import * as  marketingRoutes  from "../../../../../../../add-ons/marketing/marketing.routing"

```

2\)     Add these routes below the marketingRoutes array

```
manageCrossSelling.push(marketingRoutes.RelatedProductsRoutes[0]);

```

3\)     Add the following code in

&#x20;<mark style="color:green;">**src/theme/default/marketing/components/header/header.component.html**</mark>

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

```
<li [appHideIfUnauthorized]="'related_product'">
                    <a href="#" [routerLink]="['/marketing/manage-cross-selling/related_product']" [routerLinkActive]="'active'">
                      Related products
                    </a>
                </li>

```

**Step 4 : Run the application**

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

```
 npm run large-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

```
 npm run large-build
```

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

&#x20;

## <mark style="color:blue;">Store setup</mark>

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

<br>

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

<br>

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

{% hint style="info" %}
Make sure your device 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.

<br>

&#x20;               Usually spurcommerce comes packed in a zip, whose name ends in ".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**&#x20;

**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;

&#x20; **Update Reducer Config**

```
import * as fromRelatedProducts from './RelatedProducts/core/reducer/related-products.reducer'

```

&#x20;        &#x20;

2\. **Add the reducer into the below object**

&#x20;                    relatedProducts: fromRelatedProducts.reducer

3\. **After adding its looks like below**

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

&#x20;                     relatedProducts: fromRelatedProducts.reducer

&#x20;                    }

<br>

**Update State Config**

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

```
   import { RelatedState} from './RelatedProducts/core/reducer/related-products.state'

```

&#x20;                     &#x20;

Add the state into the below object

&#x20;                   relatedProducts:RelatedState

<br>

1. &#x20;After adding its looks like below

&#x20;                                                       &#x20;

&#x20;                                                       &#x20;

&#x20;                            export interface AddOnAppState {

&#x20; relatedProducts:RelatedState

&#x20;              }

<br>

**Update Effect Config**

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

```
import { RelatedProductsEffect } from './RelatedProducts/core/effect/related-products.effects';

```

1. &#x20;Add the effect into the below object

RelatedProductsEffect

2\. After adding its looks like below

&#x20;         <mark style="color:green;">**export const ADD\_ON\_EFFECT = \[**</mark>

&#x20; <mark style="color:green;">**RelatedProductsEffect**</mark>

&#x20;<mark style="color:green;">**];**</mark>

**Update Component Config**

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

```
     import { RelatedProductsComponent } from './RelatedProducts/template/related-products/related-products.component';
     

```

&#x20;    &#x20;

&#x20;   &#x20;

2.Add the following components into the below object&#x20;

&#x20;            RelatedProductsComponent

<br>

3\. After adding its looks like below

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

RelatedProductsComponent

]

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

&#x20;The modules pertaining to related productst 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 related productst  in Spurtcommerce pages.&#x20;

\
In the RelatedProducts addon having one components.

1. RelatedProductsComponent

\
RelatedProductsComponent

&#x20;                       Directive&#x20;

```
 <app-spurt-related-products style="width: 20%;"  [productId]="id"></app-spurt-related-products>
```

&#x20;                       &#x20;

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

&#x20;                        &#x20;

&#x20;                  <mark style="color:green;">**productId:number**</mark>

RelatedProductsSandbox can be imported in 2 modules and 2 components namely&#x20;

1. ProductsModule
2. SharedModule
3. ControlsComponent
4. ProductComponent

**Step 4 : Run the application**

After you have integrated the RelatedProducts Module into Spurtcommerce, you can use the following command to run the application.&#x20;

```
 ng serve
```

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

**Step 5 : Make the build**

To run the below command

```
 ng build –prod
```

Then the latest built files can be deployed into the server.

<br>
{% endtab %}

{% tab title="React" %}

## Front End SetUp

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

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

\
**Step 1 :  Installing an extension**

{% hint style="info" %}
Make sure your device 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.

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

**Path - addOns/RelatedProduct**

**Add on location:**

projectFolder->addOns

**After placing it it will look like this**

projectFolder->addOns->RelatedProduct

**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.&#x20;

Once you finish the first Step now declare the necessary plugins in the addonconfig.js file&#x20;

1. Import below line into the addonconfig.js

<mark style="color:green;">**import SpurtRelatedProduct  from './RelatedProduct/RelatedProduct'**</mark>

2\. Add the PartialSpecification into the below object         &#x20;

<mark style="color:green;">**export const AddonsComponent={**</mark>

<mark style="color:green;">**SpurtRelatedProduct**</mark>

<mark style="color:green;">**}**</mark>

**Step 3 : Module Detail**

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

RelatedProduct Component:     &#x20;

<mark style="color:green;">**{ConnectPlugin.SpurtRelatedProduct &&  \<ConnectPlugin.SpurtRelatedProduct  slugName={pid}/>}**</mark>

**Step 4 : Run the application**

After you have integrated the RelatedProduct Module into Spurtcommerce, you can use the following command to run the application.&#x20;

```
$ 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.&#x20;

**Step 5 : Make the build**

To run the below command

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

Then the latest built files can be deployed into the server.

<br>
{% endtab %}

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

* Installing an extension
* Update the configuration
* Module Detail
* Run the Application
* 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 → RelatedProducts folder) and copy the RelatedProducts folder  and place the copied folder&#x20;

inside the project folder

<br>

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

**After placing it it will look like this**\ <mark style="color:green;">**projectFolder->lib->add-ons->RelatedProducts**</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**

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

Then inside addonsShared array paste the following content

&#x20; <mark style="color:green;">**{"RelatedProducts": SpurtRelatedProducts(), "data":""},**</mark>

After placing the above files it will look like this

\
**List addonsShared = \[**

&#x20;  **{"RelatedProducts": SpurtRelatedProducts(), "data":""},**

**];**<br>

Then give the following imports

**import 'package:spurtcommerce/add-ons/RelatedProducts/relatedproducts.dart';**

Or&#x20;

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 Related Products to the user.&#x20;

1\)  RelatedProducts

Once you finished updating the configuration then in the <mark style="color:green;">**projectFolder->lib->core->modules->detail->details.dart**</mark>

&#x20;file update this line where you seem comfortable with<br>

&#x20; **findMyClass("RelatedProducts", {“slug”:details\[“productSlug”]}),**

Add this line to get related products section

**Step 4 : Run the application**

After integrating the Related Products Module into Spurt Commerce, you can use the following commands to run the application in terminal.&#x20;

```
$ flutter run
```

<br>

Or&#x20;

In Run menu select run without debugging

In case if throws any exception&#x20;

```
$ flutter run –no-sound-null-safety
```

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

**Step 5 : Make the build**

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.&#x20;

```
$flutter build

```

If you want to split the abi then

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

For bundle build

$flutter build appbundle

<br>
{% endtab %}
{% endtabs %}

<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/marketing-related-addons/related-products-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.
