category

package
v3.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2020 License: OSL-3.0 Imports: 12 Imported by: 2

README

Category Module

  • Domain Layer: Provides domain model for:

    • (product)category with potential data a category can have (like name, media, ...)
    • a (category) tree
    • the related categoryService interface (= Secondary Port)
  • Interface Layer:

    • Provides controller for rendering category pages, supporting different templates based on the category type.
    • Provides data controller to access category and tree from inside templates
  • Product Search:

    • Since it's expected that products should be shown, there is a dependency to the "product" module - more specific to the productSearchService.
    • The category module defines in its domain also a "CategoryFilter" (that implements the search filter interface): This filter is passed to the productSearchService, so any implementation of the product search service should understand this special filter.

Configurations

You can set the templates for the category single view (if it should be different from default)

# default template
commerce.category.view.template: "category/category"

# template used for category type "teaser"
commerce.category.view.teaserTemplate: "category/teaser"

Usage in templates

This module provides two data controller that can be used to get category and tree objects:

- var rootCategoryTree = data('category.tree', {'code': ''})

 each category in rootCategoryTree.categories
 
- var category = data("category",{'code': 'category-code'})

Dependencies:

  • product package: (for product searchservice)
  • search package: (for pagination)

GraphQL

This module offers GraphQL Shema and Resolver to get Categories.

Example:

query category {
  Commerce_Category(categoryCode:"flat-screen_tvs") {
    	category {
        code
        attributes {
          all {code}
          metaKeywords:get(code:"meta_keywords") {values{value}}
          hasMetaKeywords: has(code:"meta_keywords")
        }
      }
    productSearchResult {
      products {
        baseData {title}
      }
    }
  }
}

Category tree from config

The module comes also with a Adapter for the secondary port "CategoryService" which can be activated by setting commerce.category.useCategoryFixedAdapter: true You can then configure a category tree like in the example below.

(Of course this is only useful for small tests or demos)

commerce:
  category:
    useCategoryFixedAdapter: true
    categoryServiceFixed:
      tree:
        electronics:
          code: electronics
          name: Electronics
          sort: 1
          childs:
            flat-screen_tvs:
              code: flat-screen_tvs
              name: Flat Screens & TV
            headphones:
              code: headphones
              name: Headphones
              childs:
                headphone_accessories:
                  code: headphone_accessories
                  name: Accessories
            tablets:
              code: tablets
              name: Tablets
        clothing:
          code: clothing
          name: Clothes & Fashion
          sort: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func URL

func URL(code string) (string, map[string]string)

URL to category

func URLWithName

func URLWithName(code, name string) (string, map[string]string)

URLWithName to category

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module registers our profiler

func (*Module) Configure

func (m *Module) Configure(injector *dingo.Injector)

Configure the product URL

func (*Module) DefaultConfig

func (m *Module) DefaultConfig() config.Map

DefaultConfig for this module

func (*Module) Depends

func (m *Module) Depends() []dingo.Module

Depends on other modules

func (*Module) Inject

func (m *Module) Inject(
	routerRegistry *web.RouterRegistry,
	config *struct {
		UseCategoryFixedAdapter bool `inject:"config:commerce.category.useCategoryFixedAdapter,optional"`
	},
)

Inject dependencies

Directories

Path Synopsis
interfaces
graphql
Package graphql Code generated by go-bindata.
Package graphql Code generated by go-bindata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL