Example #1
0
 public function execute(Quote $quote, Product $product)
 {
     $ids = $this->_configurableTypeInstance->getParentIdsByChild($product->getId());
     if (empty($ids)) {
         return $quote->addProductAdvanced($product);
     }
     if (count($ids) > 1) {
         throw new Exception("too many parents defined");
     }
     $parent = $this->createProduct();
     $parent->load($ids[0]);
     ///....
 }
Example #2
0
 /**
  * @depends testGetConfigurableAttributesAsArray
  */
 public function testGetParentIdsByChild()
 {
     $attributes = $this->_model->getConfigurableAttributesAsArray($this->_product);
     $attribute = reset($attributes);
     $optionValueId = $attribute['values'][0]['value_index'];
     $result = $this->_model->getParentIdsByChild($optionValueId * 10);
     // fixture
     $this->assertEquals(array(1), $result);
 }