Skip to content

Commit

Permalink
General clean-up and stabilization of the solution (#1)
Browse files Browse the repository at this point in the history
* support for csv delimiter config

* skip localized attributes in other locales

* Move config, allow splitting of product attributes via config

* Add missing facet config to cue

* Add sort config

* Fix pagination not working with bleve due to different concept

* 232508: use configured sort options in indexer

* 232508: mark active facets

* Set saleable attributes

* introduce stock level to indexer

* Make SearchBy work

* Fix cfg struct in functional test

* Add module_test

* Update module readmes to match config/acutal code

* Clean up code, fix typos remove dead code

* Update go.mod / go.sum

* Update mandatory fields readme

* Fix typos in main readme, add basic CHANGELOG

* allow other path values, too

* Apply suggestions from code review

Fixed Typos

* Fix tests, update CHANGELOG.md

* Try to fix travis ci to run tests again

* Fix logrus dependency

* Update go.mod / go.sum

* Reorder .travis.yml

* Remove travis, add GitHub Actions

* Always run actions on PR

* Fix spelling

* Adapt code to match CR comments

* Adapt code to match CR comments

Co-authored-by: Thorsten Essig <thorsten.essig@aoe.com>
Co-authored-by: Nicole Schmelzer <56079794+kalypso-byte@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 17, 2020
1 parent 4001dfc commit 923fb49
Show file tree
Hide file tree
Showing 37 changed files with 955 additions and 700 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Tests

on:
push:
branches:
- master
pull_request:

jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.*' ]
name: Run tests
steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Get dependencies
run: go get -v -t -d ./...
- name: Test
run: go test -race ./...
static-checks:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.*' ]
name: Static checks
steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Get dependencies
run: go get -v -t -d ./...
- name: Go Vet
run: go vet ./...
- name: Go Fmt
run: |
fmt=$(gofmt -l .)
test -z $fmt || (echo "please run gofmt" ; echo $fmt ; exit 1)
- name: Go Lint
run: go run golang.org/x/lint/golint -set_exit_status $(go list ./...)
- name: Go Cyclo
run: go run github.com/fzipp/gocyclo/cmd/gocyclo -top 30 -ignore graphql .
- name: Spelling
run: |
find . -type f -name '*.go' | xargs go run github.com/client9/misspell/cmd/misspell -error
find . -type f -name '*.md' | xargs go run github.com/client9/misspell/cmd/misspell -error
- name: In effective assignments
run: go run github.com/gordonklaus/ineffassign .
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog

## v0.0.3-beta [upcoming]

* Update Readme's to reflect current configs / fix typos
* Update CueConfig to match used configurations
* Remove unused / commented out code
* Add module_tests
* Fix non-working SearchBy implementation
* Fix non-working Bleve pagination
* Add config for additional Facets/Sorting
* Allow different CSV delimiter via config
* Add support for stock level / saleable / retailer name attribute
* Add active Facets to search response
* Avoid indexing foreign language attributes
* Remove default title sort option

## v0.0.2-beta

**commercesearch**
* In memory repository was refactored
* Belve implementation was added

**csvindexing**
* Module was added

**emailplaceorder**
* Module was added

## v0.0.1-beta
* First version containing in memory product / category repository
44 changes: 21 additions & 23 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
[![Build Status](https://travis-ci.org/i-love-flamingo/flamingo-commerce-adapter-standalone.svg?branch=master)](https://travis-ci.org/i-love-flamingo/flamingo-commerce-adapter-standalone?branch=master)

# Flamingo Commerce Adapters Standalone

# Flamingo Commerce Adapters Standalone
This repository contains modules that allow to run Flamingo Commerce in a standalone mode.
(Not connected to any third party headless ecommerce API).

This repository contains modules that allow to run Flamingo Commerce n a standalone mode.
(Not connected to any thirds party headless ecommerc API).

According to the Flamingo Commerce concept of "ports and adapters" the modules provide mplementations for Flamingo Commerce Ports.
According to the Flamingo Commerce concept of "ports and adapters" the modules provide implementations for Flamingo Commerce Ports.

The following flamingo modules are part of that:

* commercesearch
* Provide Product; ProductSearch; Category and Search. That means you can have working product views, category vews and search features.
* The module therefore interally uses Repository where products are stored and received from. You can choose between
* A simple "InMemory" version
* A implementation based on bleve - a go based indexed search implementation ( https://github.com/blevesearch/bleve)
* The module requires someone who takes care if indexing new products and categories. Therefore it expects an implemantation of an "IndexUpdater"
* See [Module commercesearch Readme](commercesearch/Readme.md)

* csvindexing
* usful addon module for the *commercesearch* module
* Provide a "IndexUpdater" that loads products and categories from a CSV file
* See [Module csvcommerce Readme](csvindexing/Readme.md)
* **commercesearch**
* Provide Product; ProductSearch; Category and Search. That means you can have working product views, category views and search features.
* The module therefore internally uses Repository where products are stored and received from. You can choose between
* A simple "InMemory" version
* An implementation based on bleve - a go based indexed search implementation ( https://github.com/blevesearch/bleve)
* The module requires someone who takes care of indexing new products and categories. Therefore, it expects an implementation of an "IndexUpdater"
* See [Module commercesearch Readme](commercesearch/Readme.md)

* emailplaceorder
* Like the name says a module that just sends mails (to customer and storeowner) after placing an order
* **csvindexing**
* useful addon module for the *commercesearch* module
* Provide a "IndexUpdater" that loads products and categories from a CSV file
* See [Module csvcommerce Readme](csvindexing/Readme.md)

* **emailplaceorder**
* Like the name says a module that just sends mails (to customer and store owner) after placing an order
* See [Module emailplaceorder Readme](emailplaceorder/Readme.md)


## Usage

Just add the modules to your Flamingo bootstrap like this:

```
//flamingo-commerce-adpater-standalone modules:
```go
new(commercesearch.Module),
new(commercesearch.CategoryModule),
new(commercesearch.SearchModule),
new(csvindexing.ProductModule),
new(emailplaceorder.Module),
..

```

There are a couple of configuration options. See the Flamingo `config` command and the module readme for details.
There are a couple of configuration options. See the Flamingo `config` command, and the module readme for details.
62 changes: 36 additions & 26 deletions commercesearch/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,69 @@
Provides Adapters for Flamingo Commerce to persist and retrieve products.

The provided adapters are:
* productService (to retrieve single products)
* productSearchService (to search for products - e.g. used on category listing page)
* categoryService (for Flamingo Commerce "category" module - to receive categorys and category trees). To use the Adapter you need to add the main `CategoryModule` to your bootstrap.
* searchService (for Flamingo Commerce "search" module allowing searching for products documents). To use the Adapters you need to add the main `SearchModule` to your bootstrap.

* productService (to retrieve single products)
* productSearchService (to search for products - e.g. used on category listing page)
* categoryService (for Flamingo Commerce "category" module - to receive categories and category trees). To use the
Adapter you need to add the main `CategoryModule` to your bootstrap.
* searchService (for Flamingo Commerce "search" module allowing searching for products documents). To use the Adapters
you need to add the main `SearchModule` to your bootstrap.

The available products need to be indexed first and will be stored in a `ProductRepository`.

The module also provides an adapter to receive categories and Category Trees and provides an Adpater for the Flamingo Commerce CategoryService (flamingo.me/flamingo-commerce/v3/category/domain)
The module also provides an adapter to receive categories and Category Trees and provides an Adapter for the Flamingo
Commerce CategoryService (flamingo.me/flamingo-commerce/v3/category/domain)

## Indexing

## Indexing ##
The indexing itself is not part of that module - because the indexing source might be something project specific.
However - the module "csvindexing" implements an indexer that can be used to read products from a CSV file.

The indexing (loading) of products is done by implementing and registering the `IndexUpdater` interface:

```go

//IndexUpdater - interface to Load products in a Index - secondary port
IndexUpdater interface {
//Indexer method that is called with an initialized Indexer. The passed Indexer provides helpers to update the Repository
Index(ctx context.Context, rep *Indexer) error
}
// IndexUpdater interface to load products in an Index - secondary port
IndexUpdater interface {
// Indexer method that is called with an initialized Indexer. The passed Indexer provides helpers to update the Repository
Index(ctx context.Context, rep *Indexer) error
}
```

So you can implement that interface (port) by an own implementation (adapter) and then register your implementation:

```
```go
injector.Bind((*productSearchDomain.IndexUpdater)(nil)).To(YourLoaderImplementation)
```


## Configuration

With the setting
`flamingo-commerce-adapter-standalone.commercesearch.repositoryAdapter` you can switch the repository implementation.
`flamingoCommerceAdapterStandalone.commercesearch.repositoryAdapter` you can switch the repository implementation.

The default is an simple in-memory product index, that works for single instances.
The default is a simple in-memory product index, that works for single instances.

## Bleve Repository
### Bleve Repository Adapter

You can also use the bleve based repository - bleve (http://blevesearch.com/) is a full text search and index for go.
Supports sorting, facets and more.

```
flamingo-commerce-adapter-standalone:
commercesearch
```yaml
flamingoCommerceAdapterStandalone:
commercesearch:
enableIndexing: true
repositoryAdapter: bleve
repositoryAdapter: "bleve"
bleveAdapter:
//if products should also be attached to theire parent categories (default is true)
productsToParentCategories: true
//enable hierarichal category facet (based on the indexed products)
enableCategoryFacet: true
// add facets for any additional attribute:
facetConfig:
- attributeCode: brandCode
amount: 10
```
# Add facet for the color attribute
- attributeCode: "color"
amount: 20
sortConfig:
# Add sorting for color attribute
- attributeCode: "color"
attributeType: "text" # field content: text, numeric, bool
asc: true # Allow asc sorting
desc: true # Allow desc sorting
```
Loading

0 comments on commit 923fb49

Please sign in to comment.