Skip to content

Commit 7dd9996

Browse files
committed
Merged in develop (pull request #14)
APITOCART-13774 changes mentioned in feedback
2 parents 46e0045 + fb67faf commit 7dd9996

File tree

16 files changed

+202
-125
lines changed

16 files changed

+202
-125
lines changed

src/.phpstorm.meta.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/**
77
* PhpStorm Meta file, to provide autocomplete information for PhpStorm
8-
* Generated on 2020-06-19 07:28:47.
8+
* Generated on 2020-06-23 06:16:36.
99
*
1010
* @author Barry vd. Heuvel <[email protected]>
1111
* @see https://github.com/barryvdh/laravel-ide-helper

src/_ide_helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/**
55
* A helper file for Laravel, to provide autocomplete information to your IDE
6-
* Generated for Laravel 7.16.1 on 2020-06-19 07:28:46.
6+
* Generated for Laravel 7.16.1 on 2020-06-23 06:16:35.
77
*
88
* This file should not be included in your code, only analyzed by your IDE!
99
*

src/app/Http/Controllers/CategoriesController.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function categoryList($store_id = null, Request $request)
4949
foreach ($newRes as $item){
5050
$newItem = $item;
5151
$newItem['cart_id'] = $storeInfo['cart_id'];
52+
if ( !isset($newItem['parent_id']) ) $newItem['parent_id'] = 0;
5253
$items->push( $newItem );
5354
}
5455
}
@@ -63,6 +64,7 @@ public function categoryList($store_id = null, Request $request)
6364
foreach ($newRes as $item){
6465
$newItem = $item;
6566
$newItem['cart_id'] = $storeInfo['cart_id'];
67+
if ( !isset($newItem['parent_id']) ) $newItem['parent_id'] = 0;
6668
$items->push( $newItem );
6769
}
6870
}
@@ -74,12 +76,12 @@ public function categoryList($store_id = null, Request $request)
7476
}
7577

7678

77-
$tree = $this->buildTree( $items->toArray() );
79+
$tree = $this->buildTree( $items->sortBy('id')->toArray() );
7880

7981
$items = $items->map(function ($item, $key) use ($tree) {
8082
$newItem = $item;
8183
$result = array();
82-
if ( intval($item['parent_id']) ){
84+
if ( isset($item['parent_id']) && intval($item['parent_id']) ){
8385
$this->buildBreadcrumb( $tree, $item['id'], $result);
8486
}
8587
$newItem['parent_name'] = implode(" >> ",array_reverse($result));
@@ -88,7 +90,6 @@ public function categoryList($store_id = null, Request $request)
8890

8991

9092

91-
9293
$data = [
9394
"recordsTotal" => $totalItems,
9495
"recordsFiltered" => $totalItems,
@@ -166,8 +167,8 @@ private function buildTree(array $elements, $parentId = 0)
166167

167168
$branch = array();
168169

169-
foreach ($elements as $element) {
170-
if ($element['parent_id'] == $parentId) {
170+
foreach ($elements as $k=>$element) {
171+
if (isset($element['parent_id']) && $element['parent_id'] == $parentId) {
171172
$children = $this->buildTree($elements, $element['id']);
172173
if ($children) {
173174
$element['children'] = $children;

src/app/Http/Controllers/OrdersController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function orderList($store_id=null,Request $request)
4646

4747
if ( $totalOrders ){
4848

49-
$result = $this->api2cart->getOrderList( $store_id, null,null, null, $created_from );
49+
$result = $this->api2cart->getOrderList( $store_id, null, null, null, $created_from );
5050

5151
$newOrders = (isset($result['result']['orders_count'])) ? collect( $result['result']['order'] ) : collect([]);
5252
// put additional information

src/app/Http/Controllers/StoresController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function storeList(Request $request)
3636
$carts = collect($this->api2cart->getCartList());
3737
$allCarts = collect($this->api2cart->getCartsList());
3838

39+
// Log::debug( print_r($allCarts,1));
3940
// if ( !$carts->count() || !$allCarts->count() ) return response()->json([],404);
4041

4142

src/app/Services/Api2Cart.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ public function getOrderStatuses( $store_id=null )
631631

632632
}
633633

634-
public function getOrderList( $store_id=null , $sort_by=null, $sort_direct=null, $limit=null, $created_from=null )
634+
public function getOrderList( $store_id=null , $sort_by=null, $sort_direct=null, $limit=10, $created_from=null )
635635
{
636636
$this->setApiKey();
637637

@@ -644,6 +644,7 @@ public function getOrderList( $store_id=null , $sort_by=null, $sort_direct=null,
644644
null,
645645
null,
646646
null,
647+
null,
647648
$limit,
648649
null,
649650
$sort_by,
@@ -664,6 +665,7 @@ public function getOrderList( $store_id=null , $sort_by=null, $sort_direct=null,
664665
null,
665666
null,
666667
null,
668+
null,
667669
null
668670
);
669671

@@ -696,7 +698,19 @@ public function getOrderListPage( $store_id=null, $page_cursor=null )
696698

697699
$this->order->getConfig()->setApiKey('store_key', $store_id);
698700

699-
$result = $this->order->orderList( null, null, null, null, null, $page_cursor, null, null, 'force_all' );
701+
$result = $this->order->orderList(
702+
null,
703+
null,
704+
null,
705+
null,
706+
null,
707+
null,
708+
$page_cursor,
709+
null,
710+
null,
711+
'force_all',
712+
null
713+
);
700714

701715
$this->logApiCall( 'order.list.json', $result->getReturnCode(), $this->order->getConfig(), null, null, null, $result->getReturnMessage() ,['page_cursor' => $page_cursor] );
702716

@@ -830,7 +844,7 @@ public function getProductList($store_id=null, $ids=null, $sort_by=null, $sort_d
830844
null,
831845
null,
832846
$limit,
833-
'id,name,description,price,categories_ids,images,u_sku,type,create_at,modify_at',
847+
'id,name,description,price,categories_ids,images,u_sku,type,create_at,modify_at,quantity',
834848
null,
835849
null,
836850
$created_from,
@@ -883,7 +897,7 @@ public function getProductListPage( $store_id=null, $page_cursor=null )
883897
$page_cursor,
884898
null,
885899
null,
886-
'id,name,description,price,categories_ids,images,u_sku,type,create_at,modify_at',
900+
'id,name,description,price,categories_ids,images,u_sku,type,create_at,modify_at,quantity',
887901
null,
888902
null,
889903
null,
@@ -1392,14 +1406,18 @@ private function logApiCall( $action=null, $code=null, $config = null, $store_id
13921406
// for Unittest do not log
13931407
if ( $this->isTest ) return;
13941408

1395-
$p = (is_object($config)) ? ['api_key' => $config->getApiKey('api_key'), 'store_key' => $config->getApiKey('store_key'), 'msg' => $msg ] : [];
1409+
$p = (is_object($config)) ? ['api_key' => $config->getApiKey('api_key'), 'store_key' => $config->getApiKey('store_key') ] : [];
13961410

13971411
if ( is_array($params) ){
13981412
foreach ($params as $k=>$v){
13991413
$p[ $k ] = $v;
14001414
}
14011415
}
14021416

1417+
if ( $msg ){
1418+
$p['msg'] = $msg;
1419+
}
1420+
14031421
$log = Logger::create([
14041422
'action' => $action,
14051423
'code' => $code,

0 commit comments

Comments
 (0)