prepareProducts example

protected function setUp(): void
    {
        $this->productRepository = $this->getContainer()->get('product.repository');
        $this->statesUpdater = $this->getContainer()->get(StatesUpdater::class);
        $this->connection = $this->getContainer()->get(Connection::class);
    }

    public function testUpdateProductStates(): void
    {
        $ids = new IdsCollection();
        $this->prepareProducts($ids);

        $productIds = $ids->prefixed('product-');
        $this->statesUpdater->update($productIds, Context::createDefaultContext());

        $products = $this->productRepository
            ->search(new Criteria($productIds), Context::createDefaultContext())
            ->getEntities();

        $product1 = $products->get($ids->get('product-1'));
        $product2 = $products->get($ids->get('product-2'));
        $product3 = $products->get($ids->get('product-3'));

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