Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Grouped.php
Go to the documentation of this file.
1 <?php
9 
14 class Grouped extends \Magento\Catalog\Block\Product\View\AbstractView
15 {
19  public function getAssociatedProducts()
20  {
21  return $this->getProduct()->getTypeInstance()->getAssociatedProducts($this->getProduct());
22  }
23 
29  public function setPreconfiguredValue()
30  {
31  $configValues = $this->getProduct()->getPreconfiguredValues()->getSuperGroup();
32  if (is_array($configValues)) {
33  $associatedProducts = $this->getAssociatedProducts();
34  foreach ($associatedProducts as $item) {
35  if (isset($configValues[$item->getId()])) {
36  $item->setQty($configValues[$item->getId()]);
37  }
38  }
39  }
40  return $this;
41  }
42 }