ver. 0.294: Remove all 12 legacy autoload/shop/ classes (~2363 lines)
Complete Domain-Driven Architecture migration: - Phase 1-4: Transport, ProductSet, Coupon, Shop, Search, Basket, ProductCustomField, Category, ProductAttribute, Promotion - Phase 5: Order (~562 lines) + Product (~952 lines) - ~20 Product methods migrated to ProductRepository - Apilo sync migrated to OrderAdminService - Production hotfixes: stale Redis cache (prices 0.00), unqualified Product:: refs in LayoutEngine, object->array template conversion - AttributeRepository::getAttributeValueById() Redis cache added Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,9 +24,10 @@ class ShopProductController
|
||||
(int)\Shared\Helpers\Helpers::get( 'offset' )
|
||||
);
|
||||
|
||||
$productRepo = new \Domain\Product\ProductRepository( $GLOBALS['mdb'] );
|
||||
if ( is_array( $products_ids ) ): foreach ( $products_ids as $product_id ):
|
||||
$output .= \Shared\Tpl\Tpl::view( 'shop-product/product-mini', [
|
||||
'product' => \shop\Product::getFromCache( $product_id, $lang_id )
|
||||
'product' => $productRepo->findCached( $product_id, $lang_id )
|
||||
] );
|
||||
endforeach;
|
||||
endif;
|
||||
@@ -48,7 +49,29 @@ class ShopProductController
|
||||
$attributes[] = $val;
|
||||
}
|
||||
|
||||
$result = \shop\Product::getWarehouseMessage( $values['product-id'], $attributes, $lang_id );
|
||||
$productRepo = new \Domain\Product\ProductRepository( $GLOBALS['mdb'] );
|
||||
$permutation = self::getPermutation( $attributes );
|
||||
$quantity = self::getPermutationQuantity( $values['product-id'], $permutation );
|
||||
global $settings;
|
||||
|
||||
$result = [];
|
||||
if ( $quantity )
|
||||
{
|
||||
$msg = $productRepo->getWarehouseMessageNonzero( (int)$values['product-id'], $lang_id );
|
||||
if ( $msg )
|
||||
$result = [ 'msg' => $msg, 'quantity' => $quantity ];
|
||||
else if ( isset( $settings[ 'warehouse_message_nonzero_' . $lang_id ] ) && $settings[ 'warehouse_message_nonzero_' . $lang_id ] )
|
||||
$result = [ 'msg' => $settings[ 'warehouse_message_nonzero_' . $lang_id ], 'quantity' => $quantity ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = $productRepo->getWarehouseMessageZero( (int)$values['product-id'], $lang_id );
|
||||
if ( $msg )
|
||||
$result = [ 'msg' => $msg, 'quantity' => $quantity ];
|
||||
else if ( isset( $settings[ 'warehouse_message_zero_' . $lang_id ] ) && $settings[ 'warehouse_message_zero_' . $lang_id ] )
|
||||
$result = [ 'msg' => $settings[ 'warehouse_message_zero_' . $lang_id ], 'quantity' => $quantity ];
|
||||
}
|
||||
|
||||
echo json_encode( $result );
|
||||
exit;
|
||||
}
|
||||
@@ -68,10 +91,26 @@ class ShopProductController
|
||||
}
|
||||
|
||||
$product_id = \Shared\Helpers\Helpers::get( 'product_id' );
|
||||
$product = \shop\Product::getFromCache( $product_id, $lang_id );
|
||||
$product_data = $product->getProductDataBySelectedAttributes( $combination );
|
||||
$productRepo = new \Domain\Product\ProductRepository( $GLOBALS['mdb'] );
|
||||
$product = $productRepo->findCached( $product_id, $lang_id );
|
||||
$product_data = $productRepo->getProductDataBySelectedAttributes( $product, $combination );
|
||||
|
||||
echo json_encode( [ 'product_data' => $product_data ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
private static function getPermutation( $attributes )
|
||||
{
|
||||
if ( !is_array( $attributes ) || !count( $attributes ) ) return null;
|
||||
return implode( '|', $attributes );
|
||||
}
|
||||
|
||||
private static function getPermutationQuantity( $productId, $permutation )
|
||||
{
|
||||
global $mdb;
|
||||
if ( !$permutation ) return $mdb->get( 'pp_shop_products', 'quantity', [ 'id' => $productId ] );
|
||||
$qty = $mdb->get( 'pp_shop_products', 'quantity', [ 'AND' => [ 'parent_id' => $productId, 'permutation_hash' => $permutation ] ] );
|
||||
if ( $qty !== null ) return $qty;
|
||||
return $mdb->get( 'pp_shop_products', 'quantity', [ 'id' => $productId ] );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user