Files
shopPRO/autoload/front/controls/class.ShopProduct.php
Jacek Pyziak d29d396197 ver. 0.289: ShopCategory + ShopClient frontend migration to Domain + Views + Controllers
ShopCategory: 9 frontend methods in CategoryRepository, front\Views\ShopCategory (3 methods),
deleted factory + view, updated 6 callers, +17 tests.

ShopClient: 13 frontend methods in ClientRepository, front\Views\ShopClient (8 methods),
front\Controllers\ShopClientController (15 methods + buildEmailBody helper),
deleted factory + view + controls, updated 7 callers, +36 tests.

Security fix: removed hardcoded password bypass 'Legia1916'.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 10:41:40 +01:00

66 lines
1.9 KiB
PHP

<?php
namespace front\controls;
use shop\Product;
class ShopProduct
{
static public function lazy_loading_products()
{
global $lang_id;
$output = '';
$categoryRepo = new \Domain\Category\CategoryRepository( $GLOBALS['mdb'] );
$categoryId = (int)\Shared\Helpers\Helpers::get( 'category_id' );
$products_ids = $categoryRepo->productsId( $categoryId, $categoryRepo->getCategorySort( $categoryId ), $lang_id, 8, (int)\Shared\Helpers\Helpers::get( 'offset' ) );
if ( is_array( $products_ids ) ): foreach ( $products_ids as $product_id ):
$output .= \Shared\Tpl\Tpl::view('shop-product/product-mini', [
'product' => Product::getFromCache( $product_id, $lang_id )
] );
endforeach;
endif;
echo json_encode( [ 'html' => $output ] );
exit;
}
public static function warehouse_message()
{
global $lang_id;
$values = json_decode( \Shared\Helpers\Helpers::get( 'values' ), true );
foreach( $values as $key => $val )
{
if ( $key != 'product-id' and $key != 'quantity' )
$attributes[] = $val;
}
$result = \shop\Product::getWarehouseMessage( $values['product-id'], $attributes, $lang_id );
echo json_encode( $result );
exit;
}
// wyświetlenie atrybutów w widoku produktu
static public function draw_product_attributes()
{
global $mdb, $lang_id;
$combination = '';
$selected_values = \Shared\Helpers\Helpers::get( 'selected_values' );
foreach ( $selected_values as $value ) {
$combination .= $value;
if ( $value != end( $selected_values ) )
$combination .= '|';
}
$product_id = \Shared\Helpers\Helpers::get( 'product_id' );
$product = Product::getFromCache( $product_id, $lang_id );
$product_data = $product -> getProductDataBySelectedAttributes( $combination );
echo json_encode( [ 'product_data' => $product_data ] );
exit;
}
}