| @@ 34-107 (lines=74) @@ | ||
| 31 | * @link https://github.com/techdivision/import |
|
| 32 | * @link http://www.techdivision.com |
|
| 33 | */ |
|
| 34 | class EavAttributeGroupRepository extends AbstractRepository |
|
| 35 | { |
|
| 36 | ||
| 37 | /** |
|
| 38 | * The prepared statement to load a specific attribute group. |
|
| 39 | * |
|
| 40 | * @var \PDOStatement |
|
| 41 | */ |
|
| 42 | protected $eavAttributeGroupStmt; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * The prepared statement to load an attribute group for a specific attribute set ID. |
|
| 46 | * |
|
| 47 | * @var \PDOStatement |
|
| 48 | */ |
|
| 49 | protected $eavAttributeGroupsByAttributeSetIdStmt; |
|
| 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->eavAttributeGroupStmt = $this->getConnection()->prepare($utilityClassName::EAV_ATTRIBUTE_GROUP); |
|
| 64 | $this->eavAttributeGroupsByAttributeSetIdStmt = $this->getConnection()->prepare($utilityClassName::EAV_ATTRIBUTE_GROUPS_BY_ATTRIBUTE_SET_ID); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Return's the EAV attribute group with the passed ID. |
|
| 69 | * |
|
| 70 | * @param integer $id The EAV attribute group ID |
|
| 71 | * |
|
| 72 | * @return array The EAV attribute group |
|
| 73 | */ |
|
| 74 | public function load($id) |
|
| 75 | { |
|
| 76 | ||
| 77 | // execute the prepared statement and return the EAV attribute group with the passed ID |
|
| 78 | $this->eavAttributeGroupStmt->execute(array($id)); |
|
| 79 | return $this->eavAttributeGroupStmt->fetch(\PDO::FETCH_ASSOC); |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * Return's the attribute groups for the passed attribute set ID, whereas the array |
|
| 84 | * is prepared with the attribute group names as keys. |
|
| 85 | * |
|
| 86 | * @param mixed $attributeSetId The EAV attribute set ID to return the attribute groups for |
|
| 87 | * |
|
| 88 | * @return array|boolean The EAV attribute groups for the passed attribute ID |
|
| 89 | */ |
|
| 90 | public function findAllByAttributeSetId($attributeSetId) |
|
| 91 | { |
|
| 92 | ||
| 93 | // initialize the array for the EAV attribute sets |
|
| 94 | $eavAttributeGroups = array(); |
|
| 95 | ||
| 96 | // load the attributes |
|
| 97 | $this->eavAttributeGroupsByAttributeSetIdStmt->execute(array(MemberNames::ATTRIBUTE_SET_ID => $attributeSetId)); |
|
| 98 | ||
| 99 | // prepare the array with the attribute group names as keys |
|
| 100 | foreach ($this->eavAttributeGroupsByAttributeSetIdStmt->fetchAll(\PDO::FETCH_ASSOC) as $eavAttributeGroup) { |
|
| 101 | $eavAttributeGroups[$eavAttributeGroup[MemberNames::ATTRIBUTE_GROUP_NAME]] = $eavAttributeGroup; |
|
| 102 | } |
|
| 103 | ||
| 104 | // return the array with the EAV attribute groups |
|
| 105 | return $eavAttributeGroups; |
|
| 106 | } |
|
| 107 | } |
|
| 108 | ||
| @@ 34-107 (lines=74) @@ | ||
| 31 | * @link https://github.com/techdivision/import |
|
| 32 | * @link http://www.techdivision.com |
|
| 33 | */ |
|
| 34 | class EavAttributeSetRepository extends AbstractRepository |
|
| 35 | { |
|
| 36 | ||
| 37 | /** |
|
| 38 | * The prepared statement to load a specific attribute set. |
|
| 39 | * |
|
| 40 | * @var \PDOStatement |
|
| 41 | */ |
|
| 42 | protected $eavAttributeSetStmt; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * The prepared statement to load an attribute set for a specific entity type ID. |
|
| 46 | * |
|
| 47 | * @var \PDOStatement |
|
| 48 | */ |
|
| 49 | protected $eavAttributeSetsByEntityTypeIdStmt; |
|
| 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->eavAttributeSetStmt = $this->getConnection()->prepare($utilityClassName::EAV_ATTRIBUTE_SET); |
|
| 64 | $this->eavAttributeSetsByEntityTypeIdStmt = $this->getConnection()->prepare($utilityClassName::EAV_ATTRIBUTE_SETS_BY_ENTITY_TYPE_ID); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Return's the EAV attribute set with the passed ID. |
|
| 69 | * |
|
| 70 | * @param integer $id The EAV attribute set ID |
|
| 71 | * |
|
| 72 | * @return array The attribute set |
|
| 73 | */ |
|
| 74 | public function load($id) |
|
| 75 | { |
|
| 76 | ||
| 77 | // execute the prepared statement and return the EAV attribute set with the passed ID |
|
| 78 | $this->eavAttributeSetStmt->execute(array($id)); |
|
| 79 | return $this->eavAttributeSetStmt->fetch(\PDO::FETCH_ASSOC); |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * Return's the attribute sets for the passed entity type ID, whereas the array |
|
| 84 | * is prepared with the attribute set names as keys. |
|
| 85 | * |
|
| 86 | * @param mixed $entityTypeId The entity type ID to return the attribute sets for |
|
| 87 | * |
|
| 88 | * @return array|boolean The attribute sets for the passed entity type ID |
|
| 89 | */ |
|
| 90 | public function findAllByEntityTypeId($entityTypeId) |
|
| 91 | { |
|
| 92 | ||
| 93 | // initialize the array for the attribute sets |
|
| 94 | $eavAttributeSets = array(); |
|
| 95 | ||
| 96 | // load the attributes |
|
| 97 | $this->eavAttributeSetsByEntityTypeIdStmt->execute(array($entityTypeId)); |
|
| 98 | ||
| 99 | // prepare the array with the attribute set names as keys |
|
| 100 | foreach ($this->eavAttributeSetsByEntityTypeIdStmt->fetchAll(\PDO::FETCH_ASSOC) as $eavAttributeSet) { |
|
| 101 | $eavAttributeSets[$eavAttributeSet[MemberNames::ATTRIBUTE_SET_NAME]] = $eavAttributeSet; |
|
| 102 | } |
|
| 103 | ||
| 104 | // return the array with the attribute sets |
|
| 105 | return $eavAttributeSets; |
|
| 106 | } |
|
| 107 | } |
|
| 108 | ||