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


PHP FixtureInterface::getPrice方法代码示例

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


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

示例1: assertOnShoppingCart

 /**
  * Assert prices on the shopping cart
  *
  * @param FixtureInterface $product
  * @param CheckoutCart $checkoutCart
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function assertOnShoppingCart(FixtureInterface $product, CheckoutCart $checkoutCart)
 {
     $checkoutCart->open();
     /** @var CatalogProductSimple $product */
     $customOptions = $product->getCustomOptions();
     $checkoutData = $product->getCheckoutData();
     $checkoutCartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : [];
     $checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
     $fixturePrice = $product->getPrice();
     $specialPrice = $product->getSpecialPrice();
     $cartItem = $checkoutCart->getCartBlock()->getCartItem($product);
     $formPrice = $cartItem->getPrice();
     if ($specialPrice) {
         $fixturePrice = $specialPrice;
     }
     if (isset($checkoutCartItem['price'])) {
         $fixturePrice = $checkoutCartItem['price'];
     }
     $fixtureActualPrice = $fixturePrice;
     foreach ($checkoutCustomOptions as $checkoutOption) {
         $attributeKey = str_replace('attribute_key_', '', $checkoutOption['title']);
         $optionKey = str_replace('option_key_', '', $checkoutOption['value']);
         $option = $customOptions[$attributeKey]['options'][$optionKey];
         if ('Fixed' == $option['price_type']) {
             $fixtureActualPrice += $option['price'];
         } else {
             $fixtureActualPrice += $fixturePrice / 100 * $option['price'];
         }
     }
     \PHPUnit_Framework_Assert::assertEquals($fixtureActualPrice, $formPrice, 'Product price in shopping cart is not correct.');
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:40,代码来源:AssertProductInCart.php

示例2: processAssert

 /**
  * Assert that duplicated product is found by sku and has correct product type, product template,
  * product status disabled and out of stock
  *
  * @param FixtureInterface $product
  * @param CatalogProductIndex $productGrid
  * @return void
  */
 public function processAssert(FixtureInterface $product, CatalogProductIndex $productGrid)
 {
     $config = $product->getDataConfig();
     $filter = ['name' => $product->getName(), 'visibility' => $product->getVisibility(), 'status' => 'Disabled', 'sku' => $product->getSku() . '-1', 'type' => ucfirst($config['create_url_params']['type']) . ' Product', 'price_to' => number_format($product->getPrice(), 2)];
     $productGrid->open()->getProductGrid()->search($filter);
     $filter['price_to'] = '$' . $filter['price_to'];
     \PHPUnit_Framework_Assert::assertTrue($productGrid->getProductGrid()->isRowVisible($filter, false), 'Product duplicate is absent in Products grid.');
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:AssertProductDuplicatedInGrid.php

示例3: getProductPrice

 /**
  * Get configurable product price
  *
  * @param FixtureInterface $product
  * @throws \Exception
  * @return int
  */
 protected function getProductPrice(FixtureInterface $product)
 {
     $price = $product->getPrice();
     if (!$this->productsIsConfigured) {
         return $price;
     }
     if (!$product instanceof ConfigurableProduct) {
         throw new \Exception("Product '{$product->getName}()' is not configurable product.");
     }
     $checkoutData = $product->getCheckoutData();
     if ($checkoutData === null) {
         return 0;
     }
     $attributesData = $product->getConfigurableAttributesData()['attributes_data'];
     foreach ($checkoutData['options']['configurable_options'] as $option) {
         $itemOption = $attributesData[$option['title']]['options'][$option['value']];
         $itemPrice = $itemOption['is_percent'] == 'No' ? $itemOption['pricing_value'] : $product->getPrice() / 100 * $itemOption['pricing_value'];
         $price += $itemPrice;
     }
     return $price;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:28,代码来源:AssertConfigurableProductInItemsOrderedGrid.php

示例4: verifyPrice

 /**
  * Verify displayed product price on product page(front-end) equals passed from fixture
  *
  * @return string|null
  */
 protected function verifyPrice()
 {
     if ($this->product->hasData('price') == false) {
         return null;
     }
     $priceBlock = $this->productView->getPriceBlock();
     $formPrice = $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice();
     $fixturePrice = number_format($this->product->getPrice(), 2, '.', '');
     if ($fixturePrice != $formPrice) {
         return "Displayed product price on product page(front-end) not equals passed from fixture. " . "Actual: {$fixturePrice}, expected: {$formPrice}.";
     }
     return null;
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:18,代码来源:AssertProductPage.php

示例5: getProductPrice

 /**
  * Get configurable product price
  *
  * @param FixtureInterface $product
  * @throws \Exception
  * @return int
  */
 protected function getProductPrice(FixtureInterface $product)
 {
     $price = $product->getPrice();
     if (!$this->productsIsConfigured) {
         return $price;
     }
     if (!$product instanceof ConfigurableProduct) {
         throw new \Exception("Product '{$product->getName}()' is not configurable product.");
     }
     $checkoutData = $product->getCheckoutData();
     if ($checkoutData === null) {
         return 0;
     }
     return $price;
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:22,代码来源:AssertConfigurableProductInItemsOrderedGrid.php

示例6: prepareOptions

 /**
  * Preparation options before comparing
  *
  * @param FixtureInterface $product
  * @param int|null $actualPrice
  * @return array
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function prepareOptions(FixtureInterface $product, $actualPrice = null)
 {
     $result = [];
     $customOptions = $product->hasData('custom_options') ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() : null;
     $actualPrice = $actualPrice ? $actualPrice : $product->getPrice();
     foreach ($customOptions as $customOption) {
         $skippedField = isset($this->skippedFieldOptions[$customOption['type']]) ? $this->skippedFieldOptions[$customOption['type']] : [];
         foreach ($customOption['options'] as &$option) {
             // recalculate percent price
             if ('Percent' == $option['price_type']) {
                 $option['price'] = $actualPrice * $option['price'] / 100;
                 $option['price'] = round($option['price'], 2);
             }
             $option = array_diff_key($option, array_flip($skippedField));
         }
         $result[$customOption['title']] = $customOption;
     }
     return $result;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:28,代码来源:AssertProductCustomOptionsOnProductPage.php

示例7: getProductPrice

 /**
  * Get product price.
  *
  * @param FixtureInterface $product
  * @return int
  */
 protected function getProductPrice(FixtureInterface $product)
 {
     return isset($product->getCheckoutData()['cartItem']['price']) ? $product->getCheckoutData()['cartItem']['price'] : $product->getPrice();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:AssertProductInItemsOrderedGrid.php

示例8: assertPrice

 /**
  * Verify product price on category view page
  *
  * @param FixtureInterface $product
  * @param CatalogCategoryView $catalogCategoryView
  * @return void
  */
 protected function assertPrice(FixtureInterface $product, CatalogCategoryView $catalogCategoryView)
 {
     $price = $catalogCategoryView->getListProductBlock()->getProductPriceBlock($product->getName())->getRegularPrice();
     \PHPUnit_Framework_Assert::assertEquals(number_format($product->getPrice(), 2), $price, 'Product regular price on category page is not correct.');
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:AssertProductInCategory.php


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