Files
shopPRO/autoload/front/factory/class.ShopAttribute.php
Jacek Pyziak 8e97413361 ver. 0.282: Banners frontend migration, Cache cleanup, Shared\Cache namespace
- Banners frontend: front\Views\Banners (new), BannerRepository +2 frontend methods,
  front\view\Site przepięty, usunięte front\factory\Banners i front\view\Banners
- Cache cleanup: eliminacja legacy class.Cache.php (file-based cache),
  13 metod front\factory przepiętych z \Cache::fetch/store na CacheHandler
- Shared\Cache namespace: CacheHandler i RedisConnection przeniesione do Shared\Cache\,
  60 odwołań CacheHandler i 12 odwołań RedisConnection przepiętych,
  usunięte backward-compat wrappery class.CacheHandler.php i class.RedisConnection.php
- Naprawione rozbieżności kluczy cache (random_products, category_name)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 21:25:50 +01:00

52 lines
1.4 KiB
PHP

<?php
namespace front\factory;
class ShopAttribute
{
public static function value_details( $value_id, $lang_id )
{
global $mdb;
$cacheHandler = new \Shared\Cache\CacheHandler();
$cacheKey = "\front\factory\ShopAttribute::value_details:$value_id:$lang_id";
$objectData = $cacheHandler -> get( $cacheKey );
if ( !$objectData )
{
$value = $mdb -> get( 'pp_shop_attributes_values', '*', [ 'id' => (int)$value_id ] );
$value['language'] = $mdb -> get( 'pp_shop_attributes_values_langs', [ 'lang_id', 'name' ], [ 'AND' => [ 'value_id' => (int)$value_id, 'lang_id' => $lang_id ] ] );
$cacheHandler -> set( $cacheKey, $value );
}
else
{
return unserialize( $objectData );
}
return $value;
}
public static function attribute_details( $attribute_id, $lang_id )
{
global $mdb;
$cacheHandler = new \Shared\Cache\CacheHandler();
$cacheKey = 'attribute_details_' . $attribute_id . '_' . $lang_id;
$objectData = $cacheHandler->get( $cacheKey );
if ( !$objectData )
{
$attribute = $mdb -> get( 'pp_shop_attributes', '*', [ 'id' => (int)$attribute_id ] );
$attribute['language'] = $mdb -> get( 'pp_shop_attributes_langs', [ 'lang_id', 'name' ], [ 'AND' => [ 'attribute_id' => (int)$attribute_id, 'lang_id' => $lang_id ] ] );
$cacheHandler->set( $cacheKey, $attribute );
}
else
{
return unserialize( $objectData );
}
return $attribute;
}
}