|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Product\Repositories\ProductRepository |
|
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
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/techdivision/import |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Repositories; |
|
22
|
|
|
|
|
23
|
|
|
use TechDivision\Import\Repositories\AbstractRepository; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Repository implementation to load URL rewrite data. |
|
27
|
|
|
* |
|
28
|
|
|
* @author Tim Wagner <[email protected]> |
|
29
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
|
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
31
|
|
|
* @link https://github.com/techdivision/import |
|
32
|
|
|
* @link http://www.techdivision.com |
|
33
|
|
|
*/ |
|
34
|
|
|
class ProductRepository extends AbstractRepository |
|
35
|
|
|
{ |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* The prepared statement to load the existing URL rewrites. |
|
39
|
|
|
* |
|
40
|
|
|
* @var \PDOStatement |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $productStmt; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Initializes the repository's prepared statements. |
|
46
|
|
|
* |
|
47
|
|
|
* @return void |
|
48
|
|
|
*/ |
|
49
|
|
|
public function init() |
|
50
|
|
|
{ |
|
51
|
|
|
|
|
52
|
|
|
// load the utility class name |
|
53
|
|
|
$utilityClassName = $this->getUtilityClassName(); |
|
54
|
|
|
|
|
55
|
|
|
// initialize the prepared statements |
|
56
|
|
|
$this->productStmt = $this->getConnection()->prepare($utilityClassName::PRODUCT); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Return's the product with the passed SKU. |
|
61
|
|
|
* |
|
62
|
|
|
* @param string $sku The SKU of the product to return |
|
63
|
|
|
* |
|
64
|
|
|
* @return array The product |
|
65
|
|
|
*/ |
|
66
|
|
|
public function findOneBySku($sku) |
|
67
|
|
|
{ |
|
68
|
|
|
// load and return the product with the passed SKU |
|
69
|
|
|
$this->productStmt->execute(array($sku)); |
|
70
|
|
|
return $this->productStmt->fetch(\PDO::FETCH_ASSOC); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|