ver. 0.271 - ShopAttribute refactor + update package
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopAttribute
|
||||
{
|
||||
static public function attribute_value_tpl()
|
||||
{
|
||||
$html = \Tpl::view( 'shop-attribute/_partials/value', [
|
||||
'i' => \S::get( 'i' ),
|
||||
'value' => \S::get( 'value' ),
|
||||
'languages' => \S::get( 'languages' ),
|
||||
'attribute' => \S::get( 'attribute' ),
|
||||
] );
|
||||
echo $html;
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function values_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania wartości atrybutu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\ShopAttribute::values_save( (int) \S::get( 'attribute_id' ), $values['name'], $values['value'], $values['ids'], $values['default_value'], $values['impact_on_the_price'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Wartości atrybutu zostały zapisane.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function values_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-attribute/values-edit', [
|
||||
'attribute' => \admin\factory\ShopAttribute::attribute_details( (int) \S::get( 'attribute-id' ) ),
|
||||
'values' => \admin\factory\ShopAttribute::get_attribute_values( (int) \S::get( 'attribute-id' ) ),
|
||||
'languages' => ( new \Domain\Languages\LanguagesRepository( $GLOBALS['mdb'] ) )->languagesList()
|
||||
] );
|
||||
}
|
||||
|
||||
public static function delete_attribute()
|
||||
{
|
||||
if ( \admin\factory\ShopAttribute::delete_attribute( (int) \S::get( 'id' ) ) )
|
||||
\S::alert( 'Atrybut został usunięty.' );
|
||||
|
||||
header( 'Location: /admin/shop_attribute/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function attribute_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania atrybutu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\ShopAttribute::attribute_save( (int) $values['id'], $values['name'], $values['status'] == 'on' ? 1 : 0, (int) $values['type'], (int) $values['o'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Atrybut został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function attribute_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-attribute/attribute-edit', [
|
||||
'attribute' => \admin\factory\ShopAttribute::attribute_details( (int) \S::get( 'id' ) ),
|
||||
'languages' => ( new \Domain\Languages\LanguagesRepository( $GLOBALS['mdb'] ) )->languagesList()
|
||||
] );
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view( 'shop-attribute/attributes-list' );
|
||||
}
|
||||
}
|
||||
@@ -373,9 +373,11 @@ class ShopProduct
|
||||
//wyświetlenie kombinacji produktu
|
||||
static public function product_combination()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
return \Tpl::view( 'shop-product/product-combination', [
|
||||
'product' => \admin\factory\ShopProduct::product_details( (int) \S::get( 'product_id' ) ),
|
||||
'attributes' => \admin\factory\ShopAttribute::get_attributes_list(),
|
||||
'attributes' => ( new \Domain\Attribute\AttributeRepository( $mdb ) ) -> getAttributesListForCombinations(),
|
||||
'default_language' => \front\factory\Languages::default_language(),
|
||||
'product_permutations' => \admin\factory\ShopProduct::get_product_permutations( (int) \S::get( 'product_id' ) )
|
||||
] );
|
||||
|
||||
Reference in New Issue
Block a user