setPosition example

protected $hideSortings;

    /** * @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));
        }
/** * Helper function which creates a variant image for the passed product image. * * @return Image */
    public function createVariantImage(Image $articleImage, Detail $variant)
    {
        $variantImage = new Image();
        $variantImage->setParent($articleImage);
        $variantImage->setArticleDetail($variant);
        $variantImage->setPosition($articleImage->getPosition());
        $variantImage->setMain($articleImage->getMain());
        $variantImage->setExtension($articleImage->getExtension());

        return $variantImage;
    }

    /** * @param Collection|array $options * * @return Mapping */
    
new EntityCollection($orderAddressRepositoryResultArray),
                    null,
                    new Criteria(),
                    Context::createDefaultContext()
                )
            );
        }

        $productDownload = new ProductDownloadEntity();
        $productDownload->setId(Uuid::randomHex());
        $productDownload->setMediaId(Uuid::randomHex());
        $productDownload->setPosition(0);
        $productDownloadRepository = $this->createMock(EntityRepository::class);
        $productDownloadRepository->method('search')->willReturnCallback(function DCriteria $criteria) use ($productDownload): EntitySearchResult {
            $filters = $criteria->getFilters();
            if (isset($filters[0]) && $filters[0] instanceof EqualsAnyFilter) {
                $value = ReflectionHelper::getPropertyValue($filters[0], 'value');
                $productDownload->setProductId($value[0] ?? null);
            }

            return new EntitySearchResult(
                'productDownload',
                1,
                
$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']);
        }

        


    /** * saves the positions of all children of this parent category */
    public function saveNewChildPositionsAction()
    {
        $ids = json_decode($this->Request()->getParam('ids'));
        foreach ($ids as $key => $categoryId) {
            /** @var Category $category */
            $category = $this->em->getReference(Category::class(int) $categoryId);
            $category->setPosition($key);
        }
        $this->em->flush();

        $this->View()->assign(['success' => true]);
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * Saves a single category. If no category id is passed, * the save function will create a new category model and persist * it. * * To successful saving a category a parent category id must supplied. */
$country->setTaxFreeForVatId((bool) $data['__country_taxfree_ustid']);
        }

        if (isset($data['__country_taxfree_ustid_checked'])) {
            $country->setVatIdCheck((bool) $data['__country_taxfree_ustid_checked']);
        }

        if (isset($data['__country_areaID'])) {
            $country->setAreaId((int) $data['__country_areaID']);
        }

        $country->setPosition((int) $data['__country_position']);
        $country->setActive((bool) $data['__country_active']);

        if ($data['__countryAttribute_id'] !== null) {
            $this->attributeHydrator->addAttribute($country$data, 'countryAttribute');
        }

        return $country;
    }

    /** * @return State */

        $shopPage->setId((int) $data['__page_id']);
        $shopPage->setTpl1Variable($data['__page_tpl1variable']);
        $shopPage->setTpl1Path($data['__page_tpl1path']);
        $shopPage->setTpl2Variable($data['__page_tpl2variable']);
        $shopPage->setTpl2Path($data['__page_tpl2path']);
        $shopPage->setTpl3Variable($data['__page_tpl3variable']);
        $shopPage->setTpl3Path($data['__page_tpl3path']);
        $shopPage->setDescription($data['__page_description']);
        $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']);
        }

        
$payment->setId($data['__payment_id']);
        $payment->setName($data['__payment_name']);
        $payment->setDescription($data['__payment_description']);
        $payment->setTemplate($data['__payment_template']);
        $payment->setClass($data['__payment_class']);
        $payment->setTable($data['__payment_table']);
        $payment->setHide($data['__payment_hide']);
        $payment->setAdditionalDescription(isset($data['__payment_additionalDescription']) ? $data['__payment_additionalDescription'] : $data['__payment_additionaldescription']);
        $payment->setDebitPercent($data['__payment_debit_percent']);
        $payment->setSurcharge($data['__payment_surcharge']);
        $payment->setSurchargeString($data['__payment_surchargestring']);
        $payment->setPosition($data['__payment_position']);
        $payment->setActive($data['__payment_active']);
        $payment->setEsdActive($data['__payment_esdactive']);
        $payment->setEmbediframe($data['__payment_embediframe']);
        $payment->setHideProspect($data['__payment_hideprospect']);
        $payment->setAction($data['__payment_action']);
        $payment->setPluginID($data['__payment_pluginID']);
        $payment->setSource($data['__payment_source']);
        $payment->setMobileInactive($data['__payment_mobile_inactive']);

        if (isset($data['__paymentAttribute_id'])) {
            $this->attributeHydrator->addAttribute($payment$data, 'paymentAttribute');
        }

    public function hydrateOption(array $data)
    {
        $option = new Option();
        $translation = $this->getTranslation($data, '__propertyOption', ['optionValue' => 'value']);
        $data = array_merge($data$translation);

        $option->setId((int) $data['__propertyOption_id']);
        $option->setName($data['__propertyOption_value']);
        $option->setPosition((int) $data['__propertyOption_position']);

        if ($data['__propertyOptionAttribute_id']) {
            $this->attributeHydrator->addAttribute($option$data, 'propertyOptionAttribute', 'core', 'propertyOption');
        }

        if (isset($data['__media_id']) && $data['__media_id']) {
            $option->setMedia(
                $this->mediaHydrator->hydrate($data)
            );
        }

        

        if ($namespace !== null) {
            $this->setNamespace($namespace);
        }
        if ($plugin !== null) {
            $this->setPlugin($plugin);
        }
        if ($listener !== null) {
            $this->setListener($listener);
        }
        parent::__construct($event);
        $this->setPosition($position);
    }

    /** * Setter method for the internal plugin property. * * @param mixed $plugin Enlight_Plugin_Bootstrap|string * * @return Enlight_Event_Handler_Plugin */
    public function setPlugin($plugin)
    {
        

        $productMedia = [];
        for ($i = 4; $i >= 0; --$i) {
            $mediaId = 'media' . $i;
            $mediaEntity = new MediaEntity();
            $mediaEntity->setId($mediaId);

            $tempProductMedia = new ProductMediaEntity();
            $tempProductMedia->setId($mediaId);
            $tempProductMedia->setMediaId($mediaId);
            $tempProductMedia->setMedia($mediaEntity);
            $tempProductMedia->setPosition($i);

            $productMedia[] = $tempProductMedia;
        }

        return new ProductMediaCollection($productMedia);
    }

    protected function getResolverContext(ProductMediaCollection $productMediaCollection, ?string $coverId = null): EntityResolverContext
    {
        $manufacturer = new ProductManufacturerEntity();
        $manufacturer->setId('manufacturer_01');

        
$item->setController($menuItem['controller'] ?? null);
        $item->setAction($menuItem['action'] ?? null);
        $item->setOnclick($menuItem['onclick'] ?? null);
        $item->setClass($menuItem['class'] ?? null);

        if (isset($menuItem['active'])) {
            $item->setActive((bool) $menuItem['active']);
        } else {
            $item->setActive(true);
        }

        $item->setPosition(isset($menuItem['position']) ? (int) $menuItem['position'] : 0);

        if (isset($menuItem['controller'])) {
            $name = $menuItem['controller'];

            // Index actions aren't appended to the name of the snippet, they are an exemption from the rule             if ($menuItem['action'] !== 'Index') {
                $name .= '/' . $menuItem['action'];
            }

            $this->saveMenuTranslation($menuItem['label']$name);
        }

        
'Event does not have method getEncodeValues'
        );
        static::assertEquals($event->getEncodeValues($shopwareVersion)$this->businessEventEncoder->encode($event));
    }

    public static function getEvents(): \Generator
    {
        $tax = new TaxEntity();
        $tax->setId('tax-id');
        $tax->setName('test');
        $tax->setTaxRate(19);
        $tax->setPosition(1);

        yield 'ScalarBusinessEvent' => [new ScalarBusinessEvent()];
        yield 'StructuredObjectBusinessEvent' => [new StructuredObjectBusinessEvent()];
        yield 'StructuredArrayObjectBusinessEvent' => [new StructuredArrayObjectBusinessEvent()];
        yield 'UnstructuredObjectBusinessEvent' => [new UnstructuredObjectBusinessEvent()];
        yield 'EntityBusinessEvent' => [new EntityBusinessEvent($tax)];
        yield 'CollectionBusinessEvent' => [new CollectionBusinessEvent(new TaxCollection([$tax]))];
        yield 'ArrayBusinessEvent' => [new ArrayBusinessEvent(new TaxCollection([$tax]))];
        yield 'NestedEntityBusinessEvent' => [new NestedEntityBusinessEvent($tax)];
    }

    
$emotion->setShowListing((bool) $data['__emotion_show_listing']);
        $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'])) {
            


            $sortingObj = new ManualSorting();
            $sortingObj->setCategory($category);

            $product = $this->getManager()->find(Product::class$sorting['product_id']);
            if (!$product instanceof Product) {
                throw new ModelNotFoundException(Product::class$sorting['product_id']);
            }

            $sortingObj->setProduct($product);
            $sortingObj->setPosition((int) $sorting['position']);

            $collection[] = $sortingObj;
        }

        $category->setManualSorting(null);
        $this->getManager()->flush($category);
        $category->setManualSorting($collection);

        unset($data['manualSorting']);

        return $data;
    }
Home | Imprint | This part of the site doesn't use cookies.