[WIP] Order process
This commit is contained in:
@@ -173,14 +173,15 @@ class Articles
|
||||
$articles = self::getArticlesWithOffers($options);
|
||||
foreach ($articles as $article) {
|
||||
$price_lists = $article->offers[0]->tariff->price_lists->toArray();
|
||||
if (count($price_lists)) {
|
||||
if (!is_array($data[$article->name] ?? false)) {
|
||||
$data[$article->name] = self::getDataForSale($article);
|
||||
}
|
||||
$prices = $price_lists[0]['price_list_values'][0];
|
||||
$article_nature_name = strtolower($article->article_nature->name);
|
||||
$data[$article->name][$article_nature_name] = self::getDataPriceForSale($article, $prices);
|
||||
if (!count($price_lists)) {
|
||||
continue;
|
||||
}
|
||||
if (!is_array($data[$article->name] ?? false)) {
|
||||
$data[$article->name] = self::getDataForSale($article);
|
||||
}
|
||||
$prices = $price_lists[0]['price_list_values'][0];
|
||||
$article_nature_name = strtolower($article->article_nature->name);
|
||||
$data[$article->name][$article_nature_name] = self::getDataPriceForSale($article, $prices);
|
||||
}
|
||||
if ($data ?? false) {
|
||||
ksort($data);
|
||||
@@ -511,25 +512,26 @@ class Articles
|
||||
public static function getFullImageByArticle($article)
|
||||
{
|
||||
$image = $article->image;
|
||||
if (!$image) {
|
||||
switch ($article->product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$variety = $article->product;
|
||||
$image = $variety->image ?? false;
|
||||
if (!$image) {
|
||||
$specie = $variety->specie;
|
||||
$image = $specie->image ?? false;
|
||||
}
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$specie = $article->product;
|
||||
if ($image) {
|
||||
return $image;
|
||||
}
|
||||
switch ($article->product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$variety = $article->product;
|
||||
$image = $variety->image ?? false;
|
||||
if (!$image) {
|
||||
$specie = $variety->specie;
|
||||
$image = $specie->image ?? false;
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$merchandise = $article->product;
|
||||
$image = $merchandise->image ?? false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$specie = $article->product;
|
||||
$image = $specie->image ?? false;
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$merchandise = $article->product;
|
||||
$image = $merchandise->image ?? false;
|
||||
break;
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
@@ -581,16 +583,15 @@ class Articles
|
||||
|
||||
public static function storeCategories($article, $categories)
|
||||
{
|
||||
if ($categories) {
|
||||
$categories = collect($categories)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
return $article->syncCategories($categories, true);
|
||||
} else {
|
||||
if (!$categories) {
|
||||
return false;
|
||||
}
|
||||
$categories = collect($categories)->transform(
|
||||
function ($item, $key) {
|
||||
return (int) $item;
|
||||
}
|
||||
)->toArray();
|
||||
return $article->syncCategories($categories, true);
|
||||
}
|
||||
|
||||
public static function storeTags($article, $tags)
|
||||
|
||||
Reference in New Issue
Block a user