Example #1
0
 /**
  * Check this option if it should be skipped
  *
  * @param \Magento\Bundle\Model\Option $option
  * @param bool $canSkipRequiredOption
  * @return bool
  */
 protected function canSkipOption($option, $canSkipRequiredOption)
 {
     return !$option->getSelections() || $canSkipRequiredOption && !$option->getRequired();
 }
Example #2
0
 /**
  * Retrieve option value of bundle product
  *
  * @param \Magento\Bundle\Model\Option $option
  * @return string
  */
 protected function getFormattedOptionValues($option)
 {
     return 'name' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $option->getTitle() . ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR . 'type' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $option->getType() . ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR . 'required' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $option->getRequired();
 }
Example #3
0
 /**
  * Get formed data from selections of option
  *
  * @param Option $option
  * @param Product $product
  * @return array
  */
 private function getSelections(Option $option, Product $product)
 {
     $selections = [];
     $selectionCount = count($option->getSelections());
     foreach ($option->getSelections() as $selectionItem) {
         /* @var $selectionItem Product */
         $selectionId = $selectionItem->getSelectionId();
         $selections[$selectionId] = $this->getSelectionItemData($product, $selectionItem);
         if (($selectionItem->getIsDefault() || $selectionCount == 1 && $option->getRequired()) && $selectionItem->isSalable()) {
             $this->selectedOptions[$option->getId()][] = $selectionId;
         }
     }
     return $selections;
 }