/** * Prepare product and its configuration to be added to some products list. * Perform standard preparation process and then prepare options for downloadable links. * * @param \Magento\Framework\Object $buyRequest * @param \Magento\Catalog\Model\Product $product * @param string $processMode * @return \Magento\Framework\Phrase|array|string * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _prepareProduct(\Magento\Framework\Object $buyRequest, $product, $processMode) { $result = parent::_prepareProduct($buyRequest, $product, $processMode); if (is_string($result)) { return $result; } // if adding product from admin area we add all links to product $originalLinksPurchasedSeparately = null; if ($product->getSkipCheckRequiredOption()) { $originalLinksPurchasedSeparately = $product->getLinksPurchasedSeparately(); $product->setLinksPurchasedSeparately(false); } $preparedLinks = []; if ($product->getLinksPurchasedSeparately()) { if ($links = $buyRequest->getLinks()) { foreach ($this->getLinks($product) as $link) { if (in_array($link->getId(), $links)) { $preparedLinks[] = $link->getId(); } } } } else { foreach ($this->getLinks($product) as $link) { $preparedLinks[] = $link->getId(); } } if (null !== $originalLinksPurchasedSeparately) { $product->setLinksPurchasedSeparately($originalLinksPurchasedSeparately); } if ($preparedLinks) { $product->addCustomOption('downloadable_link_ids', implode(',', $preparedLinks)); return $result; } if ($this->getLinkSelectionRequired($product) && $this->_isStrictProcessMode($processMode)) { return __('Please specify product link(s).')->render(); } return $result; }
public function testHasWeightFalse() { $this->assertFalse($this->_model->hasWeight(), 'This product has weight, but it should not'); }