Skip to content

Commit 269eb98

Browse files
committed
Merge remote-tracking branch 'public/115_Users_can_see_sales_orders_from_other_company' into pap-b2b-prs
2 parents 36d1e99 + 4f1fb9b commit 269eb98

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

app/code/Magento/Sales/Block/Order/Recent.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
namespace Magento\Sales\Block\Order;
77

88
use Magento\Framework\View\Element\Template\Context;
9-
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
109
use Magento\Customer\Model\Session;
1110
use Magento\Sales\Model\Order\Config;
11+
use Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface;
1212
use Magento\Store\Model\StoreManagerInterface;
1313
use Magento\Framework\App\ObjectManager;
1414

@@ -26,7 +26,7 @@ class Recent extends \Magento\Framework\View\Element\Template
2626
const ORDER_LIMIT = 5;
2727

2828
/**
29-
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
29+
* @var CollectionFactoryInterface
3030
*/
3131
protected $_orderCollectionFactory;
3232

@@ -47,15 +47,15 @@ class Recent extends \Magento\Framework\View\Element\Template
4747

4848
/**
4949
* @param \Magento\Framework\View\Element\Template\Context $context
50-
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
50+
* @param CollectionFactoryInterface $orderCollectionFactory
5151
* @param \Magento\Customer\Model\Session $customerSession
5252
* @param \Magento\Sales\Model\Order\Config $orderConfig
5353
* @param array $data
5454
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
5555
*/
5656
public function __construct(
5757
Context $context,
58-
CollectionFactory $orderCollectionFactory,
58+
CollectionFactoryInterface $orderCollectionFactory,
5959
Session $customerSession,
6060
Config $orderConfig,
6161
array $data = [],
@@ -84,11 +84,12 @@ protected function _construct()
8484
*/
8585
private function getRecentOrders()
8686
{
87-
$orders = $this->_orderCollectionFactory->create()->addAttributeToSelect(
87+
$customerId = $this->_customerSession->getCustomerId();
88+
$orders = $this->_orderCollectionFactory->create($customerId)->addAttributeToSelect(
8889
'*'
8990
)->addAttributeToFilter(
9091
'customer_id',
91-
$this->_customerSession->getCustomerId()
92+
$customerId
9293
)->addAttributeToFilter(
9394
'store_id',
9495
$this->storeManager->getStore()->getId()

app/code/Magento/Sales/CustomerData/LastOrderedItems.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class LastOrderedItems implements SectionSourceInterface
2323
const SIDEBAR_ORDER_LIMIT = 5;
2424

2525
/**
26-
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
26+
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface
2727
*/
2828
protected $_orderCollectionFactory;
2929

@@ -68,7 +68,7 @@ class LastOrderedItems implements SectionSourceInterface
6868
private $logger;
6969

7070
/**
71-
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
71+
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface $orderCollectionFactory
7272
* @param \Magento\Sales\Model\Order\Config $orderConfig
7373
* @param \Magento\Customer\Model\Session $customerSession
7474
* @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
@@ -77,7 +77,7 @@ class LastOrderedItems implements SectionSourceInterface
7777
* @param LoggerInterface $logger
7878
*/
7979
public function __construct(
80-
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
80+
\Magento\Sales\Model\ResourceModel\Order\CollectionFactoryInterface $orderCollectionFactory,
8181
\Magento\Sales\Model\Order\Config $orderConfig,
8282
\Magento\Customer\Model\Session $customerSession,
8383
\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
@@ -103,7 +103,7 @@ protected function initOrders()
103103
{
104104
$customerId = $this->_customerSession->getCustomerId();
105105

106-
$orders = $this->_orderCollectionFactory->create()
106+
$orders = $this->_orderCollectionFactory->create($customerId)
107107
->addAttributeToFilter('customer_id', $customerId)
108108
->addAttributeToFilter('status', ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()])
109109
->addAttributeToSort('created_at', 'desc')
@@ -138,7 +138,7 @@ protected function getItems()
138138
$this->logger->critical($noEntityException);
139139
continue;
140140
}
141-
if (isset($product) && in_array($website, $product->getWebsiteIds())) {
141+
if (in_array($website, $product->getWebsiteIds())) {
142142
$url = $product->isVisibleInSiteVisibility() ? $product->getProductUrl() : null;
143143
$items[] = [
144144
'id' => $item->getId(),
@@ -188,7 +188,7 @@ protected function getLastOrder()
188188
}
189189

190190
/**
191-
* {@inheritdoc}
191+
* @inheritdoc
192192
*/
193193
public function getSectionData()
194194
{

0 commit comments

Comments
 (0)