flamingo.me/flamingo-commerce/v3@v3.11.0/product/interfaces/templatefunctions/getProduct.go (about)

     1  package templatefunctions
     2  
     3  import (
     4  	"context"
     5  	"log"
     6  
     7  	"flamingo.me/flamingo-commerce/v3/product/domain"
     8  )
     9  
    10  type (
    11  	// GetProduct is exported as a template function
    12  	GetProduct struct {
    13  		ProductService domain.ProductService `inject:""`
    14  	}
    15  )
    16  
    17  // Func factory
    18  func (tf *GetProduct) Func(ctx context.Context) interface{} {
    19  	return func(marketplaceCode string) domain.BasicProduct {
    20  		product, e := tf.ProductService.Get(ctx, marketplaceCode)
    21  		if e != nil {
    22  			log.Printf("Error: product.interfaces.templatefunc %v", e)
    23  		}
    24  		return product
    25  	}
    26  }