Files
pomysloweprezenty.pl/autoload/admin/factory/class.ShopProducer.php
Jacek Pyziak 33c997ce0d feat: Enhance product saving functionality with security information and language support
- Added `security_information` parameter to `ShopProduct::save` method.
- Refactored language handling in product saving to utilize `Languages::languages_list`.
- Updated SEO link handling to ensure proper redirection and canonical URLs.
- Improved error handling and logging during the update process in `Update` class.
- Enhanced producer and product classes to include additional language data.
- Updated version to 0.233 and added update logs for better tracking.
2026-01-27 23:46:36 +01:00

89 lines
2.3 KiB
PHP

<?
namespace admin\factory;
class ShopProducer
{
static public function all()
{
global $mdb;
return $mdb -> select( 'pp_shop_producer', '*', [ 'ORDER' => [ 'name' => 'ASC' ] ] );
}
static public function delete( int $producer_id )
{
global $mdb;
return $mdb -> delete( 'pp_shop_producer', [ 'id' => $producer_id ] );
}
static public function save( $producer_id, $name, int $status, $img, $description, $data, $meta_title )
{
global $mdb;
if ( !$producer_id )
{
$mdb -> insert( 'pp_shop_producer', [
'name' => $name,
'status' => $status,
'img' => $img
] );
$id = $mdb -> id();
$langs = \admin\factory\Languages::languages_list( true );
foreach ( $langs as $lg )
{
$mdb -> insert( 'pp_shop_producer_lang', [
'producer_id' => $id,
'lang_id' => $lg['id'],
'description' => $description[ $lg['id'] ] ?? null,
'data' => $data[ $lg['id'] ] ?? null,
'meta_title' => $meta_title[ $lg['id'] ] ?? null
] );
}
\S::htacces();
\S::delete_dir( '../temp/' );
return $id;
}
else
{
$mdb -> update( 'pp_shop_producer', [
'name' => $name,
'status' => $status,
'img' => $img
], [
'id' => (int) $producer_id
] );
$langs = \admin\factory\Languages::languages_list( true );
foreach ( $langs as $lg )
{
if ( $translation_id = $mdb -> get( 'pp_shop_producer_lang', 'id', [ 'AND' => [ 'producer_id' => $producer_id, 'lang_id' => $lg['id'] ] ] ) )
{
$mdb -> update( 'pp_shop_producer_lang', [
'description' => $description[ $lg['id'] ] ?? null,
'meta_title' => $meta_title[ $lg['id'] ] ?? null,
'data' => $data[ $lg['id'] ] ?? null
], [
'id' => $translation_id
] );
}
else
{
$mdb -> insert( 'pp_shop_producer_lang', [
'producer_id' => $producer_id,
'lang_id' => $lg['id'],
'description' => $description[ $lg['id'] ] ?? null,
'data' => $data[ $lg['id'] ] ?? null,
'meta_title' => $meta_title[ $lg['id'] ] ?? null
] );
}
}
\S::htacces();
\S::delete_dir( '../temp/' );
return $producer_id;
}
return false;
}
}