49 $this->_linksFactory = $linksFactory;
50 $this->_itemsFactory = $itemsFactory;
51 parent::__construct($context,
$data);
62 $purchased = $this->_linksFactory->create()
63 ->addFieldToFilter(
'customer_id', $this->currentCustomer->getCustomerId())
64 ->addOrder(
'created_at',
'desc');
65 $this->setPurchased($purchased);
67 foreach ($purchased as
$_item) {
68 $purchasedIds[] =
$_item->getId();
70 if (empty($purchasedIds)) {
71 $purchasedIds = [
null];
73 $purchasedItems = $this->_itemsFactory->create()->addFieldToFilter(
75 [
'in' => $purchasedIds]
83 $this->setItems($purchasedItems);
93 parent::_prepareLayout();
96 \
Magento\Theme\Block\Html\Pager::class,
97 'downloadable.customer.products.pager' 100 )->setPath(
'downloadable/customer/products');
102 $this->getItems()->load();
103 foreach ($this->getItems() as
$item) {
104 $item->setPurchased($this->getPurchased()->getItemById(
$item->getPurchasedId()));
117 return $this->
getUrl(
'sales/order/view', [
'order_id' => $orderId]);
127 if ($this->getRefererUrl()) {
128 return $this->getRefererUrl();
130 return $this->
getUrl(
'customer/account/');
141 if (
$item->getNumberOfDownloadsBought()) {
142 $downloads =
$item->getNumberOfDownloadsBought() -
$item->getNumberOfDownloadsUsed();
145 return __(
'Unlimited');
156 return $this->
getUrl(
'downloadable/download/link', [
'id' =>
$item->getLinkHash(),
'_secure' =>
true]);
167 return $this->_scopeConfig->isSetFlag(
168 \
Magento\Downloadable\Model\Link::XML_PATH_TARGET_NEW_WINDOW,
169 \
Magento\Store\Model\ScopeInterface::SCOPE_STORE
getOrderViewUrl($orderId)
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer, \Magento\Downloadable\Model\ResourceModel\Link\Purchased\CollectionFactory $linksFactory, \Magento\Downloadable\Model\ResourceModel\Link\Purchased\Item\CollectionFactory $itemsFactory, array $data=[])
const LINK_STATUS_PAYMENT_REVIEW
const LINK_STATUS_PENDING_PAYMENT
getUrl($route='', $params=[])
getRemainingDownloads($item)