Skip to content

Commit

Permalink
Merge pull request #165 from Progi1984/removeToolsJsonDecode
Browse files Browse the repository at this point in the history
Remove the deprecated method `Tools::jsonDecode`, Fix Reset & Bump to 1.4.1
  • Loading branch information
kpodemski authored Apr 6, 2022
2 parents 1b0be14 + 8813cc7 commit 719cc58
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion classes/APIFAQClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getData($module_key, $version)
return false;
}
/** @var object $content */
$content = Tools::jsonDecode($content, true);
$content = json_decode($content, true);
if (empty($content->categories)) {
return false;
}
Expand Down
44 changes: 19 additions & 25 deletions psgdpr.php
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ public function getCustomerDataFromPrestashop(Customer $customer)
$genderName = $gender->name;
unset($gender);

$customerInfo = [
$data['customerInfo'] = [
'id_customer' => $customer->id,
'gender' => $genderName,
'firstname' => $customer->firstname,
Expand All @@ -784,7 +784,7 @@ public function getCustomerDataFromPrestashop(Customer $customer)
];

// get orders
$orders = [];
$data['orders'] = [];
$orderList = Order::getCustomerOrders($customer->id);

if (count($orderList) >= 1) {
Expand All @@ -793,7 +793,7 @@ public function getCustomerDataFromPrestashop(Customer $customer)
$productsOrder = $orderObject->getProducts();
$currency = Currency::getCurrency($order['id_currency']);

array_push($orders, [
$data['orders'][] = [
'id_order' => $order['id_order'],
'reference' => $order['reference'],
'payment' => $order['payment'],
Expand All @@ -803,80 +803,74 @@ public function getCustomerDataFromPrestashop(Customer $customer)
'total_paid_tax_incl' => number_format($order['total_paid_tax_incl'], 2) . ' ' . $currency['iso_code'],
'nb_products' => $order['nb_products'],
'products' => [],
]);
];
foreach ($productsOrder as $product) {
array_push($orders[$index]['products'], [
$data['orders'][$index]['products'][] = [
'id_product' => $product['product_id'],
'id_product_attribute' => $product['product_attribute_id'],
'product_reference' => $product['product_reference'],
'product_name' => $product['product_name'],
'product_quantity' => $product['product_quantity'],
]);
];
}
unset($orderObject);
}
}

// get carts
$carts = [];
$data['carts'] = [];
$cartList = Cart::getCustomerCarts($customer->id, false);

if (count($cartList) >= 1) {
foreach ($cartList as $index => $cart) {
$cartObject = new Cart($cart['id_cart']);
$productsCart = $cartObject->getProducts();

array_push($carts, [
$data['carts'][] = [
'id_cart' => $cart['id_cart'],
'nb_products' => count($productsCart),
'products' => [],
'date_add' => $cart['date_add'],
]);
];
foreach ($productsCart as $product) {
array_push($carts[$index]['products'], [
$data['carts'][$index]['products'][] = [
'id_product' => $product['id_product'],
'id_product_attribute' => $product['id_product_attribute'],
'product_reference' => $product['reference'],
'product_name' => $product['name'],
'product_quantity' => $product['cart_quantity'],
'total_wt' => $product['total_wt'],
]);
];
}
unset($cartObject);
}
}

// get addresses
$addresses = $customer->getAddresses($id_lang);
$data['addresses'] = $customer->getAddresses($id_lang);

// get messages
$messages = [];
$data['messages'] = [];
$messageList = CustomerThread::getCustomerMessages($customer->id);

if (count($messageList) >= 1) {
foreach ($messageList as $index => $message) {
array_push($messages, [
$data['messages'][] = [
'id_customer_thread' => $message['id_customer_thread'],
'message' => $message['message'],
'ip' => (int) $message['ip_address'] == $message['ip_address'] ? long2ip((int) $message['ip_address']) : $message['ip_address'],
'date_add' => $message['date_add'],
]);
];
}
}

// get connections
$connections = $customer->getLastConnections();
$data['connections'] = $customer->getLastConnections();

// get referrers
$referrer = Referrer::getReferrers($customer->id);

$data['customerInfo'] = $customerInfo;
$data['orders'] = $orders;
$data['carts'] = $carts;
$data['addresses'] = $addresses;
$data['messages'] = $messages;
$data['connections'] = $connections;
$data['referrer'] = $referrer;
if (version_compare(_PS_VERSION_, '8.0.0', '<')) {
$data['referrer'] = Referrer::getReferrers($customer->id);
}

return $data;
}
Expand Down
6 changes: 2 additions & 4 deletions sql/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@
`date_add` datetime NOT NULL,
`date_upd` datetime NOT NULL,
PRIMARY KEY (`id_gdpr_log`),
INDEX (`id_customer`)
INDEX (`id_customer`),
INDEX `idx_id_customer` ( `id_customer`, `id_guest`, `client_name`, `id_module`, `date_add`, `date_upd`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=UTF8;';

$sql[] = ' ALTER TABLE `' . _DB_PREFIX_ . 'psgdpr_log`
ADD INDEX `idx_id_customer` ( `id_customer`, `id_guest`, `client_name`, `id_module`, `date_add`, `date_upd`); ';

foreach ($sql as $query) {
if (Db::getInstance()->execute($query) == false) {
return false;
Expand Down

0 comments on commit 719cc58

Please sign in to comment.