Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/salesforce/cpq-product-recommendation-demo
Example CPQ product recommendation engine with implementation of the CPQ Product Recommendation Plugin interface.
https://github.com/salesforce/cpq-product-recommendation-demo
apex cpq engine recommendation
Last synced: 12 days ago
JSON representation
Example CPQ product recommendation engine with implementation of the CPQ Product Recommendation Plugin interface.
- Host: GitHub
- URL: https://github.com/salesforce/cpq-product-recommendation-demo
- Owner: salesforce
- License: bsd-3-clause
- Created: 2020-07-30T15:31:36.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-22T02:42:41.000Z (over 2 years ago)
- Last Synced: 2024-04-08T00:12:35.631Z (8 months ago)
- Topics: apex, cpq, engine, recommendation
- Language: Python
- Homepage: https://releasenotes.docs.salesforce.com/en-us/winter21/release-notes/rn_sales_cpq_product_recommendations_plugin.htm?edition=&impact=
- Size: 92.8 KB
- Stars: 6
- Watchers: 9
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# CPQ Product Recommendation Engine Demo
This is a demo recommendation engine which reads all org quotes from salesforce database,
generates product recommendations and inserts them into the Salesforce database.## Architectural Overview
![Architecture](img/architecture.png?raw=true)The recommendation engine is scheduled to run once a day, which can be configured in [job.py](job.py).
The recommendation custom object records inserted by the engine are queried and processed by the
CPQ ProductRecommendationPlugin (Eg. [ScoredRecoPluginImpl](apex-plugin-impl/ScoredRecoPluginImpl.cls) in the below architecture diagram) which returns an ordered list of pricebook entries.
A couple of sample implementations of the plugin are provided in the
directory [apex-plugin-impl](apex-plugin-impl).## Setup and Run
- Here's an example of a [recommendation custom object](custom-objects/ProductRecommendation__c)
that you should add to your org
before this engine is run to insert the custom object records into your org:
```
ProductRecommendation__c {
Id Product2Id__c,
Id RecommendedProduct2Id__c,
Integer Score__c
}
```
- Set the org login credentials as environment variables using `export`
```
export ORG_USERNAME=
export ORG_PASSWORD=
export ORG_SECURITY_TOKEN=
export ORG_DOMAIN= - should be 'test' or 'login' or 'something.my'
```
- Configure the recommendation custom object in the `bulk.py` code
- Set the name of your recommendation custom object and its custom fields in the constant variables:
`RECOMMENDATION_OBJECT`, `PRODUCT_ID_FIELD`, `RECOMMENDED_PRODUCT_ID_FIELD`, `SCORE_FIELD`
- Construct the recommendation object record in the method - `get_recommendation_record()`
- Open a terminal and `cd` into the project directory
- Install dependencies
```console
$ pip install -r requirements.txt
- Make the file executable
```console
$ chmod +x start.sh
- Invoke the job script
```console
$ ./start.sh## Run Tests
[pytest](https://pytest.org/) is used to run the integration tests.
As mentioned above, the org login credentials need to be set as environment variables before running the tests.
To run the tests, type:```
$ pytest
```