Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
View Class Reference
Inheritance diagram for View:
AbstractProduct Template AbstractBlock DataObject BlockInterface

Public Member Functions

 __construct (\Magento\Catalog\Block\Product\Context $context, \Magento\Review\Model\Rating\Option\VoteFactory $voteFactory, \Magento\Review\Model\RatingFactory $ratingFactory, \Magento\Review\Model\ReviewFactory $reviewFactory, array $data=[])
 
 getProductData ()
 
 getReviewData ()
 
 getBackUrl ()
 
 getRating ()
 
 getRatingSummary ()
 
 getTotalReviews ()
 
 dateFormat ($date)
 
 getReviewsSummaryHtml (\Magento\Catalog\Model\Product $product, $templateType=false, $displayIfNoReviews=false)
 
- Public Member Functions inherited from AbstractProduct
 __construct (\Magento\Catalog\Block\Product\Context $context, array $data=[])
 
 getAddToCartUrl ($product, $additional=[])
 
 getSubmitUrl ($product, $additional=[])
 
 getAddToWishlistParams ($product)
 
 getAddToCompareUrl ()
 
 getMinimalQty ($product)
 
 getReviewsSummaryHtml (\Magento\Catalog\Model\Product $product, $templateType=false, $displayIfNoReviews=false)
 
 getProduct ()
 
 getProductUrl ($product, $additional=[])
 
 hasProductUrl ($product)
 
 getColumnCount ()
 
 addColumnCountLayoutDepend ($pageLayout, $columnCount)
 
 removeColumnCountLayoutDepend ($pageLayout)
 
 getColumnCountLayoutDepend ($pageLayout)
 
 getPageLayout ()
 
 getCanShowProductPrice ($product)
 
 displayProductStockStatus ()
 
 getRandomString ($length, $chars=null)
 
 getProductPrice (\Magento\Catalog\Model\Product $product)
 
 isRedirectToCartEnabled ()
 
 getProductDetailsHtml (\Magento\Catalog\Model\Product $product)
 
 getDetailsRenderer ($type=null)
 
 getImage ($product, $imageId, $attributes=[])
 
- Public Member Functions inherited from Template
 __construct (Template\Context $context, array $data=[])
 
 setTemplateContext ($templateContext)
 
 getTemplate ()
 
 setTemplate ($template)
 
 getTemplateFile ($template=null)
 
 getArea ()
 
 assign ($key, $value=null)
 
 fetchView ($fileName)
 
 getBaseUrl ()
 
 getObjectData (\Magento\Framework\DataObject $object, $key)
 
 getCacheKeyInfo ()
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Framework\View\Element\Context $context, array $data=[])
 
 getJsLayout ()
 
 getRequest ()
 
 getParentBlock ()
 
 setLayout (\Magento\Framework\View\LayoutInterface $layout)
 
 getLayout ()
 
 setNameInLayout ($name)
 
 getChildNames ()
 
 setAttribute ($name, $value=null)
 
 setChild ($alias, $block)
 
 addChild ($alias, $block, $data=[])
 
 unsetChild ($alias)
 
 unsetCallChild ($alias, $callback, $result, $params)
 
 unsetChildren ()
 
 getChildBlock ($alias)
 
 getChildHtml ($alias='', $useCache=true)
 
 getChildChildHtml ($alias, $childChildAlias='', $useCache=true)
 
 getBlockHtml ($name)
 
 insert ($element, $siblingName=0, $after=true, $alias='')
 
 append ($element, $alias='')
 
 getGroupChildNames ($groupName)
 
 getChildData ($alias, $key='')
 
 getUiId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getJsId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getUrl ($route='', $params=[])
 
 getViewFileUrl ($fileId, array $params=[])
 
 formatDate ( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
 
 formatTime ( $time=null, $format=\IntlDateFormatter::SHORT, $showDate=false)
 
 getModuleName ()
 
 escapeHtml ($data, $allowedTags=null)
 
 escapeJs ($string)
 
 escapeHtmlAttr ($string, $escapeSingleQuote=true)
 
 escapeCss ($string)
 
 stripTags ($data, $allowableTags=null, $allowHtmlEntities=false)
 
 escapeUrl ($string)
 
 escapeXssInUrl ($data)
 
 escapeQuote ($data, $addSlashes=false)
 
 escapeJsQuote ($data, $quote='\'')
 
 getNameInLayout ()
 
 getCacheKeyInfo ()
 
 getCacheKey ()
 
 getVar ($name, $module=null)
 
 isScopePrivate ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from BlockInterface
 toHtml ()
 

Protected Attributes

 $_template = 'Magento_Review::view.phtml'
 
 $_voteFactory
 
 $_ratingFactory
 
 $_reviewFactory
 
- Protected Attributes inherited from AbstractProduct
 $_priceBlock = []
 
 $_useLinkForAsLowAs = true
 
 $_defaultColumnCount = 3
 
 $_columnCountLayoutDepend = []
 
 $_coreRegistry
 
 $_taxData
 
 $_catalogConfig
 
 $_mathRandom
 
 $_cartHelper
 
 $_wishlistHelper
 
 $_compareProduct
 
 $_imageHelper
 
 $reviewRenderer
 
 $stockRegistry
 
 $imageBuilder
 
- Protected Attributes inherited from Template
 $_viewVars = []
 
 $_baseUrl
 
 $_jsUrl
 
 $_allowSymlinks
 
 $_filesystem
 
 $_template
 
 $templateEnginePool
 
 $_storeManager
 
 $_appState
 
 $directory
 
 $templateContext
 
 $pageConfig
 
 $resolver
 
 $validator
 
- Protected Attributes inherited from AbstractBlock
 $_design
 
 $_session
 
 $_sidResolver
 
 $_nameInLayout
 
 $_layout
 
 $jsLayout = []
 
 $_request
 
 $_urlBuilder
 
 $_eventManager
 
 $_frontController
 
 $_assetRepo
 
 $_viewConfig
 
 $_cacheState
 
 $_logger
 
 $_escaper
 
 $filterManager
 
 $_localeDate
 
 $inlineTranslation
 
 $_isScopePrivate = false
 
 $_scopeConfig
 
 $_cache
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractBlock
static extractModuleName ($className)
 
- Data Fields inherited from Template
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'
 
- Data Fields inherited from AbstractBlock
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER
 
const CACHE_KEY_PREFIX = 'BLOCK_'
 
- Protected Member Functions inherited from AbstractProduct
 _addProductAttributesAndPrices (\Magento\Catalog\Model\ResourceModel\Product\Collection $collection)
 
 getDetailsRendererList ()
 
- Protected Member Functions inherited from Template
 _construct ()
 
 _toHtml ()
 
 getRootDirectory ()
 
 getMediaDirectory ()
 
- Protected Member Functions inherited from AbstractBlock
 _construct ()
 
 _prepareLayout ()
 
 _beforeToHtml ()
 
 _afterToHtml ($html)
 
 _toHtml ()
 
 _getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound'])
 
 getCacheTags ()
 
 getCacheLifetime ()
 
 _loadCache ()
 
 _saveCache ($data)
 
 _getSidPlaceholder ($cacheKey=null)
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Review detailed view block

@api

Author
Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m
Since
100.0.2

Definition at line 15 of file View.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Catalog\Block\Product\Context  $context,
\Magento\Review\Model\Rating\Option\VoteFactory  $voteFactory,
\Magento\Review\Model\RatingFactory  $ratingFactory,
\Magento\Review\Model\ReviewFactory  $reviewFactory,
array  $data = [] 
)
Parameters
\Magento\Catalog\Block\Product\Context$context
\Magento\Review\Model\Rating\Option\VoteFactory$voteFactory
\Magento\Review\Model\RatingFactory$ratingFactory
\Magento\Review\Model\ReviewFactory$reviewFactory
array$data

Definition at line 52 of file View.php.

58  {
59  $this->_voteFactory = $voteFactory;
60  $this->_reviewFactory = $reviewFactory;
61  $this->_ratingFactory = $ratingFactory;
62 
63  parent::__construct(
64  $context,
65  $data
66  );
67  }

Member Function Documentation

◆ dateFormat()

dateFormat (   $date)

Format date in long format

Parameters
string$date
Returns
string

Definition at line 159 of file View.php.

160  {
161  return $this->formatDate($date, \IntlDateFormatter::LONG);
162  }
formatDate( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)

◆ getBackUrl()

getBackUrl ( )

Prepare link to review list for current product

Returns
string

Definition at line 94 of file View.php.

95  {
96  return $this->getUrl('*/*/list', ['id' => $this->getProductData()->getId()]);
97  }

◆ getProductData()

getProductData ( )

Retrieve current product model from registry

Returns
\Magento\Catalog\Model\Product

Definition at line 74 of file View.php.

75  {
76  return $this->_coreRegistry->registry('current_product');
77  }

◆ getRating()

getRating ( )

Retrieve collection of ratings

Returns
\Magento\Review\Model\ResourceModel\Rating\Option\Vote\Collection

Definition at line 104 of file View.php.

105  {
106  if (!$this->getRatingCollection()) {
107  $ratingCollection = $this->_voteFactory->create()->getResourceCollection()->setReviewFilter(
108  $this->getReviewId()
109  )->setStoreFilter(
110  $this->_storeManager->getStore()->getId()
111  )->addRatingInfo(
112  $this->_storeManager->getStore()->getId()
113  )->load();
114  $this->setRatingCollection($ratingCollection->getSize() ? $ratingCollection : false);
115  }
116  return $this->getRatingCollection();
117  }

◆ getRatingSummary()

getRatingSummary ( )

Retrieve rating summary for current product

Returns
string

Definition at line 124 of file View.php.

125  {
126  if (!$this->getRatingSummaryCache()) {
127  $this->setRatingSummaryCache(
128  $this->_ratingFactory->create()->getEntitySummary($this->getProductData()->getId())
129  );
130  }
131  return $this->getRatingSummaryCache();
132  }

◆ getReviewData()

getReviewData ( )

Retrieve current review model from registry

Returns
\Magento\Review\Model\Review

Definition at line 84 of file View.php.

85  {
86  return $this->_coreRegistry->registry('current_review');
87  }

◆ getReviewsSummaryHtml()

getReviewsSummaryHtml ( \Magento\Catalog\Model\Product  $product,
  $templateType = false,
  $displayIfNoReviews = false 
)

Get product reviews summary

Parameters
\Magento\Catalog\Model\Product$product
bool$templateType
bool$displayIfNoReviews
Returns
string

Definition at line 172 of file View.php.

176  {
177  if (!$product->getRatingSummary()) {
178  $this->_reviewFactory->create()->getEntitySummary($product, $this->_storeManager->getStore()->getId());
179  }
180  return parent::getReviewsSummaryHtml($product, $templateType, $displayIfNoReviews);
181  }
$templateType
Definition: list.phtml:37

◆ getTotalReviews()

getTotalReviews ( )

Retrieve total review count for current product

Returns
string

Definition at line 139 of file View.php.

140  {
141  if (!$this->getTotalReviewsCache()) {
142  $this->setTotalReviewsCache(
143  $this->_reviewFactory->create()->getTotalReviews(
144  $this->getProductData()->getId(),
145  false,
146  $this->_storeManager->getStore()->getId()
147  )
148  );
149  }
150  return $this->getTotalReviewsCache();
151  }

Field Documentation

◆ $_ratingFactory

$_ratingFactory
protected

Definition at line 36 of file View.php.

◆ $_reviewFactory

$_reviewFactory
protected

Definition at line 43 of file View.php.

◆ $_template

$_template = 'Magento_Review::view.phtml'
protected

Definition at line 22 of file View.php.

◆ $_voteFactory

$_voteFactory
protected

Definition at line 29 of file View.php.


The documentation for this class was generated from the following file: