blob: aa554a1bd27daeb23793280cceac7d23cf37235f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php
namespace app\models\market;
use \Registry;
use app\models\market\Market_repository as Market;
class Product_model
{
public static function fromUrl($url, $store = 904)
{
$product = Registry::use('database')->query(
Market::pull('Active_PRODUCT_by:storeID_ProductUrl'),
[
':storeID' => $store,
':ProductUrl' => $url
]
)->getFirst();
// if no product, return false
if ($product === false) return false;
// inject product's images
$product['Images'] = self::getProductImages($product['ID']);
return $product;
}
public static function getProductImages($id)
{
## return Registry::use('database')->runQuery(
## "SELECT a.Url, a.Title, a.Description
## FROM products p
## LEFT JOIN products_to_images p2i ON p2i.SimpleProductID = p.ID
## LEFT JOIN assets a ON a.ID = p2i.ImageID
## WHERE p.IsActive = 1 AND p.Published = 1
## AND p.ID = :id
## ORDER BY p2i.Order",
## [ ':id' => $id ]
## );
return Registry::use('database')->runQuery(
Market::pull('PRODUCT_IMAGES_by:productID'),
['productID' => $id ]
);
}
}
|