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


PHP Product::getQty方法代码示例

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


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

示例1: getValue

 /**
  * Get the price value for one of selection product
  *
  * @return bool|float
  */
 public function getValue()
 {
     if (null !== $this->value) {
         return $this->value;
     }
     $priceCode = $this->useRegularPrice ? BundleRegularPrice::PRICE_CODE : FinalPrice::PRICE_CODE;
     if ($this->bundleProduct->getPriceType() == Price::PRICE_TYPE_DYNAMIC) {
         // just return whatever the product's value is
         $value = $this->priceInfo->getPrice($priceCode)->getValue();
     } else {
         // don't multiply by quantity.  Instead just keep as quantity = 1
         $selectionPriceValue = $this->selection->getSelectionPriceValue();
         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', ['product' => $product, 'qty' => $this->bundleProduct->getQty()]);
             $value = $product->getData('final_price') * ($selectionPriceValue / 100);
         } else {
             // calculate price for selection type fixed
             $value = $this->priceCurrency->convert($selectionPriceValue) * $this->quantity;
         }
     }
     if (!$this->useRegularPrice) {
         $value = $this->discountCalculator->calculateDiscount($this->bundleProduct, $value);
     }
     $this->value = $this->priceCurrency->round($value);
     return $this->value;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:35,代码来源:BundleSelectionPrice.php

示例2: 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

示例3: 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

示例4: getQty

 /**
  * Retrieve Qty from item
  *
  * @param \Magento\Wishlist\Model\Item|\Magento\Catalog\Model\Product $item
  * @return float
  */
 public function getQty($item)
 {
     $qty = $item->getQty() * 1;
     if (!$qty) {
         $qty = 1;
     }
     return $qty;
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:14,代码来源:AbstractBlock.php

示例5: getUpdateParams

 /**
  * Retrieve params for updating product in wishlist
  *
  * @param \Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item
  *
  * @return  string|false
  */
 public function getUpdateParams($item)
 {
     $itemId = null;
     if ($item instanceof \Magento\Catalog\Model\Product) {
         $itemId = $item->getWishlistItemId();
         $productId = $item->getId();
     }
     if ($item instanceof \Magento\Wishlist\Model\Item) {
         $itemId = $item->getId();
         $productId = $item->getProduct()->getId();
     }
     $url = $this->_getUrl('wishlist/index/updateItemOptions');
     if ($itemId) {
         $params = ['id' => $itemId, 'product' => $productId, 'qty' => $item->getQty()];
         return $this->_postDataHelper->getPostData($url, $params);
     }
     return false;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:Data.php

示例6: testGetQty

 /**
  * Test for get qty
  */
 public function testGetQty()
 {
     $this->model->setQty(1);
     $this->assertEquals(1, $this->model->getQty());
 }
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:8,代码来源:ProductTest.php

示例7: convert

 /**
  * {@inheritdoc}
  */
 public function convert(\Magento\Catalog\Model\Product $product)
 {
     return [ProductLink::TYPE => $product->getTypeId(), ProductLink::SKU => $product->getSku(), ProductLink::POSITION => $product->getPosition(), ProductLink::CUSTOM_ATTRIBUTES_KEY => [[AttributeValue::ATTRIBUTE_CODE => 'qty', AttributeValue::VALUE => $product->getQty()]]];
 }
开发者ID:Atlis,项目名称:docker-magento2,代码行数:7,代码来源:Converter.php

示例8: convert

 /**
  * {@inheritdoc}
  */
 public function convert(\Magento\Catalog\Model\Product $product)
 {
     return ['type' => $product->getTypeId(), 'sku' => $product->getSku(), 'position' => $product->getPosition(), 'custom_attributes' => [['attribute_code' => 'qty', 'value' => $product->getQty()]]];
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:Converter.php

示例9: getQty

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


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