| @@ 34-89 (lines=56) @@ | ||
| 31 | * @link https://github.com/techdivision/import |
|
| 32 | * @link http://www.techdivision.com |
|
| 33 | */ |
|
| 34 | class EavAttributeOptionValueRepository extends AbstractRepository |
|
| 35 | { |
|
| 36 | ||
| 37 | /** |
|
| 38 | * The cache for the query results. |
|
| 39 | * |
|
| 40 | * @var array |
|
| 41 | */ |
|
| 42 | protected $cache = array(); |
|
| 43 | ||
| 44 | /** |
|
| 45 | * The prepared statement to load an existing EAV attribute option value by its attribute code, store ID and value. |
|
| 46 | * |
|
| 47 | * @var \PDOStatement |
|
| 48 | */ |
|
| 49 | protected $eavAttributeOptionValueByAttributeCodeAndStoreIdAndValueStmt; |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Initializes the repository's prepared statements. |
|
| 53 | * |
|
| 54 | * @return void |
|
| 55 | */ |
|
| 56 | public function init() |
|
| 57 | { |
|
| 58 | ||
| 59 | // load the utility class name |
|
| 60 | $utilityClassName = $this->getUtilityClassName(); |
|
| 61 | ||
| 62 | // initialize the prepared statements |
|
| 63 | $this->eavAttributeOptionValueByAttributeCodeAndStoreIdAndValueStmt = $this->getConnection()->prepare($utilityClassName::EAV_ATTRIBUTE_OPTION_VALUE_BY_ATTRIBUTE_CODE_AND_STORE_ID_AND_VALUE); |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * Load's and return's the EAV attribute option value with the passed code, store ID and value. |
|
| 68 | * |
|
| 69 | * @param string $attributeCode The code of the EAV attribute option to load |
|
| 70 | * @param integer $storeId The store ID of the attribute option to load |
|
| 71 | * @param string $value The value of the attribute option to load |
|
| 72 | * |
|
| 73 | * @return array The EAV attribute option value |
|
| 74 | */ |
|
| 75 | public function findOneByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value) |
|
| 76 | { |
|
| 77 | ||
| 78 | // the parameters of the EAV attribute option to load |
|
| 79 | $params = array( |
|
| 80 | MemberNames::ATTRIBUTE_CODE => $attributeCode, |
|
| 81 | MemberNames::STORE_ID => $storeId, |
|
| 82 | MemberNames::VALUE => $value |
|
| 83 | ); |
|
| 84 | ||
| 85 | // load and return the EAV attribute option value with the passed parameters |
|
| 86 | $this->eavAttributeOptionValueByAttributeCodeAndStoreIdAndValueStmt->execute($params); |
|
| 87 | return $this->eavAttributeOptionValueByAttributeCodeAndStoreIdAndValueStmt->fetch(\PDO::FETCH_ASSOC); |
|
| 88 | } |
|
| 89 | } |
|
| 90 | ||
| @@ 35-82 (lines=48) @@ | ||
| 32 | * @link https://github.com/techdivision/import |
|
| 33 | * @link http://www.techdivision.com |
|
| 34 | */ |
|
| 35 | class UrlRewriteRepository extends AbstractRepository |
|
| 36 | { |
|
| 37 | ||
| 38 | /** |
|
| 39 | * The prepared statement to load the existing URL rewrites. |
|
| 40 | * |
|
| 41 | * @var \PDOStatement |
|
| 42 | */ |
|
| 43 | protected $urlRewritesStmt; |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Initializes the repository's prepared statements. |
|
| 47 | * |
|
| 48 | * @return void |
|
| 49 | */ |
|
| 50 | public function init() |
|
| 51 | { |
|
| 52 | ||
| 53 | // load the utility class name |
|
| 54 | $utilityClassName = $this->getUtilityClassName(); |
|
| 55 | ||
| 56 | // initialize the prepared statements |
|
| 57 | $this->urlRewritesStmt = $this->getConnection() |
|
| 58 | ->prepare($utilityClassName::URL_REWRITES_BY_ENTITY_TYPE_AND_ENTITY_ID); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Return's an array with the URL rewrites for the passed entity type and ID. |
|
| 63 | * |
|
| 64 | * @param string $entityType The entity type to load the URL rewrites for |
|
| 65 | * @param integer $entityId The entity ID to load the URL rewrites for |
|
| 66 | * |
|
| 67 | * @return array The URL rewrites |
|
| 68 | */ |
|
| 69 | public function findAllByEntityTypeAndEntityId($entityType, $entityId) |
|
| 70 | { |
|
| 71 | ||
| 72 | // initialize the params |
|
| 73 | $params = array( |
|
| 74 | MemberNames::ENTITY_TYPE => $entityType, |
|
| 75 | MemberNames::ENTITY_ID => $entityId |
|
| 76 | ); |
|
| 77 | ||
| 78 | // load and return the URL rewrites |
|
| 79 | $this->urlRewritesStmt->execute($params); |
|
| 80 | return $this->urlRewritesStmt->fetchAll(\PDO::FETCH_ASSOC); |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||