getConfiguratorSet example


    protected function prepareConfiguratorSet($data, ProductModel $article)
    {
        if (!isset($data['configuratorSet'])) {
            return $data;
        }

        $configuratorSet = $article->getConfiguratorSet();
        if (!$configuratorSet) {
            $configuratorSet = new Set();
            $number = $data['mainDetail']['number'] ?? $article->getMainDetail()->getNumber();

            $configuratorSet->setName('Set-' . $number);
            $configuratorSet->setPublic(false);
        }

        if (isset($data['configuratorSet']['type'])) {
            $configuratorSet->setType($data['configuratorSet']['type']);
        }

        
/** * Event listener function of the configurator set model in the product backend module. */
    public function saveConfiguratorSetAction()
    {
        $data = $this->Request()->getParams();
        $id = (int) $data['id'];
        $productId = (int) $data['articleId'];

        if (!empty($productId)) {
            $product = $this->get('models')->find(Product::class$productId);
            if ($product->getConfiguratorSet()->getId() !== $id) {
                $this->get('models')->remove($product->getConfiguratorSet());
                $this->get('models')->flush();
            }
        }

        if (!empty($id) && $id > 0) {
            $configuratorSet = $this->get('models')->find(Set::class$id);
        } else {
            $configuratorSet = new Set();
        }
        if (!$configuratorSet) {
            
/** * Resolves the passed configuratorOptions parameter for a single variant. * Each passed configurator option, has to be configured in the product configurator set. * * @throws CustomValidationException * * @return array */
    protected function prepareConfigurator(array $data, ProductModel $article, Detail $variant)
    {
        if (!$article->getConfiguratorSet()) {
            throw new CustomValidationException('A configurator set has to be defined');
        }

        $availableGroups = $article->getConfiguratorSet()->getGroups();

        $options = new ArrayCollection();

        foreach ($data['configuratorOptions'] as $optionData) {
            $availableGroup = $this->getAvailableGroup($availableGroups[
                'id' => $optionData['groupId'] ?? null,
                'name' => $optionData['group'] ?? null,
            ]);
Home | Imprint | This part of the site doesn't use cookies.