Commit 881d27f 1 parent 38ae801 commit 881d27f Copy full SHA for 881d27f
File tree 3 files changed +84
-1
lines changed
3 files changed +84
-1
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace CustomerFamily \Api \Controller ;
4
+
5
+ use CustomerFamily \Api \Resource \CustomerFamilyProductPrice ;
6
+ use Symfony \Component \HttpFoundation \Request ;
7
+ use Symfony \Component \HttpKernel \Attribute \AsController ;
8
+ use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
9
+ use Thelia \Model \ProductSaleElementsQuery ;
10
+
11
+ #[AsController]
12
+ class CustomerFamilyProductPriceCreateByRef
13
+ {
14
+ public function __construct (
15
+ )
16
+ {
17
+ }
18
+
19
+ public function __invoke (Request $ request )
20
+ {
21
+ $ jsonData = json_decode ($ request ->getContent (), true );
22
+
23
+ $ productSaleElements = ProductSaleElementsQuery::create ()
24
+ ->findOneByRef ($ jsonData ['productSaleElementsRef ' ]);
25
+
26
+ if (!$ productSaleElements ){
27
+ throw new NotFoundHttpException ('NotFound ' );
28
+ }
29
+ /** @var CustomerFamilyProductPrice $customerFamilyProductPriceResource */
30
+ $ customerFamilyProductPriceResource = $ request ->get ('data ' );
31
+
32
+ $ customerFamilyProductPriceResource ->setCustomerFamilyCode ($ jsonData ['customerFamilyCode ' ])
33
+ ->setProductSaleElementsId ($ productSaleElements ->getId ())
34
+ ->setPrice ($ jsonData ['price ' ])
35
+ ->setPromoPrice ($ jsonData ['promoPrice ' ])
36
+ ->setPromo ($ jsonData ['promo ' ]);
37
+
38
+ return $ customerFamilyProductPriceResource ;
39
+
40
+ }
41
+ }
Original file line number Diff line number Diff line change 7
7
use ApiPlatform \Metadata \Get ;
8
8
use ApiPlatform \Metadata \Post ;
9
9
use ApiPlatform \Metadata \Put ;
10
+ use ApiPlatform \OpenApi \Model \Operation ;
11
+ use ApiPlatform \OpenApi \Model \RequestBody ;
12
+ use CustomerFamily \Api \Controller \CustomerFamilyProductPriceCreateByRef ;
10
13
use CustomerFamily \Api \Controller \CustomerFamilyProductPriceUpdateByRef ;
11
14
use CustomerFamily \Api \State \CustomerFamilyPricePersistProcessor ;
12
15
use CustomerFamily \Model \Map \CustomerFamilyProductPriceTableMap ;
22
25
uriTemplate: '/admin/customer_family_product_prices ' ,
23
26
denormalizationContext: ['groups ' => [self ::GROUP_ADMIN_CREATE , self ::GROUP_ADMIN_WRITE ]]
24
27
),
28
+ new Post (
29
+ uriTemplate: '/admin/customer_family_product_prices_by_ref ' ,
30
+ controller: CustomerFamilyProductPriceCreateByRef::class,
31
+ openapi: new Operation (
32
+ requestBody: new RequestBody (
33
+ content: new \ArrayObject ([
34
+ 'application/json ' => [
35
+ 'schema ' => [
36
+ 'type ' => 'object ' ,
37
+ 'properties ' => [
38
+ 'customerFamilyCode ' => [
39
+ 'type ' => 'string ' ,
40
+ 'example ' =>'string '
41
+ ],
42
+ 'productSaleElementsRef ' => [
43
+ 'type ' => 'string ' ,
44
+ 'example ' => 'string '
45
+ ],
46
+ 'price ' => [
47
+ 'type ' => 'number ' ,
48
+ 'format ' => 'float ' ,
49
+ 'example ' => 0.0
50
+ ],
51
+ 'promoPrice ' => [
52
+ 'type ' => 'number ' ,
53
+ 'format ' => 'float ' ,
54
+ 'example ' => 0.0
55
+ ],
56
+ 'promo ' => [
57
+ 'type ' => 'boolean ' ,
58
+ 'example ' => true
59
+ ]
60
+ ]
61
+ ]
62
+ ]
63
+ ])
64
+ )
65
+ ),
66
+ ),
25
67
new Get (
26
68
uriTemplate: '/admin/customer_family_product_prices/{productSaleElementsId}/family/{customerFamilyCode} ' ,
27
69
),
Original file line number Diff line number Diff line change 7
7
<descriptive locale =" fr_FR" >
8
8
<title >Famille de clients et prix d'achat</title >
9
9
</descriptive >
10
- <version >3.1.4 </version >
10
+ <version >3.1.5 </version >
11
11
<author >
12
12
<name >Guillaume Barral / Etienne Perriere</name >
13
13
<email >gbarral@openstudio.fr / eperriere@openstudio.fr</email >
You can’t perform that action at this time.
0 commit comments