Dodanie obsługi punktów Orlen w zamówieniach oraz poprawa logiki i formatowania w różnych plikach
This commit is contained in:
@@ -10,15 +10,22 @@ class Dashboard implements \ArrayAccess
|
||||
try
|
||||
{
|
||||
$redis = \RedisConnection::getInstance() -> getConnection();
|
||||
$objectData = $redis -> get( "summary_ordersd" );
|
||||
|
||||
if ( !$objectData )
|
||||
if ( $redis )
|
||||
{
|
||||
$summary = $mdb -> count( 'pp_shop_orders', [ 'status' => 6 ] );
|
||||
$redis -> setex( "summary_ordersd", 60 * 5, serialize( $summary ) );
|
||||
$objectData = $redis -> get( "summary_ordersd" );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$summary = $mdb -> count( 'pp_shop_orders', [ 'status' => 6 ] );
|
||||
$redis -> setex( "summary_ordersd", 60 * 5, serialize( $summary ) );
|
||||
}
|
||||
else
|
||||
$summary = unserialize( $objectData );
|
||||
}
|
||||
else
|
||||
$summary = unserialize( $objectData );
|
||||
{
|
||||
$summary = $mdb -> count( 'pp_shop_orders', [ 'status' => 6 ] );
|
||||
}
|
||||
}
|
||||
catch ( \RedisException $e )
|
||||
{
|
||||
@@ -35,15 +42,22 @@ class Dashboard implements \ArrayAccess
|
||||
try
|
||||
{
|
||||
$redis = \RedisConnection::getInstance() -> getConnection();
|
||||
$objectData = $redis -> get( "summary_salesd" );
|
||||
|
||||
if ( !$objectData )
|
||||
if ( $redis )
|
||||
{
|
||||
$summary = $mdb -> sum( 'pp_shop_orders', 'summary', [ 'status' => 6 ] ) - $mdb -> sum( 'pp_shop_orders', 'transport_cost', [ 'status' => 6 ] );
|
||||
$redis -> setex( "summary_salesd", 60 * 5, serialize( $summary ) );
|
||||
$objectData = $redis -> get( "summary_salesd" );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$summary = $mdb -> sum( 'pp_shop_orders', 'summary', [ 'status' => 6 ] ) - $mdb -> sum( 'pp_shop_orders', 'transport_cost', [ 'status' => 6 ] );
|
||||
$redis -> setex( "summary_salesd", 60 * 5, serialize( $summary ) );
|
||||
}
|
||||
else
|
||||
$summary = unserialize( $objectData );
|
||||
}
|
||||
else
|
||||
$summary = unserialize( $objectData );
|
||||
{
|
||||
$summary = $mdb -> sum( 'pp_shop_orders', 'summary', [ 'status' => 6 ] ) - $mdb -> sum( 'pp_shop_orders', 'transport_cost', [ 'status' => 6 ] );
|
||||
}
|
||||
}
|
||||
catch ( \RedisException $e )
|
||||
{
|
||||
|
||||
@@ -112,41 +112,50 @@ class Product implements \ArrayAccess
|
||||
* @param string $permutation_hash The permutation hash of the product.
|
||||
* @return \shop\Product The product object.
|
||||
*/
|
||||
public static function getFromCache( $product_id, $lang_id, $permutation_hash = null )
|
||||
public static function getFromCache($product_id, $lang_id, $permutation_hash = null)
|
||||
{
|
||||
// Check if Redis extension is loaded
|
||||
if ( class_exists( 'Redis' ) )
|
||||
if (class_exists('Redis'))
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the Redis connection instance
|
||||
$redis = \RedisConnection::getInstance() -> getConnection();
|
||||
$redis = \RedisConnection::getInstance()->getConnection();
|
||||
|
||||
// Try to retrieve the serialized product object from cache
|
||||
$objectData = $redis -> get( "shop\product:$product_id:$lang_id:$permutation_hash" );
|
||||
|
||||
if ( !$objectData )
|
||||
// Check if Redis connection is valid
|
||||
if ( $redis )
|
||||
{
|
||||
// Product not found in cache, create a new instance and store it in cache
|
||||
$object = new self( $product_id, $lang_id, $permutation_hash );
|
||||
$redis->setex( "shop\product:$product_id:$lang_id:$permutation_hash", 60 * 60 * 24, serialize( $object ) );
|
||||
// Try to retrieve the serialized product object from cache
|
||||
$objectData = $redis->get("shop\product:$product_id:$lang_id:$permutation_hash");
|
||||
|
||||
if (!$objectData)
|
||||
{
|
||||
// Product not found in cache, create a new instance and store it in cache
|
||||
$object = new self($product_id, $lang_id, $permutation_hash);
|
||||
$redis->setex("shop\product:$product_id:$lang_id:$permutation_hash", 60 * 60 * 24, serialize($object));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Product found in cache, unserialize it
|
||||
$object = unserialize($objectData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Product found in cache, unserialize it
|
||||
$object = unserialize( $objectData );
|
||||
// Redis connection failed, create a new instance
|
||||
$object = new self($product_id, $lang_id, $permutation_hash);
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// Log the exception if needed
|
||||
$object = new self( $product_id, $lang_id, $permutation_hash );
|
||||
$object = new self($product_id, $lang_id, $permutation_hash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Redis extension not loaded, create a new instance
|
||||
$object = new self( $product_id, $lang_id, $permutation_hash );
|
||||
$object = new self($product_id, $lang_id, $permutation_hash);
|
||||
}
|
||||
|
||||
return $object;
|
||||
|
||||
@@ -20,16 +20,25 @@ class ProductCustomField implements \ArrayAccess
|
||||
try
|
||||
{
|
||||
$redis = \RedisConnection::getInstance() -> getConnection();
|
||||
$objectData = $redis -> get( "shop\ProductCustomField:$custom_field_id" );
|
||||
|
||||
if ( !$objectData )
|
||||
if ( $redis )
|
||||
{
|
||||
$object = new self( $custom_field_id );
|
||||
$redis -> setex( "shop\ProductCustomField:$custom_field_id", 60 * 60 * 24, serialize( $object ) );
|
||||
$objectData = $redis -> get( "shop\ProductCustomField:$custom_field_id" );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$object = new self( $custom_field_id );
|
||||
$redis -> setex( "shop\ProductCustomField:$custom_field_id", 60 * 60 * 24, serialize( $object ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$object = unserialize( $objectData );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$object = unserialize( $objectData );
|
||||
// Log the error if needed
|
||||
$object = new self( $custom_field_id );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
|
||||
Reference in New Issue
Block a user