added ImageID and LinkRewrite
This commit is contained in:
10
repository/categoriesRepo/categoriesRepo.go
Normal file
10
repository/categoriesRepo/categoriesRepo.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package categoriesRepo
|
||||
|
||||
type UICategoriesRepo interface {
|
||||
}
|
||||
|
||||
type CategoriesRepo struct{}
|
||||
|
||||
func New() UICategoriesRepo {
|
||||
return &CategoriesRepo{}
|
||||
}
|
||||
@@ -22,13 +22,31 @@ func (repo *ListProductsRepo) GetListing(id_shop uint, id_lang uint, p find.Pagi
|
||||
var total int64
|
||||
|
||||
// Apply filters here
|
||||
q := db.DB.Table("ps_product").
|
||||
Select("ps_product.id_product AS id_product", "ps_product_lang.name AS name", "ps_product_shop.price AS price", "ps_product.active AS active_as_product", "ps_product_shop.active AS active_in_shop").
|
||||
Joins("LEFT JOIN ps_product_shop ON ps_product.id_product = ps_product_shop.id_product").
|
||||
Joins("LEFT JOIN ps_product_lang ON ps_product.id_product = ps_product_lang.id_product").
|
||||
Where("ps_product_shop.id_shop = ?", id_shop).
|
||||
Where("ps_product_lang.id_shop = ?", id_shop).
|
||||
Where("ps_product_lang.id_lang = ?", id_lang)
|
||||
q := db.DB.Raw(`
|
||||
SELECT
|
||||
ps_product.id_product AS ID,
|
||||
ps_product_lang.name AS Name,
|
||||
ps_product.active AS Active,
|
||||
ps_product_lang.link_rewrite AS LinkRewrite,
|
||||
COALESCE (
|
||||
ps_image_shop.id_image, any_image.id_image
|
||||
) AS ImageID
|
||||
FROM ps_product
|
||||
LEFT JOIN ps_product_lang
|
||||
ON ps_product_lang.id_product = ps_product.id_product
|
||||
AND ps_product_lang.id_shop = ?
|
||||
AND ps_product_lang.id_lang = ?
|
||||
LEFT JOIN ps_image_shop
|
||||
ON ps_image_shop.id_product = ps_product.id_product
|
||||
AND ps_image_shop.id_shop = ?
|
||||
AND ps_image_shop.cover = 1
|
||||
LEFT JOIN (
|
||||
SELECT id_product, MIN(id_image) AS id_image
|
||||
FROM ps_image
|
||||
GROUP BY id_product
|
||||
) any_image
|
||||
ON ps_product.id_product = any_image.id_product`,
|
||||
id_shop, id_lang, id_shop)
|
||||
|
||||
// var resultIDs []uint
|
||||
// q := db.DB.
|
||||
|
||||
Reference in New Issue
Block a user