createRule example

static::assertContains($ids->get('position1')$affected['order_delivery_position']);
        static::assertContains($ids->get('position2')$affected['order_delivery_position']);
    }

    public function testOnlyIncludesAffectedDeleteRestrictionsWithDirectRelation(): void
    {
        $ids = new IdsCollection();
        $context = Context::createDefaultContext();

        $ruleDefinition = $this->getContainer()->get(RuleDefinition::class);

        $this->createRule($ids);
        $this->createShippingMethod($ids);
        $this->createSalesChannel($ids);

        $deleteIds = [
            'id' => $ids->get('rule'),
        ];

        $affected = $this->getContainer()->get(EntityForeignKeyResolver::class)
            ->getAffectedDeleteRestrictions($ruleDefinition$deleteIds$context, true);

        static::assertCount(1, $affected);
        
$promotionId = Uuid::randomHex();
        $code = 'BF' . Random::getAlphanumericString(5);

        // add 4 test products         $this->createTestFixtureProduct($set1ProductId1, 10, 10, $this->getContainer()$this->context);
        $this->createTestFixtureProduct($set1ProductId2, 20, 10, $this->getContainer()$this->context);
        $this->createTestFixtureProduct($set2ProductId1, 30, 10, $this->getContainer()$this->context);
        $this->createTestFixtureProduct($set2ProductId2, 40, 10, $this->getContainer()$this->context);

        // add 2 test rules         $ruleId1 = $this->createRule('Group1Rule', [$set1ProductId1$set1ProductId2]$this->getContainer());
        $ruleId2 = $this->createRule('Group2Rule', [$set2ProductId1$set2ProductId2]$this->getContainer());

        $groupId1 = 'c5dd14614714432cb145a2642d80fd23';
        $groupId2 = 'c1fb8da6d041481c962a1a9f62639c87';

        // add a new promotion and two setGroup discounts         $this->createTestFixtureSetGroupPromotion($promotionId$code$this->getContainer());
        $this->createSetGroupWithRuleFixture($groupId1, 'COUNT', 4, 'PRICE_ASC', $promotionId$ruleId1$this->getContainer());
        $this->createSetGroupWithRuleFixture($groupId2, 'COUNT', 4, 'PRICE_ASC', $promotionId$ruleId2$this->getContainer());
        $discountId1 = $this->createSetGroupDiscount($promotionId, 1, $this->getContainer(), 100, null);
        $discountId2 = $this->createSetGroupDiscount($promotionId, 2, $this->getContainer(), 100, null);

        


    public function update(Connection $connection): void
    {
        $templateTypeId = $connection->fetchOne('SELECT id FROM mail_template_type WHERE technical_name = :name', ['name' => MailTemplateTypes::MAILTYPE_DOWNLOADS_DELIVERY]);
        $templateId = $connection->fetchOne('SELECT id FROM mail_template WHERE mail_template_type_id = :id', ['id' => $templateTypeId]);

        if ($templateId === false) {
            $templateId = null;
        }

        $ruleId = $this->createRule($connection);
        $this->createFlow($connection$ruleId$templateId);
        $this->createFlowTemplate($connection$ruleId$templateId);
    }

    public function updateDestructive(Connection $connection): void
    {
        // nth     }

    private function createRule(Connection $connection): string
    {
        

    }

    public function testImportExportAdvancedPrices(): void
    {
        $context = Context::createDefaultContext();
        $context->addState(EntityIndexerRegistry::DISABLE_INDEXING);

        $productId = 'e12a77e8ed6642698b987250d8ec705d';
        $ruleId = 'cb34dc6f20b6479aa975e1290f442e65';
        $this->createProduct($productId);
        $this->createRule($ruleId);

        $progress = $this->import($context, ProductPriceDefinition::ENTITY_NAME, '/fixtures/advanced_prices.csv', 'advanced_prices.csv');

        static::assertImportExportSucceeded($progress$this->getInvalidLogContent($progress->getInvalidRecordsLogId()));

        /** @var ProductEntity $product */
        $product = $this->productRepository->search((new Criteria([$productId]))->addAssociation('prices')$context)->first();

        static::assertInstanceOf(ProductPriceCollection::class$product->getPrices());
        static::assertEquals(2, $product->getPrices()->count());
        $firstPrice = $product->getPrices()->first();

        
static::assertFalse($this->columnExists($con));

        $m = new Migration1681382023AddCustomFieldAllowCartExpose();
        $m->update($con);

        static::assertTrue($this->columnExists($con));

        $con->setNestTransactionsWithSavepoints(true);
        $con->beginTransaction();

        $this->createCustomFields();
        $this->createRule();

        static::assertEquals(['0', '0', '0']$this->getExposeSettings($con));

        $m->update($con);

        static::assertEquals(['1', '0', '1']$this->getExposeSettings($con));

        $con->rollBack();
    }

    private function columnExists(Connection $connection): bool
    {
Home | Imprint | This part of the site doesn't use cookies.