getCategoryTree example

'isCloseout' => $product->getIsCloseout(),
            'customFields' => $product->getCustomFields(),
            'createdAt' => $product->getCreatedAt() ? $product->getCreatedAt()->format(Defaults::STORAGE_DATE_TIME_FORMAT) : null,
            'releaseDate' => $product->getReleaseDate() ? $product->getReleaseDate()->format(Defaults::STORAGE_DATE_TIME_FORMAT) : null,
            'isNew' => $product->isNew(),
            'markAsTopseller' => $product->getMarkAsTopseller(),
            'purchasePrices' => $purchasePrices ? json_encode($purchasePrices, \JSON_THROW_ON_ERROR) : null,
            'productNumber' => $product->getProductNumber(),
            'manufacturerId' => $product->getManufacturerId(),
            'taxId' => $product->getTaxId(),
            'tagIds' => $product->getTagIds(),
            'categoryIds' => $product->getCategoryTree(),
            'propertyIds' => $product->getPropertyIds(),
            'optionIds' => $product->getOptionIds(),
            'options' => $product->getVariation(),
            'streamIds' => $product->getStreamIds(),
            'parentId' => $product->getParentId(),
            'stock' => $product->getStock(),
        ];

        $lineItem->replacePayload($payload['purchasePrices' => true]);
    }

    


    /** * @return list<string>|null */
    private function getProductCategoryList(string $productId): ?array
    {
        $productRepository = $this->getContainer()->get('product.repository');
        /** @var ProductEntity $testableProduct */
        $testableProduct = $productRepository->search(new Criteria([$productId])$this->context)->first();

        $productCategoryIds = $testableProduct->getCategoryTree();
        if ($productCategoryIds !== null) {
            \sort($productCategoryIds);
        }

        return $productCategoryIds;
    }

    /** * @param list<string> $categoryIds */
    private function getCountRowsInProductCategoryTree(string $productId, array $categoryIds): int
    {
$repository->create($categories, Context::createDefaultContext());

        $products = $this->repository->search(new Criteria([$productId]), Context::createDefaultContext());

        static::assertCount(1, $products);
        static::assertTrue($products->has($productId));

        /** @var ProductEntity $product */
        $product = $products->get($productId);

        static::assertInstanceOf(ProductEntity::class$product);
        static::assertIsArray($product->getCategoryTree());
        static::assertContains($categoryId$product->getCategoryTree());
    }

    public function testWriteProductOverManufacturer(): void
    {
        $productId = Uuid::randomHex();
        $manufacturerId = Uuid::randomHex();

        $manufacturers = [
            [
                'id' => $manufacturerId,
                
use Shopware\Models\Site\Site;

class Shopware_Controllers_Frontend_Sitemap extends Enlight_Controller_Action
{
    /** * Shows a category tree * * @return void */
    public function indexAction()
    {
        $categoryTree = $this->getCategoryTree();
        $additionalTrees = $this->getAdditionalTrees();

        $additionalTrees = $this->container->get('events')->filter(
            'Shopware_Modules_Sitemap_indexAction',
            $additionalTrees,
            ['subject' => $this]
        );

        $categoryTree = array_merge($categoryTree$additionalTrees);
        $this->View()->assign('sCategoryTree', $categoryTree);
    }

    
Home | Imprint | This part of the site doesn't use cookies.