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


PHP Product::getPrice方法代码示例

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


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

示例1: testProductsUpdate

 /**
  * @magentoDbIsolation disabled
  * @magentoAppIsolation enabled
  * @magentoDataFixture Magento/Catalog/_files/price_row_fixture.php
  */
 public function testProductsUpdate()
 {
     $this->_product->load(1);
     $this->_processor->reindexList([$this->_product->getId()]);
     $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Model\\CategoryFactory');
     $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Block\\Product\\ListProduct');
     $category = $categoryFactory->create()->load(9);
     $layer = $listProduct->getLayer();
     $layer->setCurrentCategory($category);
     $productCollection = $layer->getProductCollection();
     $this->assertEquals(1, $productCollection->count());
     /** @var $product \Magento\Catalog\Model\Product */
     foreach ($productCollection as $product) {
         $this->assertEquals($this->_product->getId(), $product->getId());
         $this->assertEquals($this->_product->getPrice(), $product->getPrice());
     }
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:22,代码来源:RowsTest.php

示例2: getPrice

 /**
  * {@inheritdoc}
  */
 public function getPrice()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getPrice');
     if (!$pluginInfo) {
         return parent::getPrice();
     } else {
         return $this->___callPlugins('getPrice', func_get_args(), $pluginInfo);
     }
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:12,代码来源:Interceptor.php

示例3: assertProductInfo

 /**
  * @param \Magento\Catalog\Model\Product $product
  */
 private function assertProductInfo($product)
 {
     $data = [1 => ['sku' => 'simple', 'name' => 'Simple Product', 'price' => '10', 'qty' => '1', 'position' => '1'], 21 => ['sku' => 'virtual-product', 'name' => 'Virtual Product', 'price' => '10', 'qty' => '2', 'position' => '2']];
     $productId = $product->getId();
     $this->assertEquals($data[$productId]['sku'], $product->getSku());
     $this->assertEquals($data[$productId]['name'], $product->getName());
     $this->assertEquals($data[$productId]['price'], $product->getPrice());
     $this->assertEquals($data[$productId]['qty'], $product->getQty());
     $this->assertEquals($data[$productId]['position'], $product->getPosition());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:GroupedTest.php

示例4: getBasePrice

 /**
  * Get base price with apply Group, Tier, Special prises
  *
  * @param Product $product
  * @param float|null $qty
  *
  * @return float
  */
 public function getBasePrice($product, $qty = null)
 {
     $price = (double) $product->getPrice();
     return min($this->_applyGroupPrice($product, $price), $this->_applyTierPrice($product, $qty, $price), $this->_applySpecialPrice($product, $price));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Price.php

示例5: getProductPrice

 /**
  * Get product price including store convertion rate
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param null|string $format
  * @return float|string
  * @deprecated
  */
 public function getProductPrice($product, $format = null)
 {
     try {
         $value = $product->getPrice();
         $value = $format ? $this->priceCurrency->convertAndFormat($value) : $this->priceCurrency->convert($value);
     } catch (\Exception $e) {
         $value = $e->getMessage();
     }
     return $value;
 }
开发者ID:zhangjiachao,项目名称:magento2,代码行数:18,代码来源:Data.php

示例6: getProductPrice

 /**
  * Get product price including store convertion rate
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param null|string $format
  * @return float|string
  * @deprecated
  */
 public function getProductPrice($product, $format = null)
 {
     try {
         $value = $product->getPrice();
         $value = $this->_storeManager->getStore()->convertPrice($value, $format);
     } catch (\Exception $e) {
         $value = $e->getMessage();
     }
     return $value;
 }
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:18,代码来源:Data.php

示例7: getPrice

 /**
  * Retrieve product price
  *
  * @param ModelProduct $product
  * @return float
  */
 public function getPrice($product)
 {
     return $product->getPrice();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:10,代码来源:Product.php

示例8: getPrice

 /**
  * @return float
  */
 public function getPrice()
 {
     return parent::getPrice() * 3;
 }
开发者ID:varrek,项目名称:magento2module,代码行数:7,代码来源:Testproduct.php

示例9: convertAttribute

 /**
  * Set current attribute to entry (for specified product)
  *
  * @param \Magento\Catalog\Model\Product $product
  * @param \Magento\Framework\Gdata\Gshopping\Entry $entry
  * @return \Magento\Framework\Gdata\Gshopping\Entry
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function convertAttribute($product, $entry)
 {
     $entry->cleanTaxes();
     if ($this->_taxData->getConfig()->priceIncludesTax()) {
         return $entry;
     }
     $defaultCustomerTaxClassId = $this->_getDefaultCustomerTaxClassId($product->getStoreId());
     $rates = $this->_taxRateManagement->getRatesByCustomerAndProductTaxClassId($defaultCustomerTaxClassId, $product->getTaxClassId());
     $targetCountry = $this->_config->getTargetCountry($product->getStoreId());
     $ratesTotal = 0;
     foreach ($rates as $rate) {
         $countryId = $rate->getTaxCountryId();
         $postcode = $rate->getTaxPostcode();
         if ($targetCountry == $countryId) {
             $regions = $this->_getRegionsByRegionId($rate->getTaxRegionId(), $postcode);
             $ratesTotal += count($regions);
             if ($ratesTotal > self::RATES_MAX) {
                 throw new \Magento\Framework\Exception\LocalizedException(__('Google shopping only supports %1 tax rates per product', self::RATES_MAX));
             }
             foreach ($regions as $region) {
                 $adjustments = $product->getPriceInfo()->getAdjustments();
                 if (array_key_exists('tax', $adjustments)) {
                     $taxIncluded = true;
                 } else {
                     $taxIncluded = false;
                 }
                 $quoteDetailsItemDataArray = ['code' => $product->getSku(), 'type' => 'product', 'tax_class_key' => [TaxClassKeyInterface::KEY_TYPE => TaxClassKeyInterface::TYPE_ID, TaxClassKeyInterface::KEY_VALUE => $product->getTaxClassId()], 'unit_price' => $product->getPrice(), 'quantity' => 1, 'tax_included' => $taxIncluded, 'short_description' => $product->getName()];
                 $billingAddressDataArray = ['country_id' => $countryId, 'region' => ['region_id' => $rate->getTaxRegionId()], 'postcode' => $postcode];
                 $shippingAddressDataArray = ['country_id' => $countryId, 'region' => ['region_id' => $rate->getTaxRegionId()], 'postcode' => $postcode];
                 $quoteDetailsDataArray = ['billing_address' => $billingAddressDataArray, 'shipping_address' => $shippingAddressDataArray, 'customer_tax_class_key' => [TaxClassKeyInterface::KEY_TYPE => TaxClassKeyInterface::TYPE_ID, TaxClassKeyInterface::KEY_VALUE => $defaultCustomerTaxClassId], 'items' => [$quoteDetailsItemDataArray]];
                 $quoteDetailsObject = $this->_quoteDetailsFactory->create();
                 $this->dataObjectHelper->populateWithArray($quoteDetailsObject, $quoteDetailsDataArray, '\\Magento\\Tax\\Api\\Data\\QuoteDetailsInterface');
                 $taxDetails = $this->_taxCalculationService->calculateTax($quoteDetailsObject, $product->getStoreId());
                 $taxRate = $taxDetails->getTaxAmount() / $taxDetails->getSubtotal() * 100;
                 $entry->addTax(['tax_rate' => $taxRate, 'tax_country' => $countryId, 'tax_region' => $region]);
             }
         }
     }
     return $entry;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:48,代码来源:Tax.php

示例10: testGetPrice

 public function testGetPrice()
 {
     $this->assertEmpty($this->_model->getPrice());
     $this->_model->setPrice(10.0);
     $this->assertEquals(10.0, $this->_model->getPrice());
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:6,代码来源:ProductPriceTest.php


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