Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace MSRealReviewsBlock;
- /**
- * Entity rating block
- *
- */
- class Review extends MagentoReviewBlockProductViewListView
- {
- protected $customer_id;
- protected $_orderCollectionFactory;
- public function __construct(
- MagentoCatalogBlockProductContext $context,
- MagentoFrameworkUrlEncoderInterface $urlEncoder,
- MagentoFrameworkJsonEncoderInterface $jsonEncoder,
- MagentoFrameworkStdlibStringUtils $string,
- MagentoCatalogHelperProduct $productHelper,
- MagentoCatalogModelProductTypesConfigInterface $productTypeConfig,
- MagentoFrameworkLocaleFormatInterface $localeFormat,
- MagentoCustomerModelSession $customerSession,
- MagentoCatalogApiProductRepositoryInterface $productRepository,
- MagentoFrameworkPricingPriceCurrencyInterface $priceCurrency,
- MagentoReviewModelResourceModelReviewCollectionFactory $collectionFactory,
- MagentoSalesModelResourceModelOrderCollectionFactory $orderCollectionFactory,
- array $data = []
- ) {
- $this->_orderCollectionFactory = $orderCollectionFactory;
- parent::__construct(
- $context,
- $urlEncoder,
- $jsonEncoder,
- $string,
- $productHelper,
- $productTypeConfig,
- $localeFormat,
- $customerSession,
- $productRepository,
- $priceCurrency,
- $collectionFactory,
- $data
- );
- }
- public function getOrders() {
- if (!$this->orders && !$this->customer_id):
- $this->orders = $this->_orderCollectionFactory->create()->addAttributeToSelect(
- '*'
- )->addFieldToFilter(
- 'customer_id',
- $this->_getCustomerID()
- );
- endif;
- return $this->orders;
- }
- protected function _setCustomerID($input){
- $this->customer_id = $input;
- }
- protected function _getCustomerID(){
- return $this->customer_id;
- }
- public function isRealReview($customer_id = false){
- $html = '';
- $product = $this->getProductId();
- if($customer_id):
- $this->_setCustomerID($customer_id);
- endif;
- $orders = $this->getOrders();
- if($orders && count($orders)):
- foreach($orders as $_order):
- foreach($_order->getAllItems() as $item):
- $html .= "1"; // get item arrays further...
- endforeach;
- endforeach;
- endif;
- $html .= $this->_getCustomerID();
- return $html;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement