コード例 #1
0
ファイル: ConfigurableTest.php プロジェクト: nja78/magento2
 public function testGetChildrenIds()
 {
     $ids = $this->_model->getChildrenIds(1);
     // fixture
     $this->assertArrayHasKey(0, $ids);
     $this->assertTrue(2 === count($ids[0]));
     $ids = $this->_model->getChildrenIds(1, false);
     $this->assertArrayHasKey(0, $ids);
     $this->assertTrue(2 === count($ids[0]));
 }
コード例 #2
0
 /**
  * @param array $configurableIds
  * @param \Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer $subject
  *
  * @return array
  */
 private function reindexSubProducts(array $configurableIds, \Magento\CatalogRule\Model\Indexer\Product\ProductRuleIndexer $subject)
 {
     $subProducts = [];
     if ($configurableIds) {
         $subProducts = array_values($this->configurable->getChildrenIds($configurableIds)[0]);
         if ($subProducts) {
             $subject->executeList($subProducts);
         }
     }
     return $subProducts;
 }
コード例 #3
0
 /**
  * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
  * @magentoAppIsolation enabled
  */
 public function testSaveProductRelationsNoChildren()
 {
     $childrenIds = $this->product->getTypeInstance()->getChildrenIds($this->product->getId());
     self::assertNotEmpty(reset($childrenIds));
     $product = $this->productRepository->getById($this->product->getId(), true);
     $extensionAttributes = $product->getExtensionAttributes();
     $extensionAttributes->setConfigurableProductLinks([]);
     $product->setExtensionAttributes($extensionAttributes);
     $this->productRepository->save($product);
     self::assertEquals([[]], $this->model->getChildrenIds($this->product->getId()));
 }