|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Product\Magic360\Repositories\ProductMagic360GalleryRepository |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @author Bernhard Wick <[email protected]> |
|
16
|
|
|
* @copyright 2017 TechDivision GmbH <[email protected]> |
|
17
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
18
|
|
|
* @link https://github.com/techdivision/import-product-magic360 |
|
19
|
|
|
* @link http://www.techdivision.com |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
namespace TechDivision\Import\Product\Magic360\Repositories; |
|
23
|
|
|
|
|
24
|
|
|
use TechDivision\Import\Repositories\AbstractRepository; |
|
25
|
|
|
use TechDivision\Import\Product\Magic360\Utils\ParamNames; |
|
26
|
|
|
use TechDivision\Import\Product\Magic360\Utils\SqlStatementKeys; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Repository implementation to load product media gallery data. |
|
30
|
|
|
* |
|
31
|
|
|
* @author Tim Wagner <[email protected]> |
|
32
|
|
|
* @author Bernhard Wick <[email protected]> |
|
33
|
|
|
* @copyright 2017 TechDivision GmbH <[email protected]> |
|
34
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
35
|
|
|
* @link https://github.com/techdivision/import-product-magic360 |
|
36
|
|
|
* @link http://www.techdivision.com |
|
37
|
|
|
*/ |
|
38
|
|
|
class ProductMagic360GalleryRepository extends AbstractRepository implements ProductMagic360GalleryRepositoryInterface |
|
39
|
|
|
{ |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* The prepared statement to load an existing product media gallery entity. |
|
43
|
|
|
* |
|
44
|
|
|
* @var \PDOStatement |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $statement; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Initializes the repository's prepared statements. |
|
50
|
|
|
* |
|
51
|
|
|
* @return void |
|
52
|
|
|
*/ |
|
53
|
|
|
public function init() |
|
54
|
|
|
{ |
|
55
|
|
|
|
|
56
|
|
|
// initialize the prepared statements |
|
57
|
|
|
$this->statement = |
|
58
|
|
|
$this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::MAGIC360_GALLERY)); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Load's the product media gallery with the passed attribute ID + value. |
|
63
|
|
|
* |
|
64
|
|
|
* @param integer $productId The attribute ID of the product media gallery to load |
|
65
|
|
|
* @param integer $position The value of the product media gallery to load |
|
66
|
|
|
* |
|
67
|
|
|
* @return array The product media gallery |
|
68
|
|
|
*/ |
|
69
|
|
|
public function findOneByProductIdAndPosition($productId, $position) |
|
70
|
|
|
{ |
|
71
|
|
|
|
|
72
|
|
|
// initialize the parameters |
|
73
|
|
|
$params = array( |
|
74
|
|
|
ParamNames::POSITION => $position, |
|
75
|
|
|
ParamNames::PRODUCT_ID => $productId |
|
76
|
|
|
); |
|
77
|
|
|
|
|
78
|
|
|
// load and return the product media gallery with the passed attribute ID + value |
|
79
|
|
|
$this->statement->execute($params); |
|
80
|
|
|
return $this->statement->fetch(\PDO::FETCH_ASSOC); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|