Partner Producthchange WIP 2024-07-23

This commit is contained in:
Frank Schubert
2024-07-24 13:34:39 +02:00
parent ce671f2edd
commit a4f6b3b98c
8 changed files with 784 additions and 303 deletions

View File

@@ -421,9 +421,32 @@ class ProductController extends mfBaseController {
}
$results = [];
if(!$this->me->isAdmin()) {
$my_product_ids = [];
$my_network_ids = [];
foreach($this->me->my_networks as $network) {
$my_network_ids[] = $network->id;
}
foreach(ProductNetworkModel::search(["network_id" => $my_network_ids]) as $pn) {
if(!$pn->product->active) continue;
if(!array_key_exists($pn->product_id, $my_product_ids)) {
$my_product_ids[] = $pn->product_id;
}
}
}
// return bootstrap-autocomplete format
foreach($products as $product) {
if(!$this->me->isAdmin()) {
if(!in_array($product->id, $my_product_ids)) continue;
}
$result = ['value' => $product->id, 'text' => str_replace("'", "\\'", str_replace(["\n", "\r"], " ",$product->name))];
$results[] = $result;
if(count($results) > 15) {