⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.1
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
proc
/
thread-self
/
root
/
home
/
category
/
Edit File: ByrakController.php
<?php declare(strict_types=1); namespace Byrak\NestedCategoryDropdownPlugin\Controller; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsAnyFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\MultiFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\NotFilter; use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting; use Shopware\Core\PlatformRequest; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Shopware\Storefront\Framework\Routing\RequestTransformer; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Shopware\Storefront\Controller\StorefrontController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; /** * @internal * @Route(defaults={"_routeScope"={"storefront"}, "_acl"={"system.plugin_maintain"}}) */ class ByrakController extends StorefrontController { private $scategory; /** * @Route("/filter-categories-pro-ajax", name="frontend.filter.categories.pro.ajax", methods={"GET", "POST"}) */ public function index(Request $request): Response//JsonResponse //string // { $salesChannelContext = $request->attributes->get(PlatformRequest::ATTRIBUTE_SALES_CHANNEL_CONTEXT_OBJECT); $salesChannelId = $salesChannelContext->getSalesChannelId(); $languageId = $salesChannelContext->getLanguageId(); $shopUrl = $request->attributes->get(RequestTransformer::STOREFRONT_URL); $config = $this->config ?? $this->getSystemConfigService()->get('ByrakNestedCategoryDropdownPlugin.config', $salesChannelId); $getSelect = $request->get('select'); $getSupplier = $request->get('supplier'); $getSeries = $request->get('series'); $getParts = $request->get('parts'); $getModel = $request->get('model'); $getPosition = $request->get('pos'); $getCurrentCat = $request->get('currentcat'); /* return new JsonResponse([ 'iFilterSelect' => $getSelect, 'iFilterSearchActSupplier' => $getSupplier, 'iFilterSearchActSeries' => $getSeries, 'iFilterConfig' => $config, // 'iFilterCategories' => $categories, ]); */ return $this->renderStorefront('@ByrakNestedCategoryDropdownPlugin/storefront/byrak/ajax.html.twig', [ 'iFilterSelect' => $getSelect, 'iFilterSearchActSupplier' => $getSupplier, 'iFilterSearchActSeries' => $getSeries, 'iFilterConfig' => $config, 'iFilterCategories' => $this->getCategories($salesChannelContext), ]); } /** * @Route("/get-categorie/{catId}/{hersteller}/{bereich}/{serie}", name="get_categorie", methods={"GET", "POST"}) */ public function getCategories(SalesChannelContext $salesChannelContext,$catId=null, $hersteller=null,$bereich=null,$serie=null): JsonResponse|array { $salesChannelId = $salesChannelContext->getSalesChannelId(); $config = $this->config ?? $this->getSystemConfigService()->get('ByrakNestedCategoryDropdownPlugin.config', $salesChannelId); $maincat = $config['ideemaincategoryPro']; $nofiltered = explode(",", $config['ideenofilteredcatPro']); $sortHerst = $config['ideeorderSupplierPro']; $sortBerei = $config['ideeorderPartPro']; $sortSerie = $config['ideeorderSeriePro']; $sortModel = $config['ideeorderModelPro']; $nur2 = $config['ideehideSeriePro']; $nur4 = $config['ideeshowPartPro']; $categoryRepository = $this->container->get('category.repository'); // c $criteria = new Criteria(); if ($nur4) { $criteria->addAssociation('parent'); // p $criteria->addAssociation('parent.parent'); // y $criteria->addAssociation('parent.parent.parent'); // x $criteria->addFilter(new ContainsFilter('path', '|' . $maincat . '|')); $criteria->addFilter(new EqualsFilter('active', true)); $criteria->addFilter(new EqualsFilter('parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parent.parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parent.parent.parentId', $maincat)); if( $hersteller ) { $criteria->addFilter(new EqualsFilter('parent.parent.parent.id', $hersteller)); } if( $bereich ) { $criteria->addFilter(new EqualsFilter('parent.parent.id', $hersteller)); } if( $serie ) { $criteria->addFilter(new EqualsFilter('parent.id', $hersteller)); } if ($nofiltered) { $criteria->addFilter(new NotFilter( MultiFilter::CONNECTION_AND, [ new EqualsAnyFilter('id', $nofiltered), new EqualsAnyFilter('parent.id', $nofiltered), new EqualsAnyFilter('parent.parent.id', $nofiltered), new EqualsAnyFilter('parent.parent.parent.id', $nofiltered) ] )); } // Hersteller ... if( $sortHerst == 'NameDESC' ) $criteria->addSorting(new FieldSorting('parent.parent.parent.description', FieldSorting::DESCENDING)); else if( $sortHerst == 'PosASC' ) $criteria->addSorting(new FieldSorting('parent.parent.parent.position', FieldSorting::ASCENDING)); else if( $sortHerst == 'PosDESC' ) $criteria->addSorting(new FieldSorting('parent.parent.parent.position', FieldSorting::DESCENDING)); else if( $sortHerst == 'IdASC' ) $criteria->addSorting(new FieldSorting('parent.parent.parent.id', FieldSorting::ASCENDING)); else if( $sortHerst == 'IdDESC' ) $criteria->addSorting(new FieldSorting('parent.parent.parent.id', FieldSorting::DESCENDING)); else $criteria->addSorting(new FieldSorting('parent.parent.parent.description', FieldSorting::ASCENDING)); // Bereich (wenn aktiv) ... if( $sortBerei == 'NameDESC' ) $criteria->addSorting(new FieldSorting('parent.parent.description', FieldSorting::DESCENDING)); else if( $sortBerei == 'PosASC' ) $criteria->addSorting(new FieldSorting('parent.parent.position', FieldSorting::ASCENDING)); else if( $sortBerei == 'PosDESC' ) $criteria->addSorting(new FieldSorting('parent.parent.position', FieldSorting::DESCENDING)); else if( $sortBerei == 'IdASC' ) $criteria->addSorting(new FieldSorting('parent.parent.id', FieldSorting::ASCENDING)); else if( $sortBerei == 'IdDESC' ) $criteria->addSorting(new FieldSorting('parent.parent.id', FieldSorting::DESCENDING)); else $criteria->addSorting(new FieldSorting('parent.parent.description', FieldSorting::ASCENDING)); // Serie ... if( $sortSerie == 'NameDESC' ) $criteria->addSorting(new FieldSorting('parent.description', FieldSorting::DESCENDING)); else if( $sortSerie == 'PosASC' ) $criteria->addSorting(new FieldSorting('parent.position', FieldSorting::ASCENDING)); else if( $sortSerie == 'PosDESC' ) $criteria->addSorting(new FieldSorting('parent.position', FieldSorting::DESCENDING)); else if( $sortSerie == 'IdASC' ) $criteria->addSorting(new FieldSorting('parent.id', FieldSorting::ASCENDING)); else if( $sortSerie == 'IdDESC' ) $criteria->addSorting(new FieldSorting('parent.id', FieldSorting::DESCENDING)); else $criteria->addSorting(new FieldSorting('parent.description', FieldSorting::ASCENDING)); // Modell (wenn aktiv) ... if( !$nur2 ) { if( $sortModel == 'NameDESC' ) $criteria->addSorting(new FieldSorting('description', FieldSorting::DESCENDING)); else if( $sortModel == 'PosASC' ) $criteria->addSorting(new FieldSorting('position', FieldSorting::ASCENDING)); else if( $sortModel == 'PosDESC' ) $criteria->addSorting(new FieldSorting('position', FieldSorting::DESCENDING)); else if( $sortModel == 'IdASC' ) $criteria->addSorting(new FieldSorting('id', FieldSorting::ASCENDING)); else if( $sortModel == 'IdDESC' ) $criteria->addSorting(new FieldSorting('id', FieldSorting::DESCENDING)); else $criteria->addSorting(new FieldSorting('description', FieldSorting::ASCENDING)); } $categories=$categoryRepository->search($criteria, $salesChannelContext->getContext())->getElements(); foreach( $categories as $c ){ $herst = $c->getParent()->getParent()->getParent()->getId(); $serie = $c->getParent()->getId(); if( $nur2 ) { // 2 Ebenen ... $model = $c->getParent()->getId(); } else { // 3 Ebenen ... $model = $c->getId(); } $this->scategories['hersteller'][ $herst ]['id'] = $herst; $this->scategories['hersteller'][ $herst ]['title'] = $c->getParent()->getParent()->getParent()->getName(); $berei = $c->getParent()->getParent()->getId(); $this->scategories['hersteller'][ $herst ]['part'][ $berei ]['id'] = $berei; $this->scategories['hersteller'][ $herst ]['part'][ $berei ]['title'] = $c->getParent()->getParent()->getName(); $this->scategories['aktiverBereich'][ $model ] = $berei; $this->scategories['aktiverBereich'][ $serie ] = $berei; $this->scategories['aktiverBereich'][ $berei ] = $berei; $this->scategories['aktiverBereich'][ $herst ] = $berei; $this->scategories['aktivesModel'][ $berei ] = $model; $this->scategories['aktiveSerie'][ $berei ] = $serie; $this->scategories['aktiverHersteller'][ $berei ] = $herst; $this->scategories['hersteller'][ $herst ]['part'][ $berei ]['serie'][ $serie ]['id'] = $serie; $this->scategories['hersteller'][ $herst ]['part'][ $berei ]['serie'][ $serie ]['title'] = $c->getParent()->getName(); $this->scategories['hersteller'][ $herst ]['part'][ $berei ]['serie'][ $serie ]['model'][ $model ]['id'] = $model; $this->scategories['hersteller'][ $herst ]['part'][ $berei ]['serie'][ $serie ]['model'][ $model ]['title'] = $c->getName(); $this->scategories['aktivesModel'][ $model ] = $model; $this->scategories['aktiveSerie'][ $serie ] = $serie; $this->scategories['aktiveSerie'][ $model ] = $serie; $this->scategories['aktiverHersteller'][ $serie ] = $herst; $this->scategories['aktiverHersteller'][ $model ] = $herst; $this->scategories['aktiverHersteller'][ $herst ] = $herst; } } else if ($nur2) { $criteria->addAssociation('parent'); // x $criteria->addFilter(new ContainsFilter('path', '|' . $maincat . '|')); $criteria->addFilter(new EqualsFilter('active', true)); $criteria->addFilter(new EqualsFilter('parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parentId', $maincat)); if( $hersteller ) { $criteria->addFilter(new EqualsFilter('parent.id', $hersteller)); } if( $serie ) { $criteria->addFilter(new EqualsFilter('id', $serie)); } if ($nofiltered) { $criteria->addFilter(new NotFilter( MultiFilter::CONNECTION_AND, [ new EqualsAnyFilter('id', $nofiltered), new EqualsAnyFilter('parent.id', $nofiltered) ] )); } // Hersteller ... if( $sortHerst == 'NameDESC' ) $criteria->addSorting(new FieldSorting('parent.description', FieldSorting::DESCENDING)); else if( $sortHerst == 'PosASC' ) $criteria->addSorting(new FieldSorting('parent.position', FieldSorting::ASCENDING)); else if( $sortHerst == 'PosDESC' ) $criteria->addSorting(new FieldSorting('parent.position', FieldSorting::DESCENDING)); else if( $sortHerst == 'IdASC' ) $criteria->addSorting(new FieldSorting('parent.id', FieldSorting::ASCENDING)); else if( $sortHerst == 'IdDESC' ) $criteria->addSorting(new FieldSorting('parent.id', FieldSorting::DESCENDING)); else $criteria->addSorting(new FieldSorting('parent.description', FieldSorting::ASCENDING)); // Serie ... if( $sortSerie == 'NameDESC' ) $criteria->addSorting(new FieldSorting('description', FieldSorting::DESCENDING)); else if( $sortSerie == 'PosASC' ) $criteria->addSorting(new FieldSorting('position', FieldSorting::ASCENDING)); else if( $sortSerie == 'PosDESC' ) $criteria->addSorting(new FieldSorting('position', FieldSorting::DESCENDING)); else if( $sortSerie == 'IdASC' ) $criteria->addSorting(new FieldSorting('id', FieldSorting::ASCENDING)); else if( $sortSerie == 'IdDESC' ) $criteria->addSorting(new FieldSorting('id', FieldSorting::DESCENDING)); else $criteria->addSorting(new FieldSorting('description', FieldSorting::ASCENDING)); $categories=$categoryRepository->search($criteria, $salesChannelContext->getContext())->getElements(); foreach( $categories as $c ){ $herst = $c->getParent()->getId(); $serie = $c->getId(); $model = $c->getId(); $this->scategories['hersteller'][ $herst ]['id'] = $herst; $this->scategories['hersteller'][ $herst ]['title'] = $c->getParent()->getName(); $this->scategories['hersteller'][ $herst ]['serie'][ $serie ]['id'] = $serie; $this->scategories['hersteller'][ $herst ]['serie'][ $serie ]['title'] = $c->getName(); $this->scategories['hersteller'][ $herst ]['serie'][ $serie ]['model'][ $model ]['id'] = $model; $this->scategories['aktivesModel'][ $model ] = $model; // aktive Kategorie -> Modell-ID $this->scategories['aktiveSerie'][ $serie ] = $serie; // aktive Kategorie -> Serien-ID $this->scategories['aktiveSerie'][ $model ] = $serie; $this->scategories['aktiverHersteller'][ $serie ] = $herst; // aktive Kategorie -> Hersteller-ID $this->scategories['aktiverHersteller'][ $model ] = $herst; $this->scategories['aktiverHersteller'][ $herst ] = $herst; } ///////////////// kategori cek //////////// /// } else { $criteria->addAssociation('parent'); // p $criteria->addAssociation('parent.parent'); // x $criteria->addFilter(new ContainsFilter('path', '|' . $maincat . '|')); $criteria->addFilter(new EqualsFilter('active', true)); $criteria->addFilter(new EqualsFilter('parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parent.parentId', $maincat)); if( $hersteller ) { $criteria->addFilter(new EqualsFilter('parent.parent.id', $hersteller)); } if( $serie ) { $criteria->addFilter(new EqualsFilter('parent.id', $hersteller)); } if ($nofiltered) { $criteria->addFilter(new NotFilter( MultiFilter::CONNECTION_AND, [ new EqualsAnyFilter('id', $nofiltered), new EqualsAnyFilter('parent.id', $nofiltered), new EqualsAnyFilter('parent.parent.id', $nofiltered) ] )); } // Hersteller ... if( $sortHerst == 'NameDESC' ) $criteria->addSorting(new FieldSorting('parent.parent.description', FieldSorting::DESCENDING)); else if( $sortHerst == 'PosASC' ) $criteria->addSorting(new FieldSorting('parent.parent.position', FieldSorting::ASCENDING)); else if( $sortHerst == 'PosDESC' ) $criteria->addSorting(new FieldSorting('parent.parent.position', FieldSorting::DESCENDING)); else if( $sortHerst == 'IdASC' ) $criteria->addSorting(new FieldSorting('parent.parent.id', FieldSorting::ASCENDING)); else if( $sortHerst == 'IdDESC' ) $criteria->addSorting(new FieldSorting('parent.parent.id', FieldSorting::DESCENDING)); else $criteria->addSorting(new FieldSorting('parent.parent.description', FieldSorting::ASCENDING)); // Serie ... if( $sortSerie == 'NameDESC' ) $criteria->addSorting(new FieldSorting('parent.description', FieldSorting::DESCENDING)); else if( $sortSerie == 'PosASC' ) $criteria->addSorting(new FieldSorting('parent.position', FieldSorting::ASCENDING)); else if( $sortSerie == 'PosDESC' ) $criteria->addSorting(new FieldSorting('parent.position', FieldSorting::DESCENDING)); else if( $sortSerie == 'IdASC' ) $criteria->addSorting(new FieldSorting('parent.id', FieldSorting::ASCENDING)); else if( $sortSerie == 'IdDESC' ) $criteria->addSorting(new FieldSorting('parent.id', FieldSorting::DESCENDING)); else $criteria->addSorting(new FieldSorting('parent.description', FieldSorting::ASCENDING)); // Modell (wenn aktiv) ... if( !$nur2 ) { if( $sortModel == 'NameDESC' ) $criteria->addSorting(new FieldSorting('description', FieldSorting::DESCENDING)); else if( $sortModel == 'PosASC' ) $criteria->addSorting(new FieldSorting('position', FieldSorting::ASCENDING)); else if( $sortModel == 'PosDESC' ) $criteria->addSorting(new FieldSorting('position', FieldSorting::DESCENDING)); else if( $sortModel == 'IdASC' ) $criteria->addSorting(new FieldSorting('id', FieldSorting::ASCENDING)); else if( $sortModel == 'IdDESC' ) $criteria->addSorting(new FieldSorting('id', FieldSorting::DESCENDING)); else $criteria->addSorting(new FieldSorting('description', FieldSorting::ASCENDING)); } $categories=$categoryRepository->search($criteria, $salesChannelContext->getContext())->getElements(); ///////////////// kategori cek //////////// /// foreach( $categories as $c ){ $herst = $c->getParent()->getParent()->getId(); $serie = $c->getParent()->getId(); $model = $c->getId(); $this->scategories['hersteller'][ $herst ]['id'] = $herst; $this->scategories['hersteller'][ $herst ]['title'] = $c->getParent()->getParent()->getName(); $this->scategories['hersteller'][ $herst ]['serie'][ $serie ]['id'] = $serie; $this->scategories['hersteller'][ $herst ]['serie'][ $serie ]['title'] = $c->getParent()->getName(); $this->scategories['hersteller'][ $herst ]['serie'][ $serie ]['model'][ $model ]['id'] = $model; $this->scategories['hersteller'][ $herst ]['serie'][ $serie ]['model'][ $model ]['title'] = $c->getName(); $this->scategories['aktivesModel'][ $model ] = $model; // aktive Kategorie -> Modell-ID $this->scategories['aktiveSerie'][ $serie ] = $serie; // aktive Kategorie -> Serien-ID $this->scategories['aktiveSerie'][ $model ] = $serie; $this->scategories['aktiverHersteller'][ $serie ] = $herst; // aktive Kategorie -> Hersteller-ID $this->scategories['aktiverHersteller'][ $model ] = $herst; $this->scategories['aktiverHersteller'][ $herst ] = $herst; } } return new JsonResponse($this->scategories); } /** * @Route("/get-categorie-list/{alsString}/{articleID}", name="get_categorie_new", methods={"GET", "POST"}) */ public function getKategorienJeArtikel(SalesChannelContext $salesChannelContext, $alsString = false, $articleID = 1): JsonResponse|array { $salesChannelId = $salesChannelContext->getSalesChannelId(); $config = $this->config ?? $this->getSystemConfigService()->get('ByrakNestedCategoryDropdownPlugin.config', $salesChannelId); $criteria = new Criteria(); $productRepository = $this->container->get('category.repository'); $maincat = $config['ideemaincategoryPro']; $nofiltered = explode(",", $config['ideenofilteredcatPro']); $sortHerst = $config['ideeorderSupplierPro']; $sortBerei = $config['ideeorderPartPro']; $sortSerie = $config['ideeorderSeriePro']; $sortModel = $config['ideeorderModelPro']; $nur2 = $config['ideehideSeriePro']; $nur4 = $config['ideeshowPartPro']; if ($nur4) { $criteria->addAssociation('product'); $criteria->addAssociation('product_category.parent'); $criteria->addAssociation('product_category.parent.parent'); $criteria->addAssociation('product_category.parent.parent.parent'); $criteria->addFilter(new ContainsFilter('product_category.path', '|' . $maincat . '|')); $criteria->addFilter(new EqualsFilter('active', true)); $criteria->addFilter(new EqualsFilter('active', true)); $criteria->addFilter(new EqualsFilter('parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parent.parent.active', true)); if ($nofiltered) { $criteria->addFilter(new NotFilter( MultiFilter::CONNECTION_AND, [ new EqualsAnyFilter('id', $nofiltered), new EqualsAnyFilter('parent.id', $nofiltered), new EqualsAnyFilter('parent.parent.id', $nofiltered), new EqualsAnyFilter('parent.parent.parent.id', $nofiltered) ] )); } } elseif ($nur2) { $criteria->addAssociation('parent'); $criteria->addAssociation('parent.parent'); $criteria->addFilter(new ContainsFilter('path', '|' . $maincat . '|')); $criteria->addFilter(new EqualsFilter('parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parent.active', true)); if ($nofiltered) { $criteria->addFilter(new NotFilter( MultiFilter::CONNECTION_AND, [ new EqualsAnyFilter('parent.id', $nofiltered), new EqualsAnyFilter('parent.parent.id', $nofiltered), ] )); } } else { $criteria->addAssociation('parent'); $criteria->addAssociation('parent.parent'); $criteria->addFilter(new EqualsFilter('active', true)); $criteria->addFilter(new EqualsFilter('parent.active', true)); $criteria->addFilter(new EqualsFilter('parent.parent.active', true)); if ($nofiltered) { $criteria->addFilter(new NotFilter( MultiFilter::CONNECTION_AND, [ new EqualsAnyFilter('id', $nofiltered), new EqualsAnyFilter('parent.id', $nofiltered), new EqualsAnyFilter('parent.parent.id', $nofiltered) ] )); } } $dataArray = ($productRepository->search($criteria, $salesChannelContext->getContext())->getElements()); return new JsonResponse($dataArray); } /** * @Route("/get-product-list/{articleID}/", name="get_product_new_new", methods={"GET", "POST"}) */ public function getKategorienproduct(SalesChannelContext $salesChannelContext, $articleID = "018CD5133A4E7336BE0685C1D8A4C3BE"): JsonResponse|array { $salesChannelId = $salesChannelContext->getSalesChannelId(); $config = $this->config ?? $this->getSystemConfigService()->get('ByrakNestedCategoryDropdownPlugin.config', $salesChannelId); $maincat = $config['ideemaincategoryPro']; $productRepository = $this->container->get('category.repository'); $criteria = new Criteria(); $criteria->addFilter(new ContainsFilter('path', '|' . $maincat . '|')); $criteria->addFilter(new EqualsFilter('active', 1)); $criteria->addAssociation('products'); $criteria->addAssociation('parent'); $criteria->addAssociation('parent.parent'); $criteria->addAssociation('parent.parent.parent'); $criteria->addFilter(new EqualsFilter('id', $articleID)); $product = $productRepository->search($criteria, $salesChannelContext->getContext())->getEntities()->first(); return new JsonResponse($product); } }
Simpan