Dodanie obsługi dodatkowych danych producenta oraz informacji o bezpieczeństwie w klasach ShopProducer i ShopProduct

This commit is contained in:
2026-01-04 21:22:28 +01:00
parent f955fdbd54
commit 56fab94f47
10 changed files with 158 additions and 104 deletions

View File

@@ -761,7 +761,7 @@ class ShopProduct
}
public static function save(
$product_id, $name, $short_description, $description, $status, $meta_description, $meta_keywords, $seo_link, $copy_from, $categories, $price_netto, $price_brutto, $vat, $promoted, $warehouse_message_zero, $warehouse_message_nonzero, $tab_name_1, $tab_description_1, $tab_name_2, $tab_description_2, $layout_id, $products_related, int $set_id, $price_netto_promo, $price_brutto_promo, $new_to_date, $stock_0_buy, $wp, $custom_label_0, $custom_label_1, $custom_label_2, $custom_label_3, $custom_label_4, $additional_message, int $quantity, $additional_message_text, int $additional_message_required, $canonical, $meta_title, $producer_id, $sku, $ean, $product_unit, $weight, $xml_name, $custom_field_name, $custom_field_required
$product_id, $name, $short_description, $description, $status, $meta_description, $meta_keywords, $seo_link, $copy_from, $categories, $price_netto, $price_brutto, $vat, $promoted, $warehouse_message_zero, $warehouse_message_nonzero, $tab_name_1, $tab_description_1, $tab_name_2, $tab_description_2, $layout_id, $products_related, int $set_id, $price_netto_promo, $price_brutto_promo, $new_to_date, $stock_0_buy, $wp, $custom_label_0, $custom_label_1, $custom_label_2, $custom_label_3, $custom_label_4, $additional_message, int $quantity, $additional_message_text, int $additional_message_required, $canonical, $meta_title, $producer_id, $sku, $ean, $product_unit, $weight, $xml_name, $custom_field_name, $custom_field_required, $security_information
)
{
global $mdb, $user;
@@ -804,27 +804,29 @@ class ShopProduct
if ( $id )
{
foreach ( $name as $key => $val )
$langs = \admin\factory\Languages::languages_list( true );
foreach ( $langs as $lg )
{
$mdb -> insert( 'pp_shop_products_langs', [
'product_id' => (int) $id,
'lang_id' => $key,
'name' => '' !== $name[$key] ? $name[$key] : null,
'short_description' => '' !== $short_description[$key] ? $short_description[$key] : null,
'description' => '' !== $description[$key] ? $description[$key] : null,
'meta_description' => '' !== $meta_description[$key] ? $meta_description[$key] : null,
'meta_keywords' => '' !== $meta_keywords[$key] ? $meta_keywords[$key] : null,
'seo_link' => '' !== \S::seo($seo_link[$key]) ? \S::seo($seo_link[$key]) : null,
'copy_from' => '' !== $copy_from[$key] ? $copy_from[$key] : null,
'warehouse_message_zero' => '' !== $warehouse_message_zero[$key] ? $warehouse_message_zero[$key] : null,
'warehouse_message_nonzero' => '' !== $warehouse_message_nonzero[$key] ? $warehouse_message_nonzero[$key] : null,
'tab_name_1' => '' !== $tab_name_1[$key] ? $tab_name_1[$key] : null,
'tab_description_1' => '' !== $tab_description_1[$key] ? $tab_description_1[$key] : null,
'tab_name_2' => '' !== $tab_name_2[$key] ? $tab_name_2[$key] : null,
'tab_description_2' => '' !== $tab_description_2[$key] ? $tab_description_2[$key] : null,
'canonical' => '' !== $canonical[$key] ? $canonical[$key] : null,
'meta_title' => '' !== $meta_title[$key] ? $meta_title[$key] : null,
'xml_name' => '' !== $xml_name[$key] ? $xml_name[$key] : null,
'lang_id' => $lg['id'],
'name' => $name[$lg['id']] ? $name[$lg['id']] : null,
'short_description' => $short_description[$lg['id']] ? $short_description[$lg['id']] : null,
'description' => $description[$lg['id']] ? $description[$lg['id']] : null,
'meta_description' => $meta_description[$lg['id']] ? $meta_description[$lg['id']] : null,
'meta_keywords' => $meta_keywords[$lg['id']] ? $meta_keywords[$lg['id']] : null,
'seo_link' => $seo_link[$lg['id']] ? \S::seo($seo_link[$lg['id']]) : null,
'copy_from' => $copy_from[$lg['id']] ? $copy_from[$lg['id']] : null,
'warehouse_message_zero' => $warehouse_message_zero[$lg['id']] ? $warehouse_message_zero[$lg['id']] : null,
'warehouse_message_nonzero' => $warehouse_message_nonzero[$lg['id']] ? $warehouse_message_nonzero[$lg['id']] : null,
'tab_name_1' => $tab_name_1[$lg['id']] ? $tab_name_1[$lg['id']] : null,
'tab_description_1' => $tab_description_1[$lg['id']] ? $tab_description_1[$lg['id']] : null,
'tab_name_2' => $tab_name_2[$lg['id']] ? $tab_name_2[$lg['id']] : null,
'tab_description_2' => $tab_description_2[$lg['id']] ? $tab_description_2[$lg['id']] : null,
'canonical' => $canonical[$lg['id']] ? $canonical[$lg['id']] : null,
'meta_title' => $meta_title[$lg['id']] ? $meta_title[$lg['id']] : null,
'xml_name' => $xml_name[$lg['id']] ? $xml_name[$lg['id']] : null,
'security_information' => $security_information[$lg['id']] ? $security_information[$lg['id']] : null,
] );
}
@@ -1007,51 +1009,52 @@ class ShopProduct
\admin\factory\ShopProduct::update_product_combinations_prices( $product_id, $price_brutto, $vat, $price_brutto_promo );
foreach ( $name as $key => $val )
$langs = \admin\factory\Languages::languages_list( true );
foreach ( $langs as $lg )
{
if ( $translation_id = $mdb -> get( 'pp_shop_products_langs', 'id', [ 'AND' => [ 'product_id' => $product_id, 'lang_id' => $key ] ] ) )
if ( $translation_id = $mdb -> get( 'pp_shop_products_langs', 'id', [ 'AND' => [ 'product_id' => $product_id, 'lang_id' => $lg['id'] ] ] ) )
{
$current_seo_link = $mdb -> get( 'pp_shop_products_langs', 'seo_link', [ 'id' => $translation_id ] );
if ( $seo_link[$key] )
$new_seo_link = \S::seo( $seo_link[$key] );
if ( $seo_link[$lg['id']] )
$new_seo_link = \S::seo( $seo_link[$lg['id']] );
else
$new_seo_link = \S::seo( 'p-' . $product_id . '-' . $name[$key] );
$new_seo_link = \S::seo( 'p-' . $product_id . '-' . $name[$lg['id']] );
if ( $new_seo_link !== $current_seo_link and $current_seo_link != '' )
{
if ( !$mdb -> count( 'pp_redirects', [ 'from' => $current_seo_link, 'to' => $new_seo_link, 'lang_id' => $key, 'product_id' => $product_id ] ) )
if ( !$mdb -> count( 'pp_redirects', [ 'from' => $current_seo_link, 'to' => $new_seo_link, 'lang_id' => $lg['id'], 'product_id' => $product_id ] ) )
{
if ( $mdb -> count( 'pp_redirects', [ 'from' => $new_seo_link, 'to' => $current_seo_link, 'lang_id' => $key, 'product_id' => $product_id ] ) )
$mdb -> delete( 'pp_redirects', [ 'from' => $new_seo_link, 'to' => $current_seo_link, 'lang_id' => $key, 'product_id' => $product_id ] );
if ( $mdb -> count( 'pp_redirects', [ 'from' => $new_seo_link, 'to' => $current_seo_link, 'lang_id' => $lg['id'], 'product_id' => $product_id ] ) )
$mdb -> delete( 'pp_redirects', [ 'from' => $new_seo_link, 'to' => $current_seo_link, 'lang_id' => $lg['id'], 'product_id' => $product_id ] );
else
{
if ( \S::canAddRedirect( $current_seo_link, $new_seo_link ) )
$mdb -> insert( 'pp_redirects', [ 'from' => $current_seo_link, 'to' => $new_seo_link, 'lang_id' => $key, 'product_id' => $product_id ] );
$mdb -> insert( 'pp_redirects', [ 'from' => $current_seo_link, 'to' => $new_seo_link, 'lang_id' => $lg['id'], 'product_id' => $product_id ] );
else
$mdb -> delete( 'pp_redirects', [ 'product_id' => $product_id, 'lang_id' => $key ] );
$mdb -> delete( 'pp_redirects', [ 'product_id' => $product_id, 'lang_id' => $lg['id'] ] );
}
}
}
$mdb -> update( 'pp_shop_products_langs', [
'lang_id' => $key,
'name' => '' !== $name[$key] ? $name[$key] : null,
'short_description' => '' !== $short_description[$key] ? $short_description[$key] : null,
'description' => '' !== $description[$key] ? $description[$key] : null,
'meta_description' => '' !== $meta_description[$key] ? $meta_description[$key] : null,
'meta_keywords' => '' !== $meta_keywords[$key] ? $meta_keywords[$key] : null,
'seo_link' => \S::seo( $seo_link[$key] ) != '' ? \S::seo( $seo_link[$key] ) : \S::seo( 'p-' . $product_id . '-' . $name[$key] ),
'copy_from' => '' !== $copy_from[$key] ? $copy_from[$key] : null,
'warehouse_message_zero' => '' !== $warehouse_message_zero[$key] ? $warehouse_message_zero[$key] : null,
'warehouse_message_nonzero' => '' !== $warehouse_message_nonzero[$key] ? $warehouse_message_nonzero[$key] : null,
'tab_name_1' => '' !== $tab_name_1[$key] ? $tab_name_1[$key] : null,
'tab_description_1' => '' !== $tab_description_1[$key] ? $tab_description_1[$key] : null,
'tab_name_2' => '' !== $tab_name_2[$key] ? $tab_name_2[$key] : null,
'tab_description_2' => '' !== $tab_description_2[$key] ? $tab_description_2[$key] : null,
'canonical' => '' !== $canonical[$key] ? $canonical[$key] : null,
'meta_title' => '' !== $meta_title[$key] ? $meta_title[$key] : null,
'xml_name' => '' !== $xml_name[$key] ? $xml_name[$key] : null,
'name' => $name[$lg['id']] ? $name[$lg['id']] : null,
'short_description' => $short_description[$lg['id']] ? $short_description[$lg['id']] : null,
'description' => $description[$lg['id']] ? $description[$lg['id']] : null,
'meta_description' => $meta_description[$lg['id']] ? $meta_description[$lg['id']] : null,
'meta_keywords' => $meta_keywords[$lg['id']] ? $meta_keywords[$lg['id']] : null,
'seo_link' => $seo_link[$lg['id']] ? \S::seo($seo_link[$lg['id']]) : null,
'copy_from' => $copy_from[$lg['id']] ? $copy_from[$lg['id']] : null,
'warehouse_message_zero' => $warehouse_message_zero[$lg['id']] ? $warehouse_message_zero[$lg['id']] : null,
'warehouse_message_nonzero' => $warehouse_message_nonzero[$lg['id']] ? $warehouse_message_nonzero[$lg['id']] : null,
'tab_name_1' => $tab_name_1[$lg['id']] ? $tab_name_1[$lg['id']] : null,
'tab_description_1' => $tab_description_1[$lg['id']] ? $tab_description_1[$lg['id']] : null,
'tab_name_2' => $tab_name_2[$lg['id']] ? $tab_name_2[$lg['id']] : null,
'tab_description_2' => $tab_description_2[$lg['id']] ? $tab_description_2[$lg['id']] : null,
'canonical' => $canonical[$lg['id']] ? $canonical[$lg['id']] : null,
'meta_title' => $meta_title[$lg['id']] ? $meta_title[$lg['id']] : null,
'xml_name' => $xml_name[$lg['id']] ? $xml_name[$lg['id']] : null,
'security_information' => $security_information[$lg['id']] ? $security_information[$lg['id']] : null,
], [
'id' => $translation_id
] );
@@ -1059,24 +1062,25 @@ class ShopProduct
else
{
$mdb -> insert( 'pp_shop_products_langs', [
'product_id' => (int)$product_id,
'lang_id' => $key,
'name' => '' !== $name[$key] ? $name[$key] : null,
'short_description' => '' !== $short_description[$key] ? $short_description[$key] : null,
'description' => '' !== $description[$key] ? $description[$key] : null,
'meta_description' => '' !== $meta_description[$key] ? $meta_description[$key] : null,
'meta_keywords' => '' !== $meta_keywords[$key] ? $meta_keywords[$key] : null,
'seo_link' => '' !== \S::seo($seo_link[$key]) ? \S::seo($seo_link[$key]) : null,
'copy_from' => '' !== $copy_from[$key] ? $copy_from[$key] : null,
'warehouse_message_zero' => '' !== $warehouse_message_zero[$key] ? $warehouse_message_zero[$key] : null,
'warehouse_message_nonzero' => '' !== $warehouse_message_nonzero[$key] ? $warehouse_message_nonzero[$key] : null,
'tab_name_1' => '' !== $tab_name_1[$key] ? $tab_name_1[$key] : null,
'tab_description_1' => '' !== $tab_description_1[$key] ? $tab_description_1[$key] : null,
'tab_name_2' => '' !== $tab_name_2[$key] ? $tab_name_2[$key] : null,
'tab_description_2' => '' !== $tab_description_2[$key] ? $tab_description_2[$key] : null,
'canonical' => '' !== $canonical[$key] ? $canonical[$key] : null,
'meta_title' => '' !== $meta_title[$key] ? $meta_title[$key] : null,
'xml_name' => '' !== $xml_name[$key] ? $xml_name[$key] : null,
'product_id' => (int) $product_id,
'lang_id' => $lg['id'],
'name' => $name[$lg['id']] ? $name[$lg['id']] : null,
'short_description' => $short_description[$lg['id']] ? $short_description[$lg['id']] : null,
'description' => $description[$lg['id']] ? $description[$lg['id']] : null,
'meta_description' => $meta_description[$lg['id']] ? $meta_description[$lg['id']] : null,
'meta_keywords' => $meta_keywords[$lg['id']] ? $meta_keywords[$lg['id']] : null,
'seo_link' => $seo_link[$lg['id']] ? \S::seo($seo_link[$lg['id']]) : null,
'copy_from' => $copy_from[$lg['id']] ? $copy_from[$lg['id']] : null,
'warehouse_message_zero' => $warehouse_message_zero[$lg['id']] ? $warehouse_message_zero[$lg['id']] : null,
'warehouse_message_nonzero' => $warehouse_message_nonzero[$lg['id']] ? $warehouse_message_nonzero[$lg['id']] : null,
'tab_name_1' => $tab_name_1[$lg['id']] ? $tab_name_1[$lg['id']] : null,
'tab_description_1' => $tab_description_1[$lg['id']] ? $tab_description_1[$lg['id']] : null,
'tab_name_2' => $tab_name_2[$lg['id']] ? $tab_name_2[$lg['id']] : null,
'tab_description_2' => $tab_description_2[$lg['id']] ? $tab_description_2[$lg['id']] : null,
'canonical' => $canonical[$lg['id']] ? $canonical[$lg['id']] : null,
'meta_title' => $meta_title[$lg['id']] ? $meta_title[$lg['id']] : null,
'xml_name' => $xml_name[$lg['id']] ? $xml_name[$lg['id']] : null,
'security_information' => $security_information[$lg['id']] ? $security_information[$lg['id']] : null,
] );
}
}