setUnit example

foreach ($products as $product) {
            $key = $product->getNumber();

            if (!\array_key_exists($key$priceRules) || empty($priceRules[$key])) {
                continue;
            }

            $productPrices = $priceRules[$key];

            foreach ($productPrices as $price) {
                if ($product->getUnit() instanceof Unit) {
                    $price->setUnit($product->getUnit());
                }
                $price->setCustomerGroup($group);
            }

            $prices[$key] = $productPrices;
        }

        return $prices;
    }
}

        $deliveryTime = $this->createDeliveryTime();

        return new DeliveryInformation(100, 10.0, false, null, $deliveryTime);
    }

    private function createDeliveryTime(): DeliveryTime
    {
        $deliveryTime = new DeliveryTime();
        $deliveryTime->setMin(2);
        $deliveryTime->setMax(2);
        $deliveryTime->setUnit(DeliveryTimeEntity::DELIVERY_TIME_MONTH);

        return $deliveryTime;
    }
}
$product->setManufacturer(
                $this->manufacturerHydrator->hydrate($data)
            );
        }

        if ($data['__esd_id']) {
            $product->setEsd(
                $this->esdHydrator->hydrate($data)
            );
        }

        $product->setUnit(
            $this->unitHydrator->hydrate($data)
        );

        if (!empty($data['__productAttribute_id'])) {
            $this->assignAttributeData($product$data);
        }

        return $product;
    }

    private function assignPriceGroupData(ListProduct $product, array $data): void
    {
protected $max;

    /** * @var string */
    protected $unit;

    public static function createFromEntity(DeliveryTimeEntity $entity): self
    {
        $self = new self();
        $self->setName((string) $entity->getTranslation('name'));
        $self->setUnit($entity->getUnit());
        $self->setMax($entity->getMax());
        $self->setMin($entity->getMin());

        return $self;
    }

    public function getName(): string
    {
        return $this->name;
    }

    
'handlerIdentifier' => SyncTestPaymentHandler::class,
                    'name' => 'Generated Payment',
                    'active' => true,
                ]
            );
        }

        if (!$shippingMethod) {
            $deliveryTime = new DeliveryTimeEntity();
            $deliveryTime->setMin(1);
            $deliveryTime->setMax(2);
            $deliveryTime->setUnit(DeliveryTimeEntity::DELIVERY_TIME_DAY);

            $shippingMethod = new ShippingMethodEntity();
            $shippingMethod->setDeliveryTime($deliveryTime);
            $shippingMethod->setId('8beeb66e9dda46b18891a059257a590e');
        }

        if (!$customer) {
            $customer = (new CustomerEntity())->assign(['id' => Uuid::randomHex()]);
            $customer->setId(Uuid::randomHex());
            $customer->setGroup($currentCustomerGroup);
        }

        
static::assertNotNull($taxRule);
        static::assertEquals(10, $taxRule->getTaxRate());
    }

    /** * @dataProvider mixedShippingProvider */
    public function testCalculateWithMixedFreeShipping(int $calculation, float $price, int $quantity): void
    {
        $shippingMethod = new ShippingMethodEntity();
        $deliveryTime = new DeliveryTimeEntity();
        $deliveryTime->setUnit('test');
        $deliveryTime->setMax(5);
        $deliveryTime->setMin(1);
        $shippingMethod->setDeliveryTime($deliveryTime);
        $shippingMethod->setId(Uuid::randomHex());
        $shippingMethod->setTaxType(ShippingMethodEntity::TAX_TYPE_AUTO);
        $currency = new CurrencyEntity();
        $currency->setId(Uuid::randomHex());

        $price1 = new ShippingMethodPriceEntity();
        $price1->setUniqueIdentifier(Uuid::randomHex());
        $price1->setQuantityStart(0);
        
// Price was recalculated         static::assertNotNull($originalCart->getExtension(DeliveryProcessor::MANUAL_SHIPPING_COSTS));
        static::assertNotNull($originalCart->getDeliveries()->first());
        static::assertSame(10.0, $originalCart->getDeliveries()->first()->getShippingCosts()->getTotalPrice());
    }

    private function generateDeliveryTimeDummy(): DeliveryTimeEntity
    {
        $deliveryTime = new DeliveryTimeEntity();
        $deliveryTime->setMin(1);
        $deliveryTime->setMax(3);
        $deliveryTime->setUnit(DeliveryTimeEntity::DELIVERY_TIME_DAY);

        return $deliveryTime;
    }
}
static::assertCount(1, $errors);
        static::assertInstanceOf(ShippingMethodBlockedError::class$errors->first());
        static::assertSame('shipping-method-blocked-Express', $errors->first()->getId());
    }

    private function generateDeliveryTimeDummy(): DeliveryTimeEntity
    {
        $deliveryTime = new DeliveryTimeEntity();
        $deliveryTime->setMin(1);
        $deliveryTime->setMax(3);
        $deliveryTime->setUnit(DeliveryTimeEntity::DELIVERY_TIME_DAY);

        return $deliveryTime;
    }
}

class StructHelper
{
    public function assignProductData(ListProduct $listProduct, ListProduct $product)
    {
        trigger_error(sprintf('%s:%s is deprecated since Shopware 5.6 and will be removed with 5.7. Will be removed without replacement.', __CLASS__, __METHOD__), E_USER_DEPRECATED);

        $product->setShippingFree($listProduct->isShippingFree());
        $product->setMainVariantId($listProduct->getMainVariantId());
        $product->setAllowsNotification($listProduct->allowsNotification());
        $product->setHighlight($listProduct->highlight());
        $product->setUnit($listProduct->getUnit());
        $product->setTax($listProduct->getTax());
        $product->setPrices($listProduct->getPrices());
        $product->setManufacturer($listProduct->getManufacturer());
        $product->setCover($listProduct->getCover());
        $product->setCheapestPrice($listProduct->getCheapestPrice());
        $product->setName($listProduct->getName());
        $product->setAdditional($listProduct->getAdditional());
        $product->setCloseouts($listProduct->isCloseouts());
        $product->setEan($listProduct->getEan());
        $product->setHeight($listProduct->getHeight());
        $product->setKeywords($listProduct->getKeywords());
        
$data = array_merge($data$translation);

        if (isset($data['__unit_id'])) {
            $unit->setId($id);
        }

        if (isset($data['__unit_description'])) {
            $unit->setName($data['__unit_description']);
        }

        if (isset($data['__unit_unit'])) {
            $unit->setUnit($data['__unit_unit']);
        }

        if (isset($data['__unit_packunit'])) {
            $unit->setPackUnit($data['__unit_packunit']);
        }

        if (isset($data['__unit_purchaseunit'])) {
            $unit->setPurchaseUnit((float) $data['__unit_purchaseunit']);
        }

        if (isset($data['__unit_referenceunit'])) {
            
$customerGroup = $this->getCustomerGroupRepository()->find($price['customerGroup']['id']);
            $price['customerGroup'] = $customerGroup;
        }

        $template = new Template();
        $template->fromArray($data);
        $template->setArticle($article);

        if ($data['unitId']) {
            $productUnit = $this->get('models')->find(Unit::class$data['unitId']);
            if ($productUnit !== null) {
                $template->setUnit($productUnit);
            }
        }

        $this->get('models')->persist($template);
        $this->get('models')->flush();

        $this->createConfiguratorTemplateTranslations($template);
    }

    /** * Copies all translations from an product into the respective configurator template */

    public function hydrateCheapestPrice(array $data)
    {
        $price = $this->hydratePriceRule($data);
        $translation = $this->productHydrator->getProductTranslation($data);
        $data = array_merge($data$translation);

        $unit = $this->unitHydrator->hydrate($data);
        $price->setUnit($unit);

        return $price;
    }

    /** * @param array $data * * @return PriceGroup */
    public function hydratePriceGroup($data)
    {
        
Home | Imprint | This part of the site doesn't use cookies.