Skip to content

Commit 19d9401

Browse files
committed
fix: fix bug
1 parent 04c2da4 commit 19d9401

File tree

19 files changed

+345
-288
lines changed

19 files changed

+345
-288
lines changed

controllers/admin/AdminVuefrontAjaxController.php

Lines changed: 174 additions & 164 deletions
Large diffs are not rendered by default.

model/common/seo.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
<?php
22

3-
class ModelCommonSeo extends Model {
4-
public function addUrl($url, $type, $id) {
3+
class ModelCommonSeo extends Model
4+
{
5+
public function addUrl($url, $type, $id)
6+
{
57
$sql = new DbQuery();
68
$sql->select('*');
79
$sql->from('vuefront_url', 'v');
810
$sql->where('url LIKE \''.$url.'\'');
911

1012
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
1113
if (!$result) {
12-
Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('INSERT INTO `' . _DB_PREFIX_ . 'vuefront_url` SET url = \''.$url.'\',
13-
id = \''.$id.'\',
14-
type = \''.$type.'\'');
14+
Db::getInstance(_PS_USE_SQL_SLAVE_)
15+
->execute('INSERT INTO `' . _DB_PREFIX_ . 'vuefront_url` SET url = \''.$url.'\',
16+
id = \''.$id.'\',
17+
type = \''.$type.'\'');
1518
}
1619
}
1720

18-
public function searchKeyword($url) {
21+
public function searchKeyword($url)
22+
{
1923
$sql = new DbQuery();
2024
$sql->select('*');
2125
$sql->from('vuefront_url', 'v');
@@ -29,11 +33,10 @@ public function searchKeyword($url) {
2933
'url' => $url
3034
);
3135
}
32-
3336
return array(
3437
'id' => $result[0]['id'],
3538
'type' => $result[0]['type'],
3639
'url' => $url
3740
);
3841
}
39-
}
42+
}

model/common/vuefront.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ public function editApp($name, $appSetting)
2222

2323
try {
2424
$setting = Tools::jsonDecode($option, true);
25-
} catch(Exception $e) {
26-
25+
} catch (Exception $e) {
2726
}
2827

2928
$app = $this->getApp($name);
@@ -38,19 +37,19 @@ public function editApp($name, $appSetting)
3837
$setting[] = $appSetting;
3938
}
4039

41-
Configuration::updateValue('vuefront-apps', Tools::jsonEncode($setting), null,0,0);
40+
Configuration::updateValue('vuefront-apps', Tools::jsonEncode($setting), null, 0, 0);
4241
}
4342

44-
public function checkAccess() {
43+
public function checkAccess()
44+
{
4545

4646
$option = Configuration::get('vuefront-settings');
4747

4848
$setting = array();
4949

5050
try {
5151
$setting = Tools::jsonDecode($option, true);
52-
} catch(Exception $e) {
53-
52+
} catch (Exception $e) {
5453
}
5554

5655
if (!Tools::getValue('accessKey')) {
@@ -59,7 +58,7 @@ public function checkAccess() {
5958

6059
$result = false;
6160
foreach ($setting as $key => $value) {
62-
if($key === 'accessKey' && Tools::getValue('accessKey') === $value) {
61+
if ($key === 'accessKey' && Tools::getValue('accessKey') === $value) {
6362
$result = true;
6463
}
6564
}
@@ -74,7 +73,7 @@ public function getApp($name)
7473

7574
try {
7675
$setting = Tools::jsonDecode($option, true);
77-
} catch(Exception $e) {
76+
} catch (Exception $e) {
7877
}
7978
foreach ($setting as $value) {
8079
if ($value['codename'] == $name) {
@@ -85,14 +84,15 @@ public function getApp($name)
8584
return false;
8685
}
8786

88-
public function getAppsForEvent() {
87+
public function getAppsForEvent()
88+
{
8989
$option = Configuration::get('vuefront-apps');
9090

9191
$setting = array();
9292

9393
try {
9494
$setting = Tools::jsonDecode($option, true);
95-
} catch(Exception $e) {
95+
} catch (Exception $e) {
9696
}
9797
$result = [];
9898
foreach ($setting as $value) {
@@ -122,7 +122,8 @@ public function pushEvent($name, $data)
122122
return $data;
123123
}
124124

125-
public function request($url, $data, $token = false) {
125+
public function request($url, $data, $token = false)
126+
{
126127
$ch = curl_init();
127128
$headers = array();
128129

@@ -151,7 +152,8 @@ public function request($url, $data, $token = false) {
151152
}
152153

153154

154-
public function mergeSchemas($files) {
155+
public function mergeSchemas($files)
156+
{
155157
$rootQueryType = '';
156158
$types = '';
157159
$rootMutationType = '';
@@ -169,7 +171,8 @@ public function mergeSchemas($files) {
169171
$types = $types.PHP_EOL.$typesMatched[1];
170172
}
171173
}
172-
173-
return "${types}".PHP_EOL."type RootQueryType {".PHP_EOL."${rootQueryType}".PHP_EOL."}".PHP_EOL."type RootMutationType {".PHP_EOL."${rootMutationType}".PHP_EOL."}";
174+
return "${types}".PHP_EOL."type RootQueryType {".PHP_EOL."${rootQueryType}"
175+
.PHP_EOL."}".PHP_EOL."type RootMutationType {".PHP_EOL."${rootMutationType}"
176+
.PHP_EOL."}";
174177
}
175-
}
178+
}

model/store/cart.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22

3-
class ModelStoreCart extends Model {
4-
public function prepareCart() {
3+
class ModelStoreCart extends Model
4+
{
5+
public function prepareCart()
6+
{
57
$cart = array();
68
$this->load->model('store/product');
79
$cart['products'] = array();
@@ -37,9 +39,7 @@ public function prepareCart() {
3739
'total' => Tools::displayPrice($value['total'])
3840
);
3941
}
40-
4142
$cart['total'] = Tools::displayPrice($this->context->cart->getOrderTotal());
42-
4343
return $cart;
4444
}
45-
}
45+
}

model/store/category.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ public function getCategories($data = array())
112112
$sql->where('c.`id_parent` = ' . (int)$parent_id);
113113
}
114114
if (!empty($data['filter_name'])) {
115-
$sql->where('cl.`name` LIKE \'%' . pSQL($data['filter_name']).'%\' OR cl.`description` LIKE \'%' . pSQL($data['filter_name']).'%\'');
115+
$sql->where('cl.`name` LIKE \'%' . pSQL($data['filter_name'])
116+
.'%\' OR cl.`description` LIKE \'%' . pSQL($data['filter_name']).'%\'');
116117
}
117118

118119
$sql->orderBy($sort . ' ' . $data['order']);
@@ -151,7 +152,8 @@ public function getTotalCategories($data = array())
151152
}
152153

153154
if (!empty($data['filter_name'])) {
154-
$sql->where('cl.`name` LIKE \'%' . pSQL($data['filter_name']).'%\' OR cl.`description` LIKE \'%' . pSQL($data['filter_name']).'%\'');
155+
$sql->where('cl.`name` LIKE \'%' . pSQL($data['filter_name'])
156+
.'%\' OR cl.`description` LIKE \'%' . pSQL($data['filter_name']).'%\'');
155157
}
156158

157159
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);

model/store/checkout.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,34 @@
1212
*/
1313

1414

15-
class ModelStoreCheckout extends Model {
16-
public function getJwt($codename) {
15+
class ModelStoreCheckout extends Model
16+
{
17+
public function getJwt($codename)
18+
{
1719
$option = Configuration::get('vuefront-apps');
1820

1921
$setting = array();
2022

2123
try {
2224
$setting = Tools::jsonDecode($option, true);
23-
} catch(Exception $e) {
24-
25+
} catch (Exception $e) {
2526
}
2627

2728
$result = false;
2829

2930
foreach ($setting as $value) {
30-
if($value['codename'] == $codename) {
31+
if ($value['codename'] == $codename) {
3132
$result = $value['jwt'];
3233
}
3334
}
3435

3536
return $result;
3637
}
37-
public function requestCheckout($query, $variables) {
38+
public function requestCheckout($query, $variables)
39+
{
3840
$jwt = $this->getJwt('vuefront-checkout-app');
3941

40-
$ch = curl_init();
42+
$ch = curl_init();
4143

4244
$requestData = array(
4345
'operationName' => null,
@@ -50,17 +52,17 @@ public function requestCheckout($query, $variables) {
5052
$headr[] = 'Content-type: application/json';
5153
$headr[] = 'Authorization: '.$jwt;
5254

53-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
54-
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
55-
curl_setopt($ch, CURLOPT_POST,true);
56-
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData, JSON_FORCE_OBJECT) );
57-
// curl_setopt($ch, CURLOPT_URL, 'http://localhost:3005/graphql');
58-
curl_setopt($ch, CURLOPT_URL, 'https://api.checkout.vuefront.com/graphql');
55+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
56+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headr);
57+
curl_setopt($ch, CURLOPT_POST, true);
58+
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestData, JSON_FORCE_OBJECT));
59+
// curl_setopt($ch, CURLOPT_URL, 'http://localhost:3005/graphql');
60+
curl_setopt($ch, CURLOPT_URL, 'https://api.checkout.vuefront.com/graphql');
5961

60-
$result = curl_exec($ch);
62+
$result = curl_exec($ch);
6163

6264
$result = json_decode($result, true);
6365

6466
return $result['data'];
6567
}
66-
}
68+
}

model/store/manufacturer.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,18 @@ public function getManufacturer($id)
5454
'id' => $manufacturer->id,
5555
'name' => $manufacturer->name,
5656
'description' => html_entity_decode($manufacturer->description, ENT_QUOTES, 'UTF-8'),
57-
'image' => $this->context->link->getManufacturerImageLink($manufacturer->id, ImageType::getFormatedName("medium")),
58-
'imageBig' => $this->context->link->getManufacturerImageLink($manufacturer->id, ImageType::getFormatedName("large")),
59-
'imageLazy' => $this->context->link->getManufacturerImageLink($manufacturer->id, ImageType::getFormatedName("small")),
57+
'image' => $this->context->link->getManufacturerImageLink(
58+
$manufacturer->id,
59+
ImageType::getFormatedName("medium")
60+
),
61+
'imageBig' => $this->context->link->getManufacturerImageLink(
62+
$manufacturer->id,
63+
ImageType::getFormatedName("large")
64+
),
65+
'imageLazy' => $this->context->link->getManufacturerImageLink(
66+
$manufacturer->id,
67+
ImageType::getFormatedName("small")
68+
),
6069
'keyword' => $url,
6170
'meta' => array(
6271
'title' => $manufacturer->meta_title,
@@ -112,4 +121,4 @@ public function getTotalManufacturers($data)
112121
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
113122
return $result['count(*)'];
114123
}
115-
}
124+
}

model/store/option.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
class ModelStoreOption extends Model
1414
{
15-
public function getOptionValues($id) {
15+
public function getOptionValues($id)
16+
{
1617
$sql = new DbQuery();
1718
$sql->select('*');
1819
$sql->from('attribute', 'a');
@@ -27,7 +28,8 @@ public function getOptionValues($id) {
2728
return $result;
2829
}
2930

30-
public function getOptions($data) {
31+
public function getOptions($data)
32+
{
3133
$sort = 'al.`name`';
3234
if ($data['sort'] == 'id') {
3335
$sort = 'a.`id_attribute_group`';
@@ -53,7 +55,8 @@ public function getOptions($data) {
5355
return $result;
5456
}
5557

56-
public function getOption($id) {
58+
public function getOption($id)
59+
{
5760
$sql = new DbQuery();
5861
$sql->select('*');
5962
$sql->from('attribute_group', 'a');
@@ -67,7 +70,8 @@ public function getOption($id) {
6770
return !empty($result) ? $result[0]: null;
6871
}
6972

70-
public function getTotalOptions($data) {
73+
public function getTotalOptions($data)
74+
{
7175
$sql = new DbQuery();
7276
$sql->select('count(*)');
7377
$sql->from('attribute_group', 'a');
@@ -79,8 +83,7 @@ public function getTotalOptions($data) {
7983
$sql->where("al.`name` LIKE '%" . pSQL($data['filter_name']). "%'");
8084
}
8185

82-
8386
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql);
8487
return $result['count(*)'];
8588
}
86-
}
89+
}

model/store/product.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function getProducts($data = array())
161161
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
162162

163163
if ($data['sort'] == 'price') {
164-
Tools::orderbyPrice($result,$data['order']);
164+
Tools::orderbyPrice($result, $data['order']);
165165
}
166166

167167
return $result;
@@ -178,8 +178,8 @@ public function getTotalProducts($data = array())
178178
$sql->where('pl.`id_lang` = ' . (int)$this->context->language->id);
179179

180180
if (!empty($data['filter_category_id']) && $data['filter_category_id'] > 0) {
181-
$sql->leftJoin('category_product', 'c', 'c.`id_product` = p.`id_product`');
182-
$sql->where('c.`id_category` = ' . (int)$data['filter_category_id']);
181+
$sql->leftJoin('category_product', 'c', 'c.`id_product` = p.`id_product`');
182+
$sql->where('c.`id_category` = ' . (int)$data['filter_category_id']);
183183
}
184184
if (!empty($data['filter_product_ids'])) {
185185
$sql->where('p.`id_product` IN ' . "('" . implode("','", $data['filter_product_ids']) . "')");

0 commit comments

Comments
 (0)