Пример #1
0
 /**
  * Initialize model comments and return comment collection
  *
  * @return \Magento\Sales\Model\Resource\Order\Comment\Collection\AbstractCollection
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function getComments()
 {
     if ($this->_commentCollection === null) {
         $entity = $this->getEntity();
         if ($entity instanceof \Magento\Sales\Model\Order\Invoice) {
             $this->_commentCollection = $this->_invoiceCollectionFactory->create();
         } elseif ($entity instanceof \Magento\Sales\Model\Order\Creditmemo) {
             $this->_commentCollection = $this->_memoCollectionFactory->create();
         } elseif ($entity instanceof \Magento\Sales\Model\Order\Shipment) {
             $this->_commentCollection = $this->_shipmentCollectionFactory->create();
         } else {
             throw new \Magento\Framework\Exception\LocalizedException(__('We found an invalid entity model.'));
         }
         $this->_commentCollection->setParentFilter($entity)->setCreatedAtOrder()->addVisibleOnFrontFilter();
     }
     return $this->_commentCollection;
 }
Пример #2
0
 /**
  * Model initialization
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $this->_init('Magento\\Sales\\Model\\Order\\Invoice\\Comment', 'Magento\\Sales\\Model\\Resource\\Order\\Invoice\\Comment');
 }