Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?php
  2.  
  3. namespace MSRealReviewsBlock;
  4.  
  5. /**
  6. * Entity rating block
  7. *
  8. */
  9.  
  10. class Review extends MagentoReviewBlockProductViewListView
  11. {
  12.  
  13. protected $customer_id;
  14. protected $_orderCollectionFactory;
  15.  
  16. public function __construct(
  17. MagentoCatalogBlockProductContext $context,
  18. MagentoFrameworkUrlEncoderInterface $urlEncoder,
  19. MagentoFrameworkJsonEncoderInterface $jsonEncoder,
  20. MagentoFrameworkStdlibStringUtils $string,
  21. MagentoCatalogHelperProduct $productHelper,
  22. MagentoCatalogModelProductTypesConfigInterface $productTypeConfig,
  23. MagentoFrameworkLocaleFormatInterface $localeFormat,
  24. MagentoCustomerModelSession $customerSession,
  25. MagentoCatalogApiProductRepositoryInterface $productRepository,
  26. MagentoFrameworkPricingPriceCurrencyInterface $priceCurrency,
  27. MagentoReviewModelResourceModelReviewCollectionFactory $collectionFactory,
  28. MagentoSalesModelResourceModelOrderCollectionFactory $orderCollectionFactory,
  29. array $data = []
  30. ) {
  31. $this->_orderCollectionFactory = $orderCollectionFactory;
  32. parent::__construct(
  33. $context,
  34. $urlEncoder,
  35. $jsonEncoder,
  36. $string,
  37. $productHelper,
  38. $productTypeConfig,
  39. $localeFormat,
  40. $customerSession,
  41. $productRepository,
  42. $priceCurrency,
  43. $collectionFactory,
  44. $data
  45. );
  46. }
  47.  
  48. public function getOrders() {
  49.  
  50. if (!$this->orders && !$this->customer_id):
  51. $this->orders = $this->_orderCollectionFactory->create()->addAttributeToSelect(
  52. '*'
  53. )->addFieldToFilter(
  54. 'customer_id',
  55. $this->_getCustomerID()
  56. );
  57. endif;
  58.  
  59. return $this->orders;
  60.  
  61. }
  62.  
  63. protected function _setCustomerID($input){
  64. $this->customer_id = $input;
  65. }
  66.  
  67. protected function _getCustomerID(){
  68. return $this->customer_id;
  69. }
  70.  
  71. public function isRealReview($customer_id = false){
  72.  
  73. $html = '';
  74. $product = $this->getProductId();
  75.  
  76.  
  77. if($customer_id):
  78. $this->_setCustomerID($customer_id);
  79. endif;
  80.  
  81. $orders = $this->getOrders();
  82. if($orders && count($orders)):
  83. foreach($orders as $_order):
  84. foreach($_order->getAllItems() as $item):
  85. $html .= "1"; // get item arrays further...
  86. endforeach;
  87. endforeach;
  88. endif;
  89.  
  90. $html .= $this->_getCustomerID();
  91.  
  92. return $html;
  93. }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement