Пример #1
0
 /**
  * Format total value based on order currency
  *
  * @param \Magento\Framework\Object $total
  * @return string
  */
 public function formatValue($total)
 {
     if (!$total->getIsFormated()) {
         return $this->_adminHelper->displayPrices($this->getOrder(), $total->getBaseValue(), $total->getValue());
     }
     return $total->getValue();
 }
Пример #2
0
 /**
  * Render block html
  *
  * @return string
  */
 protected function _toHtml()
 {
     $this->setTxnIdHtml($this->adminHelper->escapeHtmlWithLinks($this->_txn->getHtmlTxnId(), ['a']));
     $this->setParentTxnIdUrlHtml($this->escapeHtml($this->getUrl('sales/transactions/view', ['txn_id' => $this->_txn->getParentId()])));
     $this->setParentTxnIdHtml($this->escapeHtml($this->_txn->getParentTxnId()));
     $this->setOrderIncrementIdHtml($this->escapeHtml($this->_txn->getOrder()->getIncrementId()));
     $this->setTxnTypeHtml($this->escapeHtml($this->_txn->getTxnType()));
     $this->setOrderIdUrlHtml($this->escapeHtml($this->getUrl('sales/order/view', ['order_id' => $this->_txn->getOrderId()])));
     $this->setIsClosedHtml($this->_txn->getIsClosed() ? __('Yes') : __('No'));
     $createdAt = strtotime($this->_txn->getCreatedAt()) ? $this->formatDate($this->_txn->getCreatedAt(), \IntlDateFormatter::MEDIUM, true) : __('N/A');
     $this->setCreatedAtHtml($this->escapeHtml($createdAt));
     return parent::_toHtml();
 }
Пример #3
0
 /**
  * Add products to items and item options
  *
  * @return $this
  */
 protected function _assignProducts()
 {
     \Magento\Framework\Profiler::start('WISHLIST:' . __METHOD__, ['group' => 'WISHLIST', 'method' => __METHOD__]);
     $productIds = [];
     $this->_productIds = array_merge($this->_productIds, array_keys($productIds));
     /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */
     $productCollection = $this->_productCollectionFactory->create();
     if ($this->_productVisible) {
         $productCollection->setVisibility($this->_productVisibility->getVisibleInSiteIds());
     }
     $productCollection->addPriceData()->addTaxPercents()->addIdFilter($this->_productIds)->addAttributeToSelect('*')->addOptionsToResult()->addUrlRewrite();
     if ($this->_productSalable) {
         $productCollection = $this->_adminhtmlSales->applySalableProductTypesFilter($productCollection);
     }
     $this->_eventManager->dispatch('wishlist_item_collection_products_after_load', ['product_collection' => $productCollection]);
     $checkInStock = $this->_productInStock && !$this->stockConfiguration->isShowOutOfStock();
     foreach ($this as $item) {
         $product = $productCollection->getItemById($item->getProductId());
         if ($product) {
             if ($checkInStock && !$product->isInStock()) {
                 $this->removeItemByKey($item->getId());
             } else {
                 $product->setCustomOptions([]);
                 $item->setProduct($product);
                 $item->setProductName($product->getName());
                 $item->setName($product->getName());
                 $item->setPrice($product->getPrice());
             }
         } else {
             $item->isDeleted(true);
         }
     }
     \Magento\Framework\Profiler::stop('WISHLIST:' . __METHOD__);
     return $this;
 }
Пример #4
0
 /**
  * @param string $data
  * @param string $expected
  * @param null|array $allowedTags
  * @dataProvider escapeHtmlWithLinksDataProvider
  */
 public function testEscapeHtmlWithLinks($data, $expected, $allowedTags = null)
 {
     $this->escaperMock
         ->expects($this->any())
         ->method('escapeHtml')
         ->will($this->returnValue($expected));
     $actual = $this->adminHelper->escapeHtmlWithLinks($data, $allowedTags);
     $this->assertEquals($expected, $actual);
 }
Пример #5
0
 /**
  * @param string $itemKey
  * @param string $type
  * @param int $calledTimes
  * @dataProvider applySalableProductTypesFilterDataProvider
  */
 public function testApplySalableProductTypesFilter($itemKey, $type, $calledTimes)
 {
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $productMock->expects($this->any())->method('getTypeId')->will($this->returnValue($type));
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Item')->disableOriginalConstructor()->setMethods(['__wakeup', 'getProductType'])->getMock();
     $orderMock->expects($this->any())->method('getProductType')->will($this->returnValue($type));
     $quoteMock = $this->getMockBuilder('Magento\\Sales\\Model\\Quote\\Item')->disableOriginalConstructor()->getMock();
     $quoteMock->expects($this->any())->method('getProductType')->will($this->returnValue($type));
     $items = ['product' => $productMock, 'order' => $orderMock, 'quote' => $quoteMock, 'other' => 'other'];
     $collectionMock = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Db\\Collection\\AbstractCollection')->disableOriginalConstructor()->getMock();
     $collectionMock->expects($this->any())->method('getItems')->will($this->returnValue([$items[$itemKey]]));
     $collectionMock->expects($this->exactly($calledTimes))->method('removeItemByKey');
     $this->salesConfigMock->expects($this->any())->method('getAvailableProductTypes')->will($this->returnValue(['validProductType']));
     $this->adminHelper->applySalableProductTypesFilter($collectionMock);
 }
Пример #6
0
 /**
  * Display prices
  *
  * @param float $basePrice
  * @param float $price
  * @param bool $strong
  * @param string $separator
  * @return string
  */
 public function displayPrices($basePrice, $price, $strong = false, $separator = '<br/>')
 {
     return $this->_adminHelper->displayPrices($this->getPriceDataObject(), $basePrice, $price, $strong, $separator);
 }
Пример #7
0
 /**
  * Replace links in string
  *
  * @param array|string $data
  * @param null|array $allowedTags
  * @return string
  */
 public function escapeHtml($data, $allowedTags = null)
 {
     return $this->adminHelper->escapeHtmlWithLinks($data, $allowedTags);
 }
Пример #8
0
 /**
  * Display tax amount
  *
  * @param string $amount
  * @param string $baseAmount
  * @return string
  */
 public function displayAmount($amount, $baseAmount)
 {
     return $this->_salesAdminHelper->displayPrices($this->getSource(), $baseAmount, $amount, false, '<br />');
 }
Пример #9
0
 /**
  * Status history item comment getter
  *
  * @param array $item
  * @return string
  */
 public function getItemComment(array $item)
 {
     $allowedTags = ['b', 'br', 'strong', 'i', 'u', 'a'];
     return isset($item['comment']) ? $this->adminHelper->escapeHtmlWithLinks($item['comment'], $allowedTags) : '';
 }
Пример #10
0
 public function testGetItemCommentIsNotSet()
 {
     $item = [];
     $this->adminHelperMock->expects($this->never())->method('escapeHtmlWithLinks');
     $this->assertEquals('', $this->commentsHistory->getItemComment($item));
 }