- Migrate class.S → Shared\Helpers\Helpers (140+ files), remove 12 unused methods - Migrate class.Html → Shared\Html\Html - Migrate class.Email → Shared\Email\Email - Migrate class.Image → Shared\Image\ImageManipulator - Delete class.Log (unused), class.Mobile_Detect (outdated UA detection) - Remove grid library loading from admin (index.php, ajax.php) - Replace gridEdit usage in 10 admin templates with grid-edit-replacement.php - Fix grid-edit-replacement.php AJAX to send values as JSON (grid.js compat) - Remove mobile layout conditionals (m_html/m_css/m_js) from Site + LayoutsRepository - Remove \Log::save_log() calls from OrderAdminService, ShopOrder, Order Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
namespace shop;
|
|
|
|
class ProductCustomField implements \ArrayAccess
|
|
{
|
|
public function __construct( int $custom_field_id )
|
|
{
|
|
global $mdb;
|
|
|
|
$result = $mdb -> get( 'pp_shop_products_custom_fields', '*', [ 'id_additional_field' => $custom_field_id ] );
|
|
if ( \Shared\Helpers\Helpers::is_array_fix( $result ) ) foreach ( $result as $key => $val )
|
|
$this -> $key = $val;
|
|
}
|
|
|
|
static public function getFromCache( int $custom_field_id )
|
|
{
|
|
// Check if Redis extension is loaded
|
|
if ( class_exists( 'Redis' ) )
|
|
{
|
|
try
|
|
{
|
|
$redis = \Shared\Cache\RedisConnection::getInstance() -> getConnection();
|
|
|
|
if ( $redis )
|
|
{
|
|
$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
|
|
{
|
|
// Log the error if needed
|
|
$object = new self( $custom_field_id );
|
|
}
|
|
}
|
|
catch ( \Exception $e )
|
|
{
|
|
// Log the exception if needed
|
|
$object = new self( $custom_field_id );
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Redis extension not loaded, create a new instance
|
|
$object = new self( $custom_field_id );
|
|
}
|
|
|
|
return $object;
|
|
}
|
|
|
|
public function offsetExists($offset) {
|
|
return isset($this->$offset);
|
|
}
|
|
|
|
public function offsetGet($offset) {
|
|
return $this->$offset;
|
|
}
|
|
|
|
public function offsetSet($offset , $value) {
|
|
$this->$offset = $value;
|
|
}
|
|
|
|
public function offsetUnset($offset) {
|
|
unset($this->$offset);
|
|
}
|
|
} |