123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Sales\Block\Order\Email\Items;
- use Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem;
- use Magento\Sales\Model\Order\Invoice\Item as InvoiceItem;
- use Magento\Sales\Model\Order\Item as OrderItem;
- /**
- * Sales Order Email items default renderer
- *
- * @api
- * @author Magento Core Team <core@magentocommerce.com>
- * @since 100.0.2
- */
- class DefaultItems extends \Magento\Framework\View\Element\Template
- {
- /**
- * Retrieve current order model instance
- *
- * @return \Magento\Sales\Model\Order
- */
- public function getOrder()
- {
- return $this->getItem()->getOrder();
- }
- /**
- * @return array
- */
- public function getItemOptions()
- {
- $result = [];
- if ($options = $this->getItem()->getOrderItem()->getProductOptions()) {
- if (isset($options['options'])) {
- $result = array_merge($result, $options['options']);
- }
- if (isset($options['additional_options'])) {
- $result = array_merge($result, $options['additional_options']);
- }
- if (isset($options['attributes_info'])) {
- $result = array_merge($result, $options['attributes_info']);
- }
- }
- return $result;
- }
- /**
- * @param string|array $value
- * @return string
- */
- public function getValueHtml($value)
- {
- if (is_array($value)) {
- return sprintf(
- '%d',
- $value['qty']
- ) . ' x ' . $this->escapeHtml(
- $value['title']
- ) . " " . $this->getItem()->getOrder()->formatPrice(
- $value['price']
- );
- } else {
- return $this->escapeHtml($value);
- }
- }
- /**
- * @param mixed $item
- * @return mixed
- */
- public function getSku($item)
- {
- if ($item->getOrderItem()->getProductOptionByCode('simple_sku')) {
- return $item->getOrderItem()->getProductOptionByCode('simple_sku');
- } else {
- return $item->getSku();
- }
- }
- /**
- * Return product additional information block
- *
- * @return \Magento\Framework\View\Element\AbstractBlock
- */
- public function getProductAdditionalInformationBlock()
- {
- return $this->getLayout()->getBlock('additional.product.info');
- }
- /**
- * Get the html for item price
- *
- * @param OrderItem|InvoiceItem|CreditmemoItem $item
- * @return string
- */
- public function getItemPrice($item)
- {
- $block = $this->getLayout()->getBlock('item_price');
- $block->setItem($item);
- return $block->toHtml();
- }
- }
|