From 526441bf268dd7810d3fc848c473d7a3a5029aa6 Mon Sep 17 00:00:00 2001 From: eduardogomez97 Date: Wed, 4 Sep 2024 13:06:53 +0200 Subject: [PATCH] [Landing Pages] - New endpoint (#236) * [Landing Pages] - New endpoint * feat: Changed multiline args to single line --------- Co-authored-by: davidmolinacano --- doofinder.php | 14 ++++-------- lib/EasyREST.php | 41 +++++++---------------------------- lib/dfTools.class.php | 15 +++++-------- lib/doofinder_api_landing.php | 6 ++--- 4 files changed, 21 insertions(+), 55 deletions(-) diff --git a/doofinder.php b/doofinder.php index 52b1a7d..5432089 100644 --- a/doofinder.php +++ b/doofinder.php @@ -33,7 +33,7 @@ class Doofinder extends Module const DOOMANAGER_URL = 'https://admin.doofinder.com'; const GS_SHORT_DESCRIPTION = 1; const GS_LONG_DESCRIPTION = 2; - const VERSION = '4.8.7'; + const VERSION = '4.8.8'; const YES = 1; const NO = 0; @@ -41,7 +41,7 @@ public function __construct() { $this->name = 'doofinder'; $this->tab = 'search_filter'; - $this->version = '4.8.7'; + $this->version = '4.8.8'; $this->author = 'Doofinder (http://www.doofinder.com)'; $this->ps_versions_compliancy = ['min' => '1.5', 'max' => _PS_VERSION_]; $this->module_key = 'd1504fe6432199c7f56829be4bd16347'; @@ -1384,14 +1384,8 @@ public function testDoofinderApi($onlyOneLang = false) * * @return array */ - public function searchOnApi( - $string, - $page = 1, - $page_size = 12, - $timeout = 8000, - $filters = null, - $return_facets = false - ) { + public function searchOnApi($string, $page = 1, $page_size = 12, $timeout = 8000, $filters = null, $return_facets = false) + { $page_size = (int) $page_size; if (!$page_size) { $page_size = Configuration::get('PS_PRODUCTS_PER_PAGE'); diff --git a/lib/EasyREST.php b/lib/EasyREST.php index 83643a1..9f656c2 100644 --- a/lib/EasyREST.php +++ b/lib/EasyREST.php @@ -352,14 +352,8 @@ public static function createClient($url = null) * * @return EasyREST */ - public static function post( - $url, - $params = null, - $user = null, - $pwd = null, - $contentType = 'multipart/form-data', - $httpHeaders = null - ) { + public static function post($url, $params = null, $user = null, $pwd = null, $contentType = 'multipart/form-data', $httpHeaders = null) + { return self::call('POST', $url, $params, $user, $pwd, $contentType, $httpHeaders); } @@ -389,14 +383,8 @@ public static function put($url, $body, $user = null, $pwd = null, $contentType * * @return EasyREST */ - public static function get( - $url, - $params = null, - $user = null, - $pwd = null, - $contentType = 'multipart/form-data', - $httpHeaders = null - ) { + public static function get($url, $params = null, $user = null, $pwd = null, $contentType = 'multipart/form-data', $httpHeaders = null) + { return self::call('GET', $url, $params, $user, $pwd, $contentType, $httpHeaders); } @@ -410,14 +398,8 @@ public static function get( * * @return EasyREST */ - public static function delete( - $url, - $params = null, - $user = null, - $pwd = null, - $contentType = 'multipart/form-data', - $httpHeaders = null - ) { + public static function delete($url, $params = null, $user = null, $pwd = null, $contentType = 'multipart/form-data', $httpHeaders = null) + { return self::call('DELETE', $url, $params, $user, $pwd, $contentType, $httpHeaders); } @@ -434,15 +416,8 @@ public static function delete( * * @return EasyREST */ - public static function call( - $method, - $url, - $body, - $user = null, - $pwd = null, - $contentType = null, - $httpHeaders = null - ) { + public static function call($method, $url, $body, $user = null, $pwd = null, $contentType = null, $httpHeaders = null) + { return self::createClient($url) ->setParameters($body) ->setMethod($method) diff --git a/lib/dfTools.class.php b/lib/dfTools.class.php index 72d615c..a83707d 100644 --- a/lib/dfTools.class.php +++ b/lib/dfTools.class.php @@ -451,13 +451,8 @@ public static function getAttributesName($attributes_ids, $id_lang) * * @return array of rows (assoc arrays) */ - public static function getAvailableProductsForLanguage( - $id_lang, - $id_shop, - $limit = false, - $offset = false, - $ids = null - ) { + public static function getAvailableProductsForLanguage($id_lang, $id_shop, $limit = false, $offset = false, $ids = null) + { $Shop = new Shop($id_shop); $isbn = ''; @@ -1408,9 +1403,11 @@ public static function get_min_variant_prices($products, $include_taxes) $min_prices_by_product_id[$product_id]['link'] = self::get_variant_url($product, $context); } } else { - $min_prices_by_product_id[$product_id] = ['price' => $variant_price, + $min_prices_by_product_id[$product_id] = [ + 'price' => $variant_price, 'onsale_price' => $variant_onsale_price, - 'link' => self::get_variant_url($product, $context)]; + 'link' => self::get_variant_url($product, $context), + ]; } } diff --git a/lib/doofinder_api_landing.php b/lib/doofinder_api_landing.php index 5d70daf..15a2648 100644 --- a/lib/doofinder_api_landing.php +++ b/lib/doofinder_api_landing.php @@ -18,7 +18,7 @@ exit; } -const API_URL = 'https://{region}-admin.doofinder.com'; +const API_URL = 'https://{region}-plugins.doofinder.com'; class DoofinderApiLanding { @@ -32,11 +32,11 @@ public function __construct($hashid, $api_key, $region) /** * Make a request to the API to get landing data * - * @param array Product data + * @param string Name from Landing */ public function getLanding($slug) { - $endpoint = '/plugins/landing_new/' . $this->hashid . '/' . $slug; + $endpoint = "/landing/{$this->hashid}/$slug"; $url = $this->api_url . $endpoint;