change construction of articles/offers

This commit is contained in:
Ludovic CANDELLIER
2022-02-20 21:38:21 +01:00
parent 4b2c431ee9
commit ea53cb4c8a
7 changed files with 54 additions and 25 deletions

View File

@@ -111,14 +111,16 @@ class Articles
$price_lists = $article->offers[0]->tariff->price_lists->toArray();
// dump($price_lists);
if (count($price_lists)) {
$data[$article->name] = [
'description' => (!empty($article->description)) ? $article->description : $article->product->description,
'image' => $article->image,
'product_type' => $article->product_type,
'product_id' => $article->product_id,
'product_name' => $article->product->name,
'parent_name' => trim(str_replace($article->product->name, '', $article->name)),
];
if (!is_array($data[$article->name] ?? false)) {
$data[$article->name] = [
'description' => (!empty($article->description)) ? $article->description : $article->product->description,
'image' => $article->image,
'product_type' => $article->product_type,
'product_id' => $article->product_id,
'product_name' => $article->product->name,
'parent_name' => trim(str_replace($article->product->name, '', $article->name)),
];
}
$prices = $price_lists[0]['price_list_values'][0];
$article_nature_name = strtolower($article->article_nature->name);
// dump($prices);
@@ -129,10 +131,8 @@ class Articles
'price' => $prices['price_taxed'],
'variation' => $article->offers[0]->variation->name,
];
}
}
}
// dump($data);
// exit;
return $data ?? false;
}

View File

@@ -129,14 +129,11 @@ class Categories
$id = $id ? (int) $id : $data['id'];
$category = self::get($id);
$ret = $category->update($data);
// CategoryTrees::update($data, $category->category_id);
return $category;
}
public static function destroy($id)
{
// $category = self::get($id);
// CategoryTrees::destroy($category->category_id);
return Category::destroy($id);
}