本文整理匯總了PHP中Magento\Catalog\Test\Page\Product\CatalogProductView::getBundleViewBlock方法的典型用法代碼示例。如果您正苦於以下問題:PHP CatalogProductView::getBundleViewBlock方法的具體用法?PHP CatalogProductView::getBundleViewBlock怎麽用?PHP CatalogProductView::getBundleViewBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Catalog\Test\Page\Product\CatalogProductView
的用法示例。
在下文中一共展示了CatalogProductView::getBundleViewBlock方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: processAssert
/**
* Assertion that tier prices are displayed correctly
*
* @param BrowserInterface $browser
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @return void
*/
public function processAssert(BrowserInterface $browser, CatalogProductView $catalogProductView, FixtureInterface $product)
{
//Open product view page
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$viewBlock = $catalogProductView->getBundleViewBlock();
$viewBlock->clickCustomize();
//Process assertions
$this->assertPrice($product, $viewBlock);
}
示例2: displayedBundleBlock
/**
* Displayed bundle block on frontend with correct fixture product
*
* @param CatalogProductView $catalogProductView
* @param CatalogProductBundle $product
* @return string|null
*/
protected function displayedBundleBlock(CatalogProductView $catalogProductView, CatalogProductBundle $product)
{
$fields = $product->getData();
$bundleOptions = $fields['bundle_selections']['bundle_options'];
if (!isset($bundleOptions)) {
return 'Bundle options data on product page is not equals to fixture preset.';
}
$catalogProductView->getViewBlock()->clickCustomize();
foreach ($bundleOptions as $index => $item) {
foreach ($item['assigned_products'] as &$selection) {
$selection = $selection['search_data'];
}
$result = $catalogProductView->getBundleViewBlock()->getBundleBlock()->displayedBundleItemOption($item, ++$index);
if ($result !== true) {
return $result;
}
}
return null;
}
示例3: assertPrice
/**
* Assert prices on the product view page and shopping cart page.
*
* @param CatalogProductBundle $product
* @param CatalogProductView $catalogProductView
* @param CheckoutCart $checkoutCartView
* @param CatalogProductBundle $originalProduct [optional]
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function assertPrice(CatalogProductBundle $product, CatalogProductView $catalogProductView, CheckoutCart $checkoutCartView, CatalogProductBundle $originalProduct = null)
{
$customerGroup = 'NOT LOGGED IN';
$catalogProductView->getViewBlock()->clickCustomize();
$bundleData = $product->getData();
$this->productPriceType = $originalProduct !== null ? $originalProduct->getPriceType() : $product->getPriceType();
$fillData = $product->getDataFieldConfig('checkout_data')['source']->getPreset();
$bundleBlock = $catalogProductView->getBundleViewBlock()->getBundleBlock();
$bundleBlock->addToCart($product, $catalogProductView);
$cartBlock = $checkoutCartView->getCartBlock();
$specialPrice = 0;
if (isset($bundleData['group_price'])) {
$specialPrice = $bundleData['group_price'][array_search($customerGroup, $bundleData['group_price'])]['price'] / 100;
}
$optionPrice = [];
foreach ($fillData['bundle_options'] as $key => $data) {
$subProductPrice = 0;
foreach ($bundleData['bundle_selections']['products'][$key] as $productKey => $itemProduct) {
if (strpos($itemProduct->getName(), $data['value']['name']) !== false) {
$data['value']['key'] = $productKey;
$subProductPrice = $itemProduct->getPrice();
}
}
$optionPrice[$key]['price'] = $this->productPriceType == 'Fixed' ? number_format($bundleData['bundle_selections']['bundle_options'][$key]['assigned_products'][$data['value']['key']]['data']['selection_price_value'], 2) : number_format($subProductPrice, 2);
}
foreach ($optionPrice as $index => $item) {
$item['price'] -= $item['price'] * $specialPrice;
\PHPUnit_Framework_Assert::assertEquals(number_format($item['price'], 2), $cartBlock->getPriceBundleOptions($index + 1), 'Bundle item ' . ($index + 1) . ' options on frontend don\'t equal to fixture.');
}
$sumOptionsPrice = $product->getDataFieldConfig('price')['source']->getPreset()['cart_price'];
$subTotal = number_format($cartBlock->getCartItemUnitPrice($product), 2);
\PHPUnit_Framework_Assert::assertEquals($sumOptionsPrice, $subTotal, 'Bundle unit price on frontend doesn\'t equal to fixture.');
}