<?php
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Enterprise License (PEL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PEL
*/
namespace App\Controller;
use App\Services\Import\ImportExternalServiceEconology;
use App\Services\ObjectToArrayService;
use Couchbase\Document;
use Pimcore\Controller\FrontendController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use Pimcore\Model\DataObject;
/**
* Class AccountController
*
* Controller that handles all account functionality, including register, login and connect to SSO profiles
*/
class MdmController extends FrontendController
{
static $PER_PAGE = 15;
static $MDM_URL = "https://pimcore.distriweb.net";
/**
* Récupérer les produits
* @Route("/mdm/products")
*/
public function listProducts(Request $request)
{
$listingProducts = new DataObject\Product\Listing();
$listingProducts->setUnpublished(true);
// $listingProducts->load();
$products = [];
$mdmUrl = self::$MDM_URL;
$now = new \DateTime();
$now->sub(new \DateInterval("PT15M"));
//$now->sub(new \DateInterval("P1D"));
$perPage = $request->get('size') ? $request->get('size') : self::$PER_PAGE;
// --------------------------------------------------------------------------------Système de pages ----------------------------------------------------------------------
$pageNumber = $request->get('page') ? $request->get('page') : 1;
//$isDbg = $request->get('lp') == 1;
// offset
$offset = 0;
if ($pageNumber == 2) $offset = ($perPage);
if ($pageNumber > 2) $offset = ($perPage) * ($pageNumber - 1);
if($request->get('lp') == 1) {
$pageNumber = 301;
$perPage = 100;
$offset = ($perPage) * ($pageNumber - 1);
}
// récupérer les produits correspondants
$listingProducts->setCondition('buyingPrice != 0 OR skuEconology IS NOT NULL');
//$listingProducts->setOrderKey('o_creationDate');
//$listingProducts->setOrder('DESC');
if (!$request->get('full'))
$listingProducts->setCondition('o_modificationDate > ?', [$now->getTimestamp()]);
$listingProducts->setOffset($offset);
$listingProducts->setLimit($perPage);
// lastPage
$lastPage = (count($listingProducts) / $perPage);
if (is_float($lastPage)) {
$lastPage = intval($lastPage) + 1;
}
// Récupérer les informations dont on a besoin pour Skyper et Routeur
foreach ($listingProducts as $key => $listingProduct) {
//echo $listingProduct->getSku(); die();
$isDbg = !!$listingProduct->getSkuEconology();
if (!$listingProduct->hasChildren() || !$listingProduct->getSku() || $listingProduct->getChildren()[0]->getKey() != "Providers") {
if ($isDbg) {
//echo ' A ';
//echo $listingProduct->getSku();
//echo ' ';
$_providerInfo_Econology = \Pimcore\Model\DataObject\ProviderInfo::getById(1761389);
$skuEco = $listingProduct->getSkuEconology();
// REF49003
//echo '<br/>';
//echo '<br/>';
//print_r($skuEco);
$_class = \Pimcore\Model\DataObject\ExternalDataEconology::class;
$product_eco = ImportExternalServiceEconology::getProductInBdd($_class, $skuEco);
// echo '<br/>';
// echo get_class($product_eco);
// //print_r($product_eco);
// echo '<br/>';
// echo '<br/>';
$_classStock = \Pimcore\Model\DataObject\ExternalDataEconologyStock::class;
$productStock = ImportExternalServiceEconology::getProductStockInBdd($_classStock, $skuEco, 'Default');
// echo get_class($productStock);
// echo '<br/>';
// echo '<br/>';
// echo $productStock->getQuantityAvailable();
// //print_r($productStock);
// Ajout ProductProvider
$stockProviderEco = new \Pimcore\Model\DataObject\ProductProvider();
// echo '<br/>';
// echo '<br/>';
// echo get_class($stockProviderEco);
$pathProviders = $listingProduct->getFullPath() . '/Providers';
// echo '<br/>';
// print_r($pathProviders);
$parent = DataObject\Service::createFolderByPath($pathProviders);
// echo '<br/>';
//echo get_class($parent);
//$product_eco = new \Pimcore\Model\DataObject\ExternalDataEconology();
// Ajout des champs utiles
$stockProviderEco->setKey(strtolower("econology" . "-" . $product_eco->getKey()));
$stockProviderEco->setName($product_eco->getTitle());
// Lié à Eco
$stockProviderEco->setProviderName("Econology");
$stockProviderEco->setStatus(true);
$stockProviderEco->setProviderSku($product_eco->getKey());
$stockProviderEco->setProduct($listingProduct);
$stockProviderEco->setProvider($_providerInfo_Econology);
// Gestion des prix
$stockProviderEco->setPrice($product_eco->getPrice_ttc());
//echo '<pre>'.print_r($stockProviderEco,true).'</pre>';
$stockProviderEco->setParent($parent);
$stockProviderEco->setPublished(true);
$stockProviderEco->save();
//$productStock = new \Pimcore\Model\DataObject\ExternalDataEconologyStock();
// AJOUT STOCK UNIT
$unite = \Pimcore\Model\DataObject\QuantityValue\Unit::getByAbbreviation("Un");
$stockEntrepotEco = new \Pimcore\Model\DataObject\ProductWharehouse();
$stockEntrepotEco->setKey(strtolower($productStock->getWarehouseInfos()->getCode() . "-" . $product_eco->getKey()));
$stockEntrepotEco->setProvider($stockProviderEco);
$stockEntrepotEco->setProduct($listingProduct);
$stockEntrepotEco->setInfos($productStock->getWarehouseInfos());
// Variables utiles
$stockEntrepotEco->setActiveForDispo(true);
$stockEntrepotEco->setPhysicalStock(new \Pimcore\Model\DataObject\Data\QuantityValue($productStock->getQuantityInStock(), $unite));
$stockEntrepotEco->setAvailableStock(new \Pimcore\Model\DataObject\Data\QuantityValue($productStock->getQuantityAvailable(), $unite));
$stockEntrepotEco->setParent($stockProviderEco);
$stockEntrepotEco->setPublished(true);
$stockEntrepotEco->save();
// echo '<pre>'.print_r($stockEntrepotEco->getFullPath(),true).'</pre>';
// echo '<pre>'.print_r($stockEntrepotEco,true).'</pre>';
// die();
}
continue;
}
if (!isset($listingProduct->getChildren()[0])) {
// if ($isDbg) echo ' B ';
continue;
}
$product['id'] = $listingProduct->getId();
$product['sku'] = $listingProduct->getSku();
$product['isActive'] = $listingProduct->isPublished();
// Fix - Init des clés
if(true) {
$product['description'] = $listingProduct->getDescription();
$product['shortDescription'] = $listingProduct->getDescription();
$product['metaDescription'] = null;
$product['metakey'] = null;
}
// url image
$hotspotImage = $listingProduct->getBaseImage();
$thumbnailUrl = $hotspotImage ? sprintf('%s%s', $mdmUrl, $hotspotImage->getThumbnail()->getPath()) : null;
$product['thumbnail'] = $thumbnailUrl;
// ok référence fabriquant
$product['manufacturerReference'] = $listingProduct->getMpn();
// ok metadataImage
$metadataImage = $listingProduct->getBaseImage() && $listingProduct->getBaseImage()->getHasMetaData()
? $listingProduct->getBaseImage()->getMetadata()[0]
: null;
$product['metadataImage'] = $metadataImage;
$product['name'] = $listingProduct->getName();
// prix de vente viens de salle
$product['price'] = null;
if (isset($listingProduct->getChildren()[1], $listingProduct->getChildren()[1]->getChildren()[0])) {
$product['price'] = $listingProduct->getChildren()[1]->getChildren()[0]->getPrice() ?
$listingProduct->getChildren()[1]->getChildren()[0]->getPrice() :
$listingProduct->getChildren()[1]->getChildren()[0]->getSpecialPrice();
// ok slugUrl
$slugUrl = null;
$product['description'] = null;
$product['shortDescription'] = null;
$product['metaDescription'] = null;
$product['metakey'] = null;
\Pimcore\Model\DataObject::setHideUnpublished(false);
foreach ($listingProduct->getChildren()[1]->getChildren()[0]->getChildren() as $child) {
switch ($child->getChannelName()) {
case 'DistriwebTeamelek':
$product['price'] = $child->getPrice() ?
$child->getPrice() :
$child->getSpecialPrice();
$slugUrl = $child->getUrl()[0]
? $child->getUrl()[0]->getSlug()
: null;
$product['description'] = isset($child->getDescription()[3])
? $listingProduct->getChildren()[1]->getChildren()[0]->getDescription() != $child->getDescription() ? $child->getDescription() : null
: null;
$product['shortDescription'] = isset($child->getShortDescription()[3])
? $child->getShortDescription()
: null;
$product['metaDescription'] = $child->getMetaDescription();
$product['metakey'] = $child->getMetakey();
// Dépublier la chaine
$product['isActive'] = $child->getPublished();
break;
}
}
$product['slugUrl'] = $slugUrl;
}
$product['priceSpecial'] = null;
$product['priceMagasin'] = null;
$product['priceSpecialMagasin'] = null;
$product['providerProducts'] = [];
if (isset($listingProduct->getChildren()[0]) && is_array($listingProduct->getChildren()[0]->getChildren()))
foreach ($listingProduct->getChildren()[0]->getChildren() as $key1 => $productProvider) {
$product['providerProducts'] += [$key1 => [
"id" => $productProvider->getId(),
"sku" => $listingProduct->getSku(),
"productMagento" => null,
"code" => $productProvider->getProviderSku(),
"name" => $productProvider->getProviderName(),
"price" => $productProvider->getPrice(),
'provider' => [
'id' => $productProvider->getProvider()->getId(),
'name' => $productProvider->getName(),
'favoriteProvider' => $productProvider->getFavoriteProvider()
]
]];
}
$product['magentoId'] = null;
$product['gtin'] = $listingProduct->getEan13();
// les quantité min/max
$product['minQty'] = $listingProduct->getMinQty();
$product['incrementQty'] = $listingProduct->getIncrementQty();
// parti de catégorie
$productSalesChannel = new DataObject\ProductSalesChannel\Listing();
$productSalesChannel->setCondition('channelName = ? AND o_published ', ["DistriwebTeamelek", true]);
$productSalesChannel->setCondition('product__id = ?', [$listingProduct->getId()]);
$categories = null;
$categoriesSalesChannel = [];
foreach ($productSalesChannel as $productSaleChannel) {
$categoriesSalesChannel = $productSaleChannel->getCategories();
}
if ($categoriesSalesChannel) {
foreach ($categoriesSalesChannel as $categorySalesChannel) {
// $categorie = [
// 'id' => $categorySalesChannel->getId(),
// 'name' => $categorySalesChannel->getName(),
// 'isActive' => $categorySalesChannel->getIsActive(),
// 'slug' => $categorySalesChannel->getSlug(),
// 'description' => $categorySalesChannel->getDescription(),
// 'title' => $categorySalesChannel->getTitle(),
// 'metakey' => $categorySalesChannel->getMetakey(),
// 'metaDescription' => $categorySalesChannel->getMetaDescription(),
// ];
$categories[] = ObjectToArrayService::objectToArray($categorySalesChannel);
}
}
$product['category'] = $categories;
// Brand et characteristics
$brandSorti = null;
$characteristicsSorti = [];
$characteristics = $listingProduct->getCharacteristics();
$brand = $listingProduct->getBrand();
if ($brand) {
$brandSorti = ObjectToArrayService::objectToArray($brand);
}
if ($characteristics) {
foreach ($characteristics as $characteristic) {
$key = array_search($characteristic->getObjectId(), array_column($characteristicsSorti, 'id'));
if ($key === false) {
$characteristicsSorti[] = ["id" => $characteristic->getObjectId(), "name" => $characteristic->getElement()->getName(), "value" => $characteristic->getData()["val"]];
} else {
$characteristicsSorti[$key]['value'] = $characteristicsSorti[$key]['value'] . ', ' . $characteristic->getData()["val"];
}
}
}
$product['caracteristiques'] = $characteristicsSorti;
$product['brand'] = $brandSorti;
$product['images'] = ['id' => null];
$product['weight'] = $listingProduct->getGrossWeight() ? $listingProduct->getGrossWeight() : 0;
$product['volume'] = 0;
// nouveau modification par rapport de stock;
// $product['stock'] = $listingProduct->getTotalAvailableStock();
// $stock DERD
$product['stockDerd'] = null;
if (isset($listingProduct->getChildren()[0]) && isset($listingProduct->getChildren()[0]->getChildren()[0])) {
$product['stockDerd'] = (int)$listingProduct->getChildren()[0]->getChildren()[0]->getAvailableStock();
}
$product['stock'] = (int)$listingProduct->getTotalAvailableStock();
$product['stockMp'] = (int)$listingProduct->getTotalAvailableStockMp();
$product['stockSecurity'] = 0; // stockSecurity
$product['stockDefaultMin'] = 0; // stockDefaultMin
$product['stockDefaultSufficient'] = 0; // stockDefaultSufficient
$product['stockDefaultMax'] = 0; // stockDefaultMax
$product['manageStock'] = true; // manageStock
$product['replenishmentQuantity'] = 0; // replenishmentQuantity
$product['locationArea'] = ""; // manageStock
$product['nbCarton'] = 0; // nbCarton
$product['nbProductsCarton'] = 0; // nbCarton
// Fix
$product['is_visible'] = true;
try {
if($listingProduct->getSkuEconology()) {
// Pour qu'il soit indexé dans Sylius
$product['minQty'] = 0;
$product['incrementQty'] = 0;
// Test si produit uniquement Econology
if(count($listingProduct->getChildren()[0]->getChildren()) == 1) {
// Pour que le produit uniquement Econology ne soit pas visible (sauf lien direct)
$product['is_visible'] = false;
// Pour que le prix remonte (car pas de Sales dans PIMCore)
if(!($product['price'] > 0)) {
$product['price'] = 1.0 * $listingProduct->getChildren()[0]->getChildren()[0]->getPrice();
}
}
}
} catch (\Throwable $th) { }
$products[] = $product;
}
return new JsonResponse([
'status' => 'ok',
'page' => [
"current-page" => (int) $pageNumber,
"per-page" => (int) $perPage,
"total" => count($listingProducts),
"last-page" => $lastPage < 1 ? 1 : (int) $lastPage,
],
'result' => $products,
]);
}
/**
* Récupérer les transporteurs par marketplaces
*
* @Route("/mdm/carrier-marketplaces", name="carrier_marketplaces")
*/
public function listCarrierMarketplaces(Request $request)
{
$listingCarrierMartplaces = new DataObject\CarrierMarketplace\Listing();
return new JsonResponse(ObjectToArrayService::objectsToArray($listingCarrierMartplaces));
}
/**
* Récupérer les produits
* @Route("/mdm/products1")
*/
public function listProducts1(Request $request)
{
$listingProducts = new DataObject\Product\Listing();
$listingProducts->setUnpublished(true);
// $listingProducts->load();
$products = [];
$mdmUrl = self::$MDM_URL;
$now = new \DateTime();
$now->sub(new \DateInterval("PT15M"));
$perPage = $request->get('size') ? $request->get('size') : self::$PER_PAGE;
// --------------------------------------------------------------------------------Système de pages ----------------------------------------------------------------------
$pageNumber = $request->get('page') ? $request->get('page') : 1;
// offset
$offset = 0;
if ($pageNumber == 2) $offset = ($perPage);
if ($pageNumber > 2) $offset = ($perPage) * ($pageNumber - 1);
// récupérer les produits correspondants
$listingProducts->setCondition('buyingPrice != 0');
if (!$request->get('full'))
$listingProducts->setCondition('o_modificationDate > ?', [$now->getTimestamp()]);
$listingProducts->setOffset($offset);
$listingProducts->setLimit($perPage);
// lastPage
$lastPage = (count($listingProducts) / $perPage);
if (is_float($lastPage)) {
$lastPage = intval($lastPage) + 1;
}
// Récupérer les informations dont on a besoin pour Skyper et Routeur
foreach ($listingProducts as $key => $listingProduct) {
if (!$listingProduct->hasChildren() || !$listingProduct->getSku() || $listingProduct->getChildren()[0]->getKey() != "Providers") continue;
$product['id'] = $listingProduct->getId();
$product['sku'] = $listingProduct->getSku();
$product['isActive'] = $listingProduct->isPublished();
// url image
$hotspotImage = $listingProduct->getBaseImage();
$thumbnailUrl = $hotspotImage ? sprintf('%s%s', $mdmUrl, $hotspotImage->getThumbnail()->getPath()) : null;
$product['thumbnail'] = $thumbnailUrl;
// ok référence fabriquant
$product['manufacturerReference'] = $listingProduct->getMpn();
// ok metadataImage
$metadataImage = $listingProduct->getBaseImage()
? $listingProduct->getBaseImage()->getMetadata()[0]
: null;
$product['metadataImage'] = $metadataImage;
$product['name'] = $listingProduct->getName();
// prix de vente viens de salle
$product['price'] = null;
if (isset($listingProduct->getChildren()[1], $listingProduct->getChildren()[1]->getChildren()[0])) {
$product['price'] = $listingProduct->getChildren()[1]->getChildren()[0]->getPrice() ?
$listingProduct->getChildren()[1]->getChildren()[0]->getPrice() :
$listingProduct->getChildren()[1]->getChildren()[0]->getSpecialPrice();
// ok slugUrl
$slugUrl = null;
$product['description'] = null;
$product['shortDescription'] = null;
$product['metaDescription'] = null;
$product['metakey'] = null;
\Pimcore\Model\DataObject::setHideUnpublished(false);
foreach ($listingProduct->getChildren()[1]->getChildren()[0]->getChildren() as $child) {
switch ($child->getChannelName()) {
case 'DistriwebTeamelek':
$product['price'] = $child->getPrice() ?
$child->getPrice() :
$child->getSpecialPrice();
$slugUrl = $child->getUrl()[0]
? $child->getUrl()[0]->getSlug()
: null;
$product['description'] = isset($child->getDescription()[3])
? $listingProduct->getChildren()[1]->getChildren()[0]->getDescription() != $child->getDescription() ? $child->getDescription() : null
: null;
$product['shortDescription'] = isset($child->getShortDescription()[3])
? $child->getShortDescription()
: null;
$product['metaDescription'] = $child->getMetaDescription();
$product['metakey'] = $child->getMetakey();
// Dépublier la chaine
$product['isActive'] = $child->getPublished();
break;
}
}
$product['slugUrl'] = $slugUrl;
}
$product['priceSpecial'] = null;
$product['priceMagasin'] = null;
$product['priceSpecialMagasin'] = null;
$product['providerProducts'] = [];
if (is_array($listingProduct->getChildren()[0]->getChildren()))
foreach ($listingProduct->getChildren()[0]->getChildren() as $key1 => $productProvider) {
$product['providerProducts'] += [$key1 => [
"id" => $productProvider->getId(),
"sku" => $listingProduct->getSku(),
"productMagento" => null,
"code" => $productProvider->getProviderSku(),
"name" => $productProvider->getProviderName(),
"price" => $productProvider->getPrice(),
'provider' => [
'id' => $productProvider->getProvider()->getId(),
'name' => $productProvider->getName(),
'favoriteProvider' => $productProvider->getFavoriteProvider()
]
]];
}
$product['magentoId'] = null;
$product['gtin'] = $listingProduct->getEan13();
// les quantité min/max
$product['minQty'] = $listingProduct->getMinQty();
$product['incrementQty'] = $listingProduct->getIncrementQty();
// parti de catégorie
$productSalesChannel = new DataObject\ProductSalesChannel\Listing();
$productSalesChannel->setCondition('channelName = ? AND o_published ', ["DistriwebTeamelek", true]);
$productSalesChannel->setCondition('product__id = ?', [$listingProduct->getId()]);
$categories = null;
$categoriesSalesChannel = [];
foreach ($productSalesChannel as $productSaleChannel) {
$categoriesSalesChannel = $productSaleChannel->getCategories();
}
if ($categoriesSalesChannel) {
foreach ($categoriesSalesChannel as $categorySalesChannel) {
// $categorie = [
// 'id' => $categorySalesChannel->getId(),
// 'name' => $categorySalesChannel->getName(),
// 'isActive' => $categorySalesChannel->getIsActive(),
// 'slug' => $categorySalesChannel->getSlug(),
// 'description' => $categorySalesChannel->getDescription(),
// 'title' => $categorySalesChannel->getTitle(),
// 'metakey' => $categorySalesChannel->getMetakey(),
// 'metaDescription' => $categorySalesChannel->getMetaDescription(),
// ];
$categories[] = ObjectToArrayService::objectToArray($categorySalesChannel);
}
}
$product['category'] = $categories;
// Brand et characteristics
$brandSorti = null;
$characteristicsSorti = null;
$characteristics = $listingProduct->getCharacteristics();
$brand = $listingProduct->getBrand();
if ($brand) {
$brandSorti = ObjectToArrayService::objectToArray($brand);
}
if ($characteristics) {
foreach ($characteristics as $characteristic) {
$characteristicsSorti[] = ["id" => $characteristic->getObjectId(), "name" => $characteristic->getElement()->getName(), "value" => $characteristic->getData()["val"]];
}
}
$product['caracteristiques'] = $characteristicsSorti;
$product['brand'] = $brandSorti;
$product['images'] = ['id' => null];
$product['weight'] = $listingProduct->getGrossWeight() ? $listingProduct->getGrossWeight() : 0;
$product['volume'] = 0;
// nouveau modification par rapport de stock;
// $product['stock'] = $listingProduct->getTotalAvailableStock();
// $stock DERD
$product['stockDerd'] = null;
if (isset($listingProduct->getChildren()[0]) && isset($listingProduct->getChildren()[0]->getChildren()[0])) {
$product['stockDerd'] = (int)$listingProduct->getChildren()[0]->getChildren()[0]->getAvailableStock();
}
$product['stock'] = (int)$listingProduct->getTotalAvailableStock();
$product['stockSecurity'] = 0; // stockSecurity
$product['stockDefaultMin'] = 0; // stockDefaultMin
$product['stockDefaultSufficient'] = 0; // stockDefaultSufficient
$product['stockDefaultMax'] = 0; // stockDefaultMax
$product['manageStock'] = true; // manageStock
$product['replenishmentQuantity'] = 0; // replenishmentQuantity
$product['locationArea'] = ""; // manageStock
$product['nbCarton'] = 0; // nbCarton
$product['nbProductsCarton'] = 0; // nbCarton
$products[] = $product;
}
return new JsonResponse([
'status' => 'ok',
'page' => [
"current-page" => (int) $pageNumber,
"per-page" => (int) $perPage,
"total" => count($listingProducts),
"last-page" => $lastPage < 1 ? 1 : (int) $lastPage,
],
'result' => $products,
]);
}
/**
* Récupérer les catégories
* @Route("/mdm/categories")
*/
public function listCategories(Request $request)
{
$listingCategories = new DataObject\Category\Listing();
$categories = [];
$mdmUrl = self::$MDM_URL;
$now = new \DateTime();
$now->sub(new \DateInterval("PT15M"));
$perPage = $request->get('size') ? $request->get('size') : self::$PER_PAGE;
$pageNumber = $request->get('page') ? $request->get('page') : 1;
$offset = 0;
if ($pageNumber == 2) $offset = ($perPage);
if ($pageNumber > 2) $offset = ($perPage) * ($pageNumber - 1);
if (!$request->get('full')) {
$listingCategories->setCondition('o_modificationDate > ?', [$now->getTimestamp()]);
}
$listingCategories->setOffset($offset);
$listingCategories->setLimit($perPage);
$lastPage = (count($listingCategories) / $perPage);
if (is_float($lastPage)) {
$lastPage = intval($lastPage) + 1;
}
foreach ($listingCategories as $key => $listingCategory) {
$category['id'] = $listingCategory->getId();
$category['name'] = $listingCategory->getName();
$category['isActive'] = $listingCategory->getIsActive();
$category['slug'] = $listingCategory->getSlug();
$category['description'] = $listingCategory->getDescription();
$category['parentCategory'] = $listingCategory->getParent() ? $listingCategory->getParent()->getId() : null;
// url image
$hotspotImage = $listingCategory->getImage();
$thumbnailUrl = $hotspotImage ? sprintf('%s%s', $mdmUrl, $hotspotImage->getThumbnail()->getPath()) : null;
$category['image'] = $thumbnailUrl;
$categories[] = $category;
}
return new JsonResponse([
'status' => 'ok',
'page' => [
"current-page" => (int) $pageNumber,
"per-page" => (int) $perPage,
"total" => count($listingCategories),
"last-page" => $lastPage < 1 ? 1 : (int) $lastPage,
],
'result' => $categories,
]);
}
}