mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
Fix duplicates answers
This commit is contained in:
@@ -1323,7 +1323,7 @@ if ($mode == 'marketplace') {
|
|||||||
|
|
||||||
$categories_tree = $remotestore->getCategories($options['categorie']); // Call API to get the categories
|
$categories_tree = $remotestore->getCategories($options['categorie']); // Call API to get the categories
|
||||||
|
|
||||||
$products_list = $remotestore->getProducts($options);
|
$products_list = $remotestore->getProducts($options); // Get list of product from all sources
|
||||||
|
|
||||||
$previouslink = $remotestore->get_previous_link();
|
$previouslink = $remotestore->get_previous_link();
|
||||||
|
|
||||||
@@ -1337,7 +1337,7 @@ if ($mode == 'marketplace') {
|
|||||||
<input type="hidden" name="mode" value="marketplace">
|
<input type="hidden" name="mode" value="marketplace">
|
||||||
<input type="hidden" name="page_y" value="">
|
<input type="hidden" name="page_y" value="">
|
||||||
<div class="divsearchfield">
|
<div class="divsearchfield">
|
||||||
<input name="search_keyword" placeholder="<?php echo $langs->trans('Keyword') ?>" id="search_keyword" type="text" class="minwidth200" value="<?php echo dolPrintHTMLForAttribute($options['search']) ?>">
|
<input name="search_keyword" placeholder="<?php echo $langs->trans('Keyword') ?>" id="search_keyword" type="text" class="minwidth200" value="<?php echo dolPrintHTMLForAttribute($options['search']) ?>" spellcheck="false">
|
||||||
</div>
|
</div>
|
||||||
<div class="divsearchfield">
|
<div class="divsearchfield">
|
||||||
<input name="buttonsubmit" class="button buttongen reposition" value="<?php echo $langs->trans('Search') ?>" type="submit">
|
<input name="buttonsubmit" class="button buttongen reposition" value="<?php echo $langs->trans('Search') ?>" type="submit">
|
||||||
|
|||||||
@@ -352,10 +352,13 @@ class ExternalModules
|
|||||||
'lang' => $this->lang
|
'lang' => $this->lang
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$this->numberTotalOfProducts = 0;
|
||||||
|
|
||||||
// Fetch the products from Dolistore source
|
// Fetch the products from Dolistore source
|
||||||
|
|
||||||
$dolistoreProducts = array();
|
$dolistoreProducts = array();
|
||||||
$dolistoreProductsTotal = 0;
|
$dolistoreProductsTotal = 0;
|
||||||
$this->numberTotalOfProducts = 0;
|
|
||||||
if ($this->dolistoreApiStatus > 0 && getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_DOLISTORE')) {
|
if ($this->dolistoreApiStatus > 0 && getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_DOLISTORE')) {
|
||||||
$getDolistoreProducts = $this->callApi('products', $data);
|
$getDolistoreProducts = $this->callApi('products', $data);
|
||||||
|
|
||||||
@@ -368,8 +371,9 @@ class ExternalModules
|
|||||||
$this->numberTotalOfProducts += $dolistoreProductsTotal;
|
$this->numberTotalOfProducts += $dolistoreProductsTotal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var_dump($dolistoreProducts);
|
||||||
// Fetch the products from the github repo
|
// Fetch the products from the github repo
|
||||||
|
|
||||||
$fileProducts = array();
|
$fileProducts = array();
|
||||||
$fileProductsTotal = 0;
|
$fileProductsTotal = 0;
|
||||||
if (!empty($this->githubFileStatus) && getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_COMMUNITY')) {
|
if (!empty($this->githubFileStatus) && getDolGlobalInt('MAIN_ENABLE_EXTERNALMODULES_COMMUNITY')) {
|
||||||
@@ -389,8 +393,22 @@ class ExternalModules
|
|||||||
// Number of pages
|
// Number of pages
|
||||||
$this->numberTotalOfPages = (int) ceil(max($fileProductsTotal / $this->per_page, $dolistoreProductsTotal / $this->per_page));
|
$this->numberTotalOfPages = (int) ceil(max($fileProductsTotal / $this->per_page, $dolistoreProductsTotal / $this->per_page));
|
||||||
|
|
||||||
// merge both sources
|
// Merge both sources (github community modules have priority on dolistore).
|
||||||
$this->products = array_values(array_merge($fileProducts, $dolistoreProducts));
|
$this->products = $dolistoreProducts;
|
||||||
|
foreach ($fileProducts as $fileProduct) {
|
||||||
|
$id = $fileProduct['id'];
|
||||||
|
if ($id > 0) {
|
||||||
|
if (empty($this->products[$id])) { // Not already present in array
|
||||||
|
array_unshift($this->products, $fileProduct);
|
||||||
|
} else {
|
||||||
|
$this->products[$id] = $fileProduct;
|
||||||
|
$this->products[$id]['category'] = $fileProduct['category'];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
array_unshift($this->products, $fileProduct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($this->products as $product) {
|
foreach ($this->products as $product) {
|
||||||
@@ -975,7 +993,15 @@ class ExternalModules
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if there is a known ID
|
||||||
|
$reg = array();
|
||||||
|
$id = 0;
|
||||||
|
if (!empty($package['dolistore-download']) && preg_match('/www\.dolistore\.com\/product\.php\?id=(\d+)/', $package['dolistore-download'], $reg)) {
|
||||||
|
$id = $reg[1];
|
||||||
|
}
|
||||||
|
|
||||||
$adaptedPackage = [
|
$adaptedPackage = [
|
||||||
|
'id' => $id,
|
||||||
'ref' => str_replace(' ', '', $package['modulename'] . '-' . $package['current_version'] . '@' .
|
'ref' => str_replace(' ', '', $package['modulename'] . '-' . $package['current_version'] . '@' .
|
||||||
(array_key_exists('author', $package) ? $package['author'] : 'unkownauthor')),
|
(array_key_exists('author', $package) ? $package['author'] : 'unkownauthor')),
|
||||||
'label' => !empty($package['label'][substr($this->lang, 0, 2)])
|
'label' => !empty($package['label'][substr($this->lang, 0, 2)])
|
||||||
@@ -1064,7 +1090,7 @@ class ExternalModules
|
|||||||
'status' => empty($package['status']) ? '' : $package['status']
|
'status' => empty($package['status']) ? '' : $package['status']
|
||||||
];
|
];
|
||||||
|
|
||||||
$adaptedData[] = $adaptedPackage;
|
$adaptedData[$package['id']] = $adaptedPackage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user