本文整理汇总了PHP中Magento\Catalog\Helper\Image::getHeight方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::getHeight方法的具体用法?PHP Image::getHeight怎么用?PHP Image::getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Helper\Image
的用法示例。
在下文中一共展示了Image::getHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetHeight
/**
* @param array $data
* @dataProvider getHeightDataProvider
*/
public function testGetHeight($data)
{
$imageId = 'test_image_id';
$attributes = [];
$productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
$this->prepareAttributes($data, $imageId);
$height = isset($data['height']) ? $data['height'] : $data['width'];
$this->helper->init($productMock, $imageId, $attributes);
$this->assertEquals($height, $this->helper->getHeight());
}
示例2: getItems
/**
* Get wishlist items
*
* @return array
*/
protected function getItems()
{
$this->view->loadLayout();
$collection = $this->wishlistHelper->getWishlistItemCollection();
$collection->clear()->setPageSize(self::SIDEBAR_ITEMS_NUMBER)->setInStockFilter(true)->setOrder('added_at');
$items = [];
/** @var \Magento\Wishlist\Model\Item $wishlistItem */
foreach ($collection as $wishlistItem) {
$product = $wishlistItem->getProduct();
$this->imageHelper->init($product, 'wishlist_sidebar_block');
$items[] = ['image' => ['src' => $this->imageHelper->getUrl(), 'alt' => $this->imageHelper->getLabel(), 'width' => $this->imageHelper->getWidth(), 'height' => $this->imageHelper->getHeight()], 'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem), 'product_name' => $product->getName(), 'product_price' => $this->block->getProductPriceHtml($product, \Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE, \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, ['item' => $wishlistItem]), 'product_is_saleable_and_visible' => $product->isSaleable() && $product->isVisibleInSiteVisibility(), 'product_has_required_options' => $product->getTypeInstance()->hasRequiredOptions($product), 'add_to_cart_params' => $this->wishlistHelper->getAddToCartParams($wishlistItem, true), 'delete_item_params' => $this->wishlistHelper->getRemoveParams($wishlistItem, true)];
}
return $items;
}
示例3: getRatio
/**
* Calculate image ratio
*
* @param \Magento\Catalog\Helper\Image $helper
* @return float|int
*/
protected function getRatio(\Magento\Catalog\Helper\Image $helper)
{
$width = $helper->getWidth();
$height = $helper->getHeight();
if ($width && $height) {
return $height / $width;
}
return 1;
}