setParentId example

->load($product->getParentId() ?? $product->getId()$request$context$reviewCriteria)
            ->getResult();

        $matrix = $this->getReviewRatingMatrix($reviews);

        $reviewResult = ProductReviewResult::createFrom($reviews);
        $reviewResult->setMatrix($matrix);
        $reviewResult->setProductId($product->getId());
        $reviewResult->setCustomerReview($this->getCustomerReview($product->getId()$context));
        $reviewResult->setTotalReviews($matrix->getTotalReviewCount());
        $reviewResult->setProductId($product->getId());
        $reviewResult->setParentId($product->getParentId() ?? $product->getId());

        return $reviewResult;
    }

    private function createReviewCriteria(Request $request, SalesChannelContext $context): Criteria
    {
        $limit = (int) $request->get('limit', self::LIMIT);
        $page = (int) $request->get('p', self::DEFAULT_PAGE);
        $offset = $limit * ($page - 1);

        $criteria = new Criteria();
        
$shopPage->setHtml($data['__page_html']);
        $shopPage->setGrouping(explode('|', $data['__page_grouping']));
        $shopPage->setPosition((int) $data['__page_position']);
        $shopPage->setLink($data['__page_link']);
        $shopPage->setTarget($data['__page_target']);
        $shopPage->setPageTitle($data['__page_page_title']);
        $shopPage->setMetaKeywords($data['__page_meta_keywords']);
        $shopPage->setMetaDescription($data['__page_meta_description']);
        $shopPage->setChildrenCount((int) $data['__page_children_count']);

        if (isset($data['__page_parent_id']) && $data['__page_parent_id'] > 0) {
            $shopPage->setParentId((int) $data['__page_parent_id']);
        }

        if (!empty($data['__page_changed'])) {
            $shopPage->setChanged(DateTime::createFromFormat('Y-m-d H:i:s', $data['__page_changed']));
        }

        $shopIds = [];

        if (isset($data['__page_shop_ids'])) {
            $shopIds = explode('|', $data['__page_shop_ids']);
            $shopIds = array_keys(array_flip($shopIds));
            
$emotion->setIsLandingPage((bool) $data['__emotion_is_landingpage']);
        $emotion->setSeoTitle($data['__emotion_seo_title']);
        $emotion->setSeoKeywords($data['__emotion_seo_keywords']);
        $emotion->setSeoDescription($data['__emotion_seo_description']);
        $emotion->setCreateDate($this->createDate($data['__emotion_create_date']));
        $emotion->setModifiedDate($this->createDate($data['__emotion_modified']));
        $emotion->setTemplateId((int) $data['__emotion_template_id']);
        $emotion->setDevices(array_map('\intval', explode(',', $data['__emotion_device'])));
        $emotion->setFullscreen((bool) $data['__emotion_fullscreen']);
        $emotion->setMode($data['__emotion_mode']);
        $emotion->setPosition((int) $data['__emotion_position']);
        $emotion->setParentId($data['__emotion_parent_id'] !== null ? (int) $data['__emotion_parent_id'] : null);
        $emotion->setIsPreview((bool) $data['__emotion_preview_id']);
        $emotion->setPreviewSecret($data['__emotion_preview_secret']);
        $emotion->setCategoryIds(array_map('\intval', explode(',', $data['__emotion_category_ids'])));
        $emotion->setShopIds(array_map('\intval', explode(',', $data['__emotion_shop_ids'])));

        // assign template         $this->assignTemplate($emotion$data);

        // assign attribute         if (!empty($data['__emotionAttribute_id'])) {
            $this->attributeHydrator->addAttribute($emotion$data, 'emotionAttribute');
        }

    protected $customerScope;

    /** * @return Shop */
    public static function createFromShopEntity(ShopEntity $shop)
    {
        $struct = new self();
        $struct->setId($shop->getId());
        $struct->setParentId($shop->getMain() ? $shop->getMain()->getId() : $shop->getId());

        $struct->setCustomerScope($shop->getMain() ? $shop->getMain()->getCustomerScope() : $shop->getCustomerScope());
        $struct->setIsDefault($shop->getDefault());
        $struct->setName($shop->getName());
        $struct->setHost($shop->getHost());
        $struct->setPath($shop->getBasePath());
        $struct->setUrl($shop->getBaseUrl());
        $struct->setSecure($shop->getSecure());
        if ($shop->getCategory()) {
            $struct->setCategory(
                Category::createFromCategoryEntity($shop->getCategory())
            );


        $newProductId = $variantResponse->getFoundCombination()->getVariantId();

        $result = $this->productRoute->load($newProductId$request$contextnew Criteria());
        $product = $result->getProduct();
        $configurator = $result->getConfigurator();

        $request->request->set('parentId', $product->getParentId());
        $request->request->set('productId', $product->getId());
        $reviews = $this->productReviewLoader->load($request$context);
        $reviews->setParentId($product->getParentId() ?? $product->getId());

        $event = new SwitchBuyBoxVariantEvent($elementId$product$configurator$request$context);
        $this->eventDispatcher->dispatch($event);

        $response = $this->renderStorefront('@Storefront/storefront/component/buy-widget/buy-widget.html.twig', [
            'product' => $product,
            'configuratorSettings' => $configurator,
            'totalReviews' => $reviews->getTotalReviews(),
            'elementId' => $elementId,
        ]);
        $response->headers->set('x-robots-tag', 'noindex');

        
$parent->setId('3e352be2d85846dd97529c0f6b544870');
        $parent->setChildCount(1);
        $parent->setUseParentConfiguration(false);
        $parent->setCreatedAt(new \DateTime('2012-08-15T00:00:00.000+00:00'));
        $parent->setUpdatedAt(new \DateTime('2017-11-21T11:25:34.000+00:00'));
        $parent->internalSetEntityData('media_folder', new FieldVisibility([]));

        $child = new MediaFolderEntity();
        $child->setId('5846dd97529c0f6b5448713e352be2d8');
        $child->setChildCount(1);
        $child->setUseParentConfiguration(true);
        $child->setParentId('3e352be2d85846dd97529c0f6b544870');
        $child->setCreatedAt(new \DateTime('2012-08-15T00:00:00.000+00:00'));
        $child->setUpdatedAt(new \DateTime('2017-11-21T11:25:34.000+00:00'));
        $child->internalSetEntityData('media_folder', new FieldVisibility([]));
        $parent->setChildren(new MediaFolderCollection([$child]));

        return new MediaFolderCollection([$parent]);
    }

    /** * @return array<string, mixed> */
    
/** * @param array $data * * @return CategoryStruct */
    public function hydrateCategory($data)
    {
        $category = new CategoryStruct();

        $category->setId($data['categoryId']);
        $category->setName($data['name']);
        $category->setParentId($data['parentId']);

        return $category;
    }

    /** * @param array $data */
    public function assignLocalData(PluginStruct $plugin$data)
    {
        $plugin->setId((int) ($data['id'] ?? 0));
        $plugin->setTechnicalName($data['name']);
        
/** * @return Category */
    public static function createFromCategoryEntity(CategoryEntity $category)
    {
        $struct = new self();

        $struct->setId($category->getId());
        $struct->setName($category->getName());
        $struct->setPosition($category->getPosition());
        $struct->setParentId($category->getParentId());

        $path = $category->getPath();
        if ($path) {
            $path = ltrim($path, '|');
            $path = rtrim($path, '|');

            $path = explode('|', $path);
            $path = array_map('\intval', $path);

            $struct->setPath(array_reverse($path));
        }

        
$orderLineItemEntity->setIdentifier($id);
        $orderLineItemEntity->setLabel(Uuid::randomHex());
        $orderLineItemEntity->setGood(true);
        $orderLineItemEntity->setRemovable(true);
        $orderLineItemEntity->setStackable(false);
        $orderLineItemEntity->setQuantity($quantity);

        if ($parentId === null) {
            return $orderLineItemEntity;
        }

        $orderLineItemEntity->setParentId($parentId);

        return $orderLineItemEntity;
    }
}
if ($current < $reference) {
                $reference = $current;
                $cheapest = $price;
            }
        }
        // @codeCoverageIgnoreEnd
        $object = new CheapestPrice();
        $object->setRuleId($cheapest['rule_id']);
        $object->setVariantId($cheapest['variant_id']);
        $object->setParentId($cheapest['parent_id']);
        $object->setHasRange($hasRange);
        $object->setPurchase($cheapest['purchase_unit'] ? (float) $cheapest['purchase_unit'] : null);
        $object->setReference($cheapest['reference_unit'] ? (float) $cheapest['reference_unit'] : null);
        $object->setUnitId($cheapest['unit_id'] ?? null);

        $prices = [];

        $blueprint = new Price('', 1, 1, true);

        foreach ($cheapest['price'] as $row) {
            $price = clone $blueprint;
            
$shop->setCurrency($this->currencyHydrator->hydrate($data));
        $shop->setCustomerGroup($this->customerGroupHydrator->hydrate($data));
        $shop->setCategory($this->categoryHydrator->hydrate($data));
        $shop->setLocale($this->localeHydrator->hydrate($data));

        $parent = $data;
        if ($data['parent']) {
            $parent = $data['parent'];
        }

        $shop->setTemplate($this->templateHydrator->hydrate($parent));
        $shop->setParentId((int) $parent['__shop_id']);
        $shop->setHost($parent['__shop_host']);
        $shop->setPath($parent['__shop_base_path']);
        $shop->setCustomerScope((bool) $parent['__shop_customer_scope']);
        $shop->setUrl($data['__shop_base_url'] ?: $parent['__shop_base_url']);
        $shop->setSecure((bool) $parent['__shop_secure']);

        $hosts = [];
        if ($parent['__shop_hosts']) {
            $hosts = explode('\n', $parent['__shop_hosts']);
            $hosts = array_unique(array_values(array_filter($hosts)));
        }
        
public function hydrate($data)
    {
        $template = new Template();
        $template->setId((int) $data['__template_id']);
        $template->setTemplate($data['__template_template']);
        $template->setName($data['__template_name']);
        $template->setDescription($data['__template_description']);
        $template->setAuthor($data['__template_author']);
        $template->setLicense($data['__template_license']);
        $template->setVersion((int) $data['__template_version']);
        $template->setPluginId((int) $data['__template_plugin_id']);
        $template->setParentId((int) $data['__template_parent_id']);

        return $template;
    }
}
$fieldConfig->add(new FieldConfig('product', FieldConfig::SOURCE_MAPPED, $investigatedProductId));
        $fieldConfig->add(new FieldConfig('alignment', FieldConfig::SOURCE_STATIC, null));

        $slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('buy-box');
        $slot->setFieldConfig($fieldConfig);

        $variantProduct = new SalesChannelProductEntity();
        $variantProduct->setId($investigatedProductId);
        if (isset($variantIds[0])) {
            $variantProduct->setParentId($productId);
        }
        $variantProduct->setOptionIds([Uuid::randomHex()]);

        $resolverContext = new EntityResolverContext(
            $salesChannelContext,
            new Request(),
            $this->createMock(SalesChannelProductDefinition::class),
            $variantProduct
        );

        $result = new ElementDataCollection();

        
$path = explode('|', $path);
            $path = array_map('\intval', $path);

            $category->setPath(array_reverse($path));
        }

        if (isset($data['__category_description'])) {
            $category->setName($data['__category_description']);
        }

        $category->setParentId((int) $data['__category_parent_id']);

        $category->setPosition((int) $data['__category_position']);

        $category->setProductBoxLayout($data['__category_product_box_layout']);

        if (isset($data['__category_metatitle'])) {
            $category->setMetaTitle($data['__category_metatitle']);
        }

        if (isset($data['__category_metakeywords'])) {
            $category->setMetaKeywords($data['__category_metakeywords']);
        }

        $ruleIds = $this->getIds('rule');

        if ($parent->getActionName() !== null) {
            return $this->buildActionSequence($parent);
        }

        $randomRuleId = $this->faker->randomElement($ruleIds);

        $sequence = FlowSequenceEntity::createFrom($parent);
        $sequence->setId(Uuid::randomHex());
        $sequence->setParentId($parent->getId());
        $sequence->setRuleId($randomRuleId);
        $sequence->setPosition($parent->getPosition() + 1);
        $sequence->setTrueCase($trueCase);
        $sequence->assign([
            'actionName' => null,
        ]);

        $this->ids['rule'] = array_filter($ruleIdsfn ($ruleId) => $ruleId !== $randomRuleId);

        return $sequence;
    }

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