|
@@ 207-241 (lines=35) @@
|
| 204 |
|
* @deprecated Since 2.0.2, because multiple attributes with the same attribute code, but differenct entity type code can be available |
| 205 |
|
* @see \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface::findOneByEntityTypeIdAndAttributeCodeAndStoreIdAndValue() |
| 206 |
|
*/ |
| 207 |
|
public function findOneByAttributeCodeAndStoreIdAndValue($attributeCode, $storeId, $value) |
| 208 |
|
{ |
| 209 |
|
|
| 210 |
|
// the parameters of the EAV attribute option to load |
| 211 |
|
$params = array( |
| 212 |
|
MemberNames::ATTRIBUTE_CODE => $attributeCode, |
| 213 |
|
MemberNames::STORE_ID => $storeId, |
| 214 |
|
MemberNames::VALUE => $value |
| 215 |
|
); |
| 216 |
|
|
| 217 |
|
// prepare the cache key |
| 218 |
|
$cacheKey = $this->cacheAdapter->cacheKey(SqlStatementKeys::EAV_ATTRIBUTE_OPTION_VALUE_BY_ATTRIBUTE_CODE_AND_STORE_ID_AND_VALUE, $params); |
| 219 |
|
|
| 220 |
|
// return the cached result if available |
| 221 |
|
if ($this->cacheAdapter->isCached($cacheKey)) { |
| 222 |
|
return $this->cacheAdapter->fromCache($cacheKey); |
| 223 |
|
} |
| 224 |
|
|
| 225 |
|
// load the EAV attribute option value with the passed parameters |
| 226 |
|
$this->eavAttributeOptionValueByAttributeCodeAndStoreIdAndValueStmt->execute($params); |
| 227 |
|
|
| 228 |
|
// query whether or not the result has been cached |
| 229 |
|
if ($eavAttributeOptionValue = $this->eavAttributeOptionValueByAttributeCodeAndStoreIdAndValueStmt->fetch(\PDO::FETCH_ASSOC)) { |
| 230 |
|
// prepare the unique cache key for the EAV attribute option value |
| 231 |
|
$uniqueKey = $this->cacheAdapter->cacheKey( |
| 232 |
|
EavAttributeOptionValueRepositoryInterface::class, |
| 233 |
|
array($eavAttributeOptionValue[$this->getPrimaryKeyName()]) |
| 234 |
|
); |
| 235 |
|
// add the EAV attribute option value to the cache, register the cache key reference as well |
| 236 |
|
$this->cacheAdapter->toCache($cacheKey, $eavAttributeOptionValue, array($cacheKey => $uniqueKey)); |
| 237 |
|
} |
| 238 |
|
|
| 239 |
|
// finally, return it |
| 240 |
|
return $eavAttributeOptionValue; |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
/** |
| 244 |
|
* Load's and return's the EAV attribute option value with the passed entity type ID, code, store ID and value. |
|
@@ 253-288 (lines=36) @@
|
| 250 |
|
* |
| 251 |
|
* @return array The EAV attribute option value |
| 252 |
|
*/ |
| 253 |
|
public function findOneByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value) |
| 254 |
|
{ |
| 255 |
|
|
| 256 |
|
// the parameters of the EAV attribute option to load |
| 257 |
|
$params = array( |
| 258 |
|
MemberNames::ENTITY_TYPE_ID => $entityTypeId, |
| 259 |
|
MemberNames::ATTRIBUTE_CODE => $attributeCode, |
| 260 |
|
MemberNames::STORE_ID => $storeId, |
| 261 |
|
MemberNames::VALUE => $value |
| 262 |
|
); |
| 263 |
|
|
| 264 |
|
// prepare the cache key |
| 265 |
|
$cacheKey = $this->cacheAdapter->cacheKey(SqlStatementKeys::EAV_ATTRIBUTE_OPTION_VALUE_BY_ENTITY_TYPE_ID_AND_ATTRIBUTE_CODE_AND_STORE_ID_AND_VALUE, $params); |
| 266 |
|
|
| 267 |
|
// return the cached result if available |
| 268 |
|
if ($this->cacheAdapter->isCached($cacheKey)) { |
| 269 |
|
return $this->cacheAdapter->fromCache($cacheKey); |
| 270 |
|
} |
| 271 |
|
|
| 272 |
|
// load the EAV attribute option value with the passed parameters |
| 273 |
|
$this->eavAttributeOptionValueByEntityTypeIdAndAttributeCodeAndStoreIdAndValueStmt->execute($params); |
| 274 |
|
|
| 275 |
|
// query whether or not the result has been cached |
| 276 |
|
if ($eavAttributeOptionValue = $this->eavAttributeOptionValueByEntityTypeIdAndAttributeCodeAndStoreIdAndValueStmt->fetch(\PDO::FETCH_ASSOC)) { |
| 277 |
|
// prepare the unique cache key for the EAV attribute option value |
| 278 |
|
$uniqueKey = $this->cacheAdapter->cacheKey( |
| 279 |
|
EavAttributeOptionValueRepositoryInterface::class, |
| 280 |
|
array($eavAttributeOptionValue[$this->getPrimaryKeyName()]) |
| 281 |
|
); |
| 282 |
|
// add the EAV attribute option value to the cache, register the cache key reference as well |
| 283 |
|
$this->cacheAdapter->toCache($cacheKey, $eavAttributeOptionValue, array($cacheKey => $uniqueKey)); |
| 284 |
|
} |
| 285 |
|
|
| 286 |
|
// finally, return it |
| 287 |
|
return $eavAttributeOptionValue; |
| 288 |
|
} |
| 289 |
|
} |
| 290 |
|
|