44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
namespace front\factory;
|
|
|
|
class ShopAttribute
|
|
{
|
|
public static function value_details( $value_id, $lang_id )
|
|
{
|
|
global $mdb;
|
|
|
|
$cacheHandler = new \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;
|
|
|
|
if ( !$attribute = \Cache::fetch( 'attribute_details_' . $attribute_id . '_' . $lang_id ) )
|
|
{
|
|
$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 ] ] );
|
|
|
|
\Cache::store( 'attribute_details_' . $attribute_id . '_' . $lang_id, $attribute );
|
|
}
|
|
return $attribute;
|
|
}
|
|
}
|