Ejemplo n.º 1
0
 /**
  * Save bundle item price per website
  *
  * @param \Magento\Bundle\Model\Selection $item
  * @return void
  */
 public function saveSelectionPrice($item)
 {
     $connection = $this->getConnection();
     if ($item->getDefaultPriceScope()) {
         $connection->delete($this->getTable('catalog_product_bundle_selection_price'), ['selection_id = ?' => $item->getSelectionId(), 'website_id = ?' => $item->getWebsiteId()]);
     } else {
         $values = ['selection_id' => $item->getSelectionId(), 'website_id' => $item->getWebsiteId(), 'selection_price_type' => $item->getSelectionPriceType(), 'selection_price_value' => $item->getSelectionPriceValue()];
         $connection->insertOnDuplicate($this->getTable('catalog_product_bundle_selection_price'), $values, ['selection_price_type', 'selection_price_value']);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param \Magento\Bundle\Model\Selection $selectionModel
  * @param \Magento\Bundle\Api\Data\LinkInterface $productLink
  * @param string $linkedProductId
  * @param string $parentProductId
  * @return \Magento\Bundle\Model\Selection
  */
 protected function mapProductLinkToSelectionModel(\Magento\Bundle\Model\Selection $selectionModel, \Magento\Bundle\Api\Data\LinkInterface $productLink, $linkedProductId, $parentProductId)
 {
     $selectionModel->setProductId($linkedProductId);
     $selectionModel->setParentProductId($parentProductId);
     if ($productLink->getOptionId() !== null) {
         $selectionModel->setOptionId($productLink->getOptionId());
     }
     if ($productLink->getPosition() !== null) {
         $selectionModel->setPosition($productLink->getPosition());
     }
     if ($productLink->getQty() !== null) {
         $selectionModel->setSelectionQty($productLink->getQty());
     }
     if ($productLink->getPriceType() !== null) {
         $selectionModel->setSelectionPriceType($productLink->getPriceType());
     }
     if ($productLink->getPrice() !== null) {
         $selectionModel->setSelectionPriceValue($productLink->getPrice());
     }
     if ($productLink->getCanChangeQuantity() !== null) {
         $selectionModel->setSelectionCanChangeQty($productLink->getCanChangeQuantity());
     }
     if ($productLink->getIsDefault() !== null) {
         $selectionModel->setIsDefault($productLink->getIsDefault());
     }
     return $selectionModel;
 }
Ejemplo n.º 3
0
 /**
  * Save bundle item price per website
  *
  * @param \Magento\Bundle\Model\Selection $item
  * @return void
  */
 public function saveSelectionPrice($item)
 {
     $write = $this->_getWriteAdapter();
     if ($item->getDefaultPriceScope()) {
         $write->delete($this->getTable('catalog_product_bundle_selection_price'), array('selection_id = ?' => $item->getSelectionId(), 'website_id = ?' => $item->getWebsiteId()));
     } else {
         $values = array('selection_id' => $item->getSelectionId(), 'website_id' => $item->getWebsiteId(), 'selection_price_type' => $item->getSelectionPriceType(), 'selection_price_value' => $item->getSelectionPriceValue());
         $write->insertOnDuplicate($this->getTable('catalog_product_bundle_selection_price'), $values, array('selection_price_type', 'selection_price_value'));
     }
 }