当前位置: 首页>>代码示例>>PHP>>正文


PHP Product::getPriceType方法代码示例

本文整理汇总了PHP中Magento\Catalog\Model\Product::getPriceType方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::getPriceType方法的具体用法?PHP Product::getPriceType怎么用?PHP Product::getPriceType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Catalog\Model\Product的用法示例。


在下文中一共展示了Product::getPriceType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getProduct

 /**
  * @return SaleableInterface
  */
 public function getProduct()
 {
     if ($this->bundleProduct->getPriceType() == Price::PRICE_TYPE_DYNAMIC) {
         return parent::getProduct();
     } else {
         return $this->bundleProduct;
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:BundleSelectionPrice.php

示例2: aroundValidate

 /**
  * @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject
  * @param \Closure $proceed
  * @param \Magento\Catalog\Model\Product|\Magento\Framework\Object $object
  * @return bool
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundValidate(\Magento\Catalog\Model\Product\Attribute\Backend\Price $subject, \Closure $proceed, $object)
 {
     if ($object instanceof \Magento\Catalog\Model\Product && $object->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE && $object->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC) {
         return true;
     } else {
         return $proceed($object);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:PriceBackend.php

示例3: createDataFromModel

 /**
  * @param Product $product
  * @param Product $bundle
  * @return Metadata
  */
 public function createDataFromModel(Product $product, Product $bundle)
 {
     $selectionPriceType = $selectionPrice = null;
     /** @var \Magento\Bundle\Model\Selection $product */
     if ($bundle->getPriceType()) {
         $selectionPriceType = $product->getSelectionPriceType();
         $selectionPrice = $product->getSelectionPriceValue();
     }
     $this->builder->populateWithArray($product->getData())->setDefault($product->getIsDefault())->setQty($product->getSelectionQty())->setDefined($product->getSelectionCanChangeQty())->setPrice($selectionPrice)->setPriceType($selectionPriceType);
     return $this->builder->create();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:MetadataConverter.php

示例4: getValue

 /**
  * Get the price value for one of selection product
  *
  * @return bool|float
  */
 public function getValue()
 {
     if (null !== $this->value) {
         return $this->value;
     }
     if ($this->bundleProduct->getPriceType() == Price::PRICE_TYPE_DYNAMIC) {
         $value = $this->priceInfo->getPrice(FinalPrice::PRICE_CODE)->getValue();
     } else {
         if ($this->product->getSelectionPriceType()) {
             // calculate price for selection type percent
             $price = $this->bundleProduct->getPriceInfo()->getPrice(CatalogPrice\RegularPrice::PRICE_CODE)->getValue();
             $product = clone $this->bundleProduct;
             $product->setFinalPrice($price);
             $this->eventManager->dispatch('catalog_product_get_final_price', array('product' => $product, 'qty' => $this->bundleProduct->getQty()));
             $value = $product->getData('final_price') * ($this->product->getSelectionPriceValue() / 100);
         } else {
             // calculate price for selection type fixed
             $value = $this->product->getSelectionPriceValue() * $this->quantity;
         }
     }
     $this->value = $this->discountCalculator->calculateDiscount($this->bundleProduct, $value);
     return $this->value;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:28,代码来源:BundleSelectionPrice.php

示例5: beforeSave

 /**
  * Disable MAP if it's bundle with dynamic price type
  *
  * @param \Magento\Catalog\Model\Product $product
  * @return $this
  */
 public function beforeSave($product)
 {
     if (!$product instanceof \Magento\Catalog\Model\Product || $product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE || $product->getPriceType() != \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC) {
         return parent::beforeSave($product);
     }
     parent::beforeSave($product);
     $attributeCode = $this->getAttribute()->getName();
     $value = $product->getData($attributeCode);
     if (empty($value)) {
         $value = $this->_catalogData->isMsrpApplyToAll();
     }
     if ($value) {
         $product->setData($attributeCode, 0);
     }
     return $this;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:22,代码来源:Msrp.php

示例6: afterInitialize

 /**
  * Setting Bundle Items Data to product for father processing
  *
  * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject
  * @param \Magento\Catalog\Model\Product $product
  *
  * @return \Magento\Catalog\Model\Product
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function afterInitialize(\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $subject, \Magento\Catalog\Model\Product $product)
 {
     if (($items = $this->request->getPost('bundle_options')) && !$product->getCompositeReadonly()) {
         $product->setBundleOptionsData($items);
     }
     if (($selections = $this->request->getPost('bundle_selections')) && !$product->getCompositeReadonly()) {
         $product->setBundleSelectionsData($selections);
     }
     if ($product->getPriceType() == '0' && !$product->getOptionsReadonly()) {
         $product->setCanSaveCustomOptions(true);
         if ($customOptions = $product->getProductOptions()) {
             foreach (array_keys($customOptions) as $key) {
                 $customOptions[$key]['is_delete'] = 1;
             }
             $product->setProductOptions($customOptions);
         }
     }
     $product->setCanSaveBundleSelections((bool) $this->request->getPost('affect_bundle_product_selections') && !$product->getCompositeReadonly());
     return $product;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:30,代码来源:Bundle.php

示例7: buildLink

 /**
  * @param \Magento\Catalog\Model\Product $selection
  * @param \Magento\Catalog\Model\Product $product
  * @return \Magento\Bundle\Api\Data\LinkInterface
  */
 private function buildLink(\Magento\Catalog\Model\Product $selection, \Magento\Catalog\Model\Product $product)
 {
     $selectionPriceType = $selectionPrice = null;
     /** @var \Magento\Bundle\Model\Selection $product */
     if ($product->getPriceType()) {
         $selectionPriceType = $selection->getSelectionPriceType();
         $selectionPrice = $selection->getSelectionPriceValue();
     }
     /** @var \Magento\Bundle\Api\Data\LinkInterface $link */
     $link = $this->linkFactory->create();
     $this->dataObjectHelper->populateWithArray($link, $selection->getData(), '\\Magento\\Bundle\\Api\\Data\\LinkInterface');
     $link->setIsDefault($selection->getIsDefault())->setQty($selection->getSelectionQty())->setIsDefined($selection->getSelectionCanChangeQty())->setPrice($selectionPrice)->setPriceType($selectionPriceType);
     return $link;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:19,代码来源:LinkManagement.php

示例8: processDynamicOptionsData

 /**
  * @param \Magento\Catalog\Model\Product $product
  * @return void
  */
 protected function processDynamicOptionsData(\Magento\Catalog\Model\Product $product)
 {
     if ((int) $product->getPriceType() !== \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC) {
         return;
     }
     if ($product->getOptionsReadonly()) {
         return;
     }
     $product->setCanSaveCustomOptions(true);
     $customOptions = $product->getProductOptions();
     if (!$customOptions) {
         return;
     }
     foreach (array_keys($customOptions) as $key) {
         $customOptions[$key]['is_delete'] = 1;
     }
     $newOptions = $product->getOptions();
     foreach ($customOptions as $customOptionData) {
         if ((bool) $customOptionData['is_delete']) {
             continue;
         }
         $customOption = $this->customOptionFactory->create(['data' => $customOptionData]);
         $customOption->setProductSku($product->getSku());
         $customOption->setOptionId(null);
         $newOptions[] = $customOption;
     }
     $product->setOptions($newOptions);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:32,代码来源:Bundle.php

示例9: getSelectionFinalTotalPrice

 /**
  * Calculate final price of selection
  * with take into account tier price
  *
  * @param  \Magento\Catalog\Model\Product $bundleProduct
  * @param  \Magento\Catalog\Model\Product $selectionProduct
  * @param  float                    $bundleQty
  * @param  float                    $selectionQty
  * @param  bool                       $multiplyQty
  * @param  bool                       $takeTierPrice
  * @return float
  */
 public function getSelectionFinalTotalPrice($bundleProduct, $selectionProduct, $bundleQty, $selectionQty, $multiplyQty = true, $takeTierPrice = true)
 {
     if (null === $bundleQty) {
         $bundleQty = 1.0;
     }
     if ($selectionQty === null) {
         $selectionQty = $selectionProduct->getSelectionQty();
     }
     if ($bundleProduct->getPriceType() == self::PRICE_TYPE_DYNAMIC) {
         $price = $selectionProduct->getFinalPrice($takeTierPrice ? $selectionQty : 1);
     } else {
         if ($selectionProduct->getSelectionPriceType()) {
             // percent
             $product = clone $bundleProduct;
             $product->setFinalPrice($this->getPrice($product));
             $this->_eventManager->dispatch('catalog_product_get_final_price', ['product' => $product, 'qty' => $bundleQty]);
             $price = $product->getData('final_price') * ($selectionProduct->getSelectionPriceValue() / 100);
         } else {
             // fixed
             $price = $selectionProduct->getSelectionPriceValue();
         }
     }
     if ($multiplyQty) {
         $price *= $selectionQty;
     }
     return min($price, $this->_applyGroupPrice($bundleProduct, $price), $this->_applyTierPrice($bundleProduct, $bundleQty, $price), $this->_applySpecialPrice($bundleProduct, $price));
 }
开发者ID:opexsw,项目名称:magento2,代码行数:39,代码来源:Price.php

示例10: calculateBundleAmount

 /**
  * Calculate amount for bundle product with all selection prices
  *
  * @param float $basePriceValue
  * @param Product $bundleProduct
  * @param \Magento\Bundle\Pricing\Price\BundleSelectionPrice[] $selectionPriceList
  * @param null|string $exclude
  * @return \Magento\Framework\Pricing\Amount\AmountInterface
  */
 public function calculateBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude = null)
 {
     if ($bundleProduct->getPriceType() == Price::PRICE_TYPE_FIXED) {
         return $this->calculateFixedBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
     } else {
         return $this->calculateDynamicBundleAmount($basePriceValue, $bundleProduct, $selectionPriceList, $exclude);
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:17,代码来源:Calculator.php

示例11: getConfigData

 /**
  * Get formed config data from calculated options data
  *
  * @param Product $product
  * @param array $options
  * @return array
  */
 private function getConfigData(Product $product, array $options)
 {
     $isFixedPrice = $this->getProduct()->getPriceType() == \Magento\Bundle\Model\Product\Price::PRICE_TYPE_FIXED;
     $productAmount = $product->getPriceInfo()->getPrice(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)->getPriceWithoutOption();
     $baseProductAmount = $product->getPriceInfo()->getPrice(\Magento\Catalog\Pricing\Price\RegularPrice::PRICE_CODE)->getAmount();
     $config = ['options' => $options, 'selected' => $this->selectedOptions, 'bundleId' => $product->getId(), 'priceFormat' => $this->localeFormat->getPriceFormat(), 'prices' => ['oldPrice' => ['amount' => $isFixedPrice ? $baseProductAmount->getValue() : 0], 'basePrice' => ['amount' => $isFixedPrice ? $productAmount->getBaseAmount() : 0], 'finalPrice' => ['amount' => $isFixedPrice ? $productAmount->getValue() : 0]], 'priceType' => $product->getPriceType(), 'isFixedPrice' => $isFixedPrice];
     return $config;
 }
开发者ID:Coplex,项目名称:magento2,代码行数:15,代码来源:Bundle.php


注:本文中的Magento\Catalog\Model\Product::getPriceType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。