ver. 0.294: Remove all 12 legacy autoload/shop/ classes (~2363 lines)
Complete Domain-Driven Architecture migration: - Phase 1-4: Transport, ProductSet, Coupon, Shop, Search, Basket, ProductCustomField, Category, ProductAttribute, Promotion - Phase 5: Order (~562 lines) + Product (~952 lines) - ~20 Product methods migrated to ProductRepository - Apilo sync migrated to OrderAdminService - Production hotfixes: stale Redis cache (prices 0.00), unqualified Product:: refs in LayoutEngine, object->array template conversion - AttributeRepository::getAttributeValueById() Redis cache added Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -484,7 +484,16 @@ class AttributeRepository
|
||||
}
|
||||
|
||||
$languageId = $langId !== null && trim($langId) !== '' ? trim($langId) : $this->defaultLanguageId();
|
||||
return (string)$this->db->get(
|
||||
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "AttributeRepository::getAttributeValueById:{$valueId}:{$languageId}";
|
||||
$cached = $cacheHandler->get($cacheKey);
|
||||
|
||||
if ($cached !== false && $cached !== null) {
|
||||
return (string)unserialize($cached);
|
||||
}
|
||||
|
||||
$name = (string)$this->db->get(
|
||||
'pp_shop_attributes_values_langs',
|
||||
'name',
|
||||
[
|
||||
@@ -494,6 +503,10 @@ class AttributeRepository
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$cacheHandler->set($cacheKey, $name);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -939,4 +952,66 @@ class AttributeRepository
|
||||
{
|
||||
return round($value, $precision);
|
||||
}
|
||||
|
||||
public function isValueDefault(int $valueId)
|
||||
{
|
||||
if ($valueId <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "attr_value_default:{$valueId}";
|
||||
$cached = $cacheHandler->get($cacheKey);
|
||||
|
||||
if ($cached) {
|
||||
return unserialize($cached);
|
||||
}
|
||||
|
||||
$isDefault = $this->db->get('pp_shop_attributes_values', 'is_default', ['id' => $valueId]);
|
||||
$cacheHandler->set($cacheKey, $isDefault);
|
||||
|
||||
return $isDefault;
|
||||
}
|
||||
|
||||
public function getAttributeOrder(int $attributeId)
|
||||
{
|
||||
if ($attributeId <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "attr_order:{$attributeId}";
|
||||
$cached = $cacheHandler->get($cacheKey);
|
||||
|
||||
if ($cached) {
|
||||
return unserialize($cached);
|
||||
}
|
||||
|
||||
$order = $this->db->get('pp_shop_attributes', 'o', ['id' => $attributeId]);
|
||||
$cacheHandler->set($cacheKey, $order);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
public function getAttributeNameByValue(int $valueId, string $langId)
|
||||
{
|
||||
if ($valueId <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$stmt = $this->db->query(
|
||||
'SELECT name FROM pp_shop_attributes_langs AS psal '
|
||||
. 'INNER JOIN pp_shop_attributes_values AS psav ON psal.attribute_id = psav.attribute_id '
|
||||
. 'WHERE psav.id = :value_id AND lang_id = :lang_id',
|
||||
[':value_id' => $valueId, ':lang_id' => $langId]
|
||||
);
|
||||
|
||||
if (!$stmt) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||
|
||||
return is_array($row) ? ($row['name'] ?? null) : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user