예제 #1
0
 /**
  * Unhold selected orders
  *
  * @param AbstractCollection $collection
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $countUnHoldOrder = 0;
     /** @var \Magento\Sales\Model\Order $order */
     foreach ($collection->getItems() as $order) {
         $order->load($order->getId());
         if (!$order->canUnhold()) {
             continue;
         }
         $order->unhold();
         $order->save();
         $countUnHoldOrder++;
     }
     $countNonUnHoldOrder = $collection->count() - $countUnHoldOrder;
     if ($countNonUnHoldOrder && $countUnHoldOrder) {
         $this->messageManager->addError(__('%1 order(s) were not released from on hold status.', $countNonUnHoldOrder));
     } elseif ($countNonUnHoldOrder) {
         $this->messageManager->addError(__('No order(s) were released from on hold status.'));
     }
     if ($countUnHoldOrder) {
         $this->messageManager->addSuccess(__('%1 order(s) have been released from on hold status.', $countUnHoldOrder));
     }
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath($this->getComponentRefererUrl());
     return $resultRedirect;
 }
예제 #2
0
 /**
  * Callback function that filters collection by field "Used" from grid
  *
  * @param AbstractCollection $collection
  * @param Column $column
  * @return void
  */
 public function addIsUsedFilterCallback($collection, $column)
 {
     $filterValue = $column->getFilter()->getCondition();
     $expression = $this->getConnection()->getCheckSql('main_table.times_used > 0', 1, 0);
     $conditionSql = $this->_getConditionSql($expression, $filterValue);
     $collection->getSelect()->where($conditionSql);
 }
예제 #3
0
 /**
  * Print shipments for selected orders
  *
  * @param AbstractCollection $collection
  * @return ResponseInterface|\Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $shipmentsCollection = $this->shipmentCollectionFactotory->create()->setOrderFilter(['in' => $collection->getAllIds()]);
     if (!$shipmentsCollection->getSize()) {
         $this->messageManager->addError(__('There are no printable documents related to selected orders.'));
         return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
     }
     return $this->fileFactory->create(sprintf('packingslip%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')), $this->pdfShipment->getPdf($shipmentsCollection->getItems())->render(), DirectoryList::VAR_DIR, 'application/pdf');
 }
예제 #4
0
 /**
  * Delete all records in collection. Return count of successful operations.
  *
  * @param AbstractCollection $collection
  *
  * @return int
  */
 protected function _processAction(AbstractCollection $collection)
 {
     $count = 0;
     /** @var \ISM\Blog\Model\Post $model */
     foreach ($collection->getItems() as $model) {
         $model->delete();
         ++$count;
     }
     return $count;
 }
예제 #5
0
 protected function _processAction(AbstractCollection $collection)
 {
     $count = 0;
     foreach ($collection->getItems() as $model) {
         /** @var \ISM\Blog\Model\Post $model */
         $model->setIsActive(false);
         $model->save();
         ++$count;
     }
     return $count;
 }
예제 #6
0
 /**
  * @inheritdoc
  */
 public function addFieldToFilter($field, $condition = null)
 {
     if (in_array($field, ['created_at', 'updated_at'], true)) {
         $field = 'main_table.' . $field;
     }
     return parent::addFieldToFilter($field, $condition);
 }
예제 #7
0
 /**
  * {@inheritdoc}
  */
 protected function _afterLoad()
 {
     foreach ($this->_items as $item) {
         $item->setIndex($this->index);
     }
     return parent::_afterLoad();
 }
예제 #8
0
 /**
  * @param EntityFactory $entityFactory
  * @param Logger $logger
  * @param FetchStrategy $fetchStrategy
  * @param EventManager $eventManager
  * @param string $mainTable
  * @param string $resourceModel
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function __construct(EntityFactory $entityFactory, Logger $logger, FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable, $resourceModel)
 {
     $this->_init('Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\Document', $resourceModel);
     $this->setMainTable(true);
     $this->setMainTable($this->_resource->getTable($mainTable));
     parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, null, null);
     $this->_setIdFieldName($this->getResource()->getIdFieldName());
 }
예제 #9
0
 /**
  * Load collection data
  *
  * @return $this
  */
 public function _beforeLoad()
 {
     if (!$this->getLoadDefault()) {
         $this->setWithoutDefaultFilter();
     }
     $this->addOrder('main_table.name', self::SORT_ORDER_ASC);
     return parent::_beforeLoad();
 }
예제 #10
0
 /**
  * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param null|\Zend_Db_Adapter_Abstract $mainTable
  * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $eventPrefix
  * @param string $eventObject
  * @param string $resourceModel
  * @param string $model
  * @param string|null $connection
  * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, $mainTable, $eventPrefix, $eventObject, $resourceModel, $model = 'Magento\\Sales\\Model\\ResourceModel\\Grid\\Document', $connection = null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null)
 {
     $this->_eventPrefix = $eventPrefix;
     $this->_eventObject = $eventObject;
     $this->_init($model, $resourceModel);
     $this->setMainTable($mainTable);
     parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
 }
예제 #11
0
 /**
  * Process loaded collection data
  *
  * @return $this
  */
 protected function _afterLoadData()
 {
     parent::_afterLoadData();
     $this->addCustomerTaxClassesToResult();
     $this->addProductTaxClassesToResult();
     $this->addRatesToResult();
     return $this;
 }
예제 #12
0
 /**
  * Initialize select object
  *
  * @return $this
  */
 protected function _initSelect()
 {
     parent::_initSelect();
     $locale = $this->_localeResolver->getLocale();
     $this->addBindParam(':region_locale', $locale);
     $this->getSelect()->joinLeft(['rname' => $this->_regionNameTable], 'main_table.region_id = rname.region_id AND rname.locale = :region_locale', ['name']);
     return $this;
 }
예제 #13
0
 public function _initSelect()
 {
     parent::_initSelect();
     $this->_select->joinLeft(['country_table' => $this->_countryTable], 'country_table.country_id = main_table.dest_country_id', ['dest_country' => 'iso3_code'])->joinLeft(['region_table' => $this->_regionTable], 'region_table.region_id = main_table.dest_region_id', ['dest_region' => 'code']);
     $this->addOrder('dest_country', self::SORT_ORDER_ASC);
     $this->addOrder('dest_region', self::SORT_ORDER_ASC);
     $this->addOrder('dest_zip', self::SORT_ORDER_ASC);
 }
예제 #14
0
 /**
  * @param EntityFactory $entityFactory
  * @param Logger $logger
  * @param FetchStrategy $fetchStrategy
  * @param EventManager $eventManager
  * @param string $mainTable
  * @param string $resourceModel
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function __construct(EntityFactory $entityFactory, Logger $logger, FetchStrategy $fetchStrategy, EventManager $eventManager, $mainTable, $resourceModel)
 {
     $this->_init($this->document, $resourceModel);
     $this->setMainTable(true);
     $this->setMainTable($this->_resource->getTable($mainTable));
     parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, null, null);
     $this->_setIdFieldName($this->getResource()->getIdFieldName());
 }
예제 #15
0
 /**
  * @inheritdoc
  */
 public function fetchItem()
 {
     $item = parent::fetchItem();
     if ($item) {
         $this->entitySnapshot->registerSnapshot($item);
     }
     return $item;
 }
예제 #16
0
 /**
  * Initialize select
  *
  * @return $this
  */
 protected function _initSelect()
 {
     parent::_initSelect();
     $this->addFieldToSelect(['path', 'value'])->addFieldToFilter('scope', $this->_scope);
     if ($this->_scopeId !== null) {
         $this->addFieldToFilter('scope_id', $this->_scopeId);
     }
     return $this;
 }
 /**
  * Batch print shipping labels for whole shipments.
  * Push pdf document with shipping labels to user browser
  *
  * @param AbstractCollection $collection
  * @return ResponseInterface|ResultInterface
  */
 protected function massAction(AbstractCollection $collection)
 {
     $labelsContent = [];
     if ($collection->getSize()) {
         /** @var \Magento\Sales\Model\Order\Shipment $shipment */
         foreach ($collection as $shipment) {
             $labelContent = $shipment->getShippingLabel();
             if ($labelContent) {
                 $labelsContent[] = $labelContent;
             }
         }
     }
     if (!empty($labelsContent)) {
         $outputPdf = $this->labelGenerator->combineLabelsPdf($labelsContent);
         return $this->fileFactory->create('ShippingLabels.pdf', $outputPdf->render(), DirectoryList::VAR_DIR, 'application/pdf');
     }
     $this->messageManager->addError(__('There are no shipping labels related to selected shipments.'));
     return $this->resultRedirectFactory->create()->setPath('sales/shipment/');
 }
예제 #18
0
 /**
  * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\Locale\ListsInterface $localeLists
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Directory\Model\ResourceModel\CountryFactory $countryFactory
  * @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
  * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
  * @param \Magento\Framework\App\Helper\AbstractHelper $helperData
  * @param mixed $connection
  * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Locale\ListsInterface $localeLists, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Directory\Model\ResourceModel\CountryFactory $countryFactory, \Magento\Framework\Stdlib\ArrayUtils $arrayUtils, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\App\Helper\AbstractHelper $helperData, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null)
 {
     parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
     $this->_scopeConfig = $scopeConfig;
     $this->_localeLists = $localeLists;
     $this->_localeResolver = $localeResolver;
     $this->_countryFactory = $countryFactory;
     $this->_arrayUtils = $arrayUtils;
     $this->helperData = $helperData;
 }
예제 #19
0
파일: Send.php 프로젝트: signifyd/magento2
 public function massAction(AbstractCollection $collection)
 {
     foreach ($collection->getItems() as $order) {
         try {
             // Check if case already exists for this order
             if ($this->_helper->doesCaseExist($order)) {
                 continue;
             }
             $orderData = $this->_helper->processOrderData($order);
             // Add order to database
             $this->_helper->createNewCase($order);
             // Post case to signifyd service
             $this->_helper->postCaseToSignifyd($orderData, $order);
         } catch (\Exception $ex) {
             $this->_logger->error($ex->getMessage());
         }
     }
     $this->messageManager->addSuccessMessage(__('Success.'));
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath($this->getComponentRefererUrl());
     return $resultRedirect;
 }
예제 #20
0
 /**
  * Set collection to pager
  *
  * @param \Magento\Framework\Data\Collection $collection
  * @return $this
  */
 public function setCollection($collection)
 {
     $this->_collection = $collection;
     $this->_collection->setCurPage($this->getCurrentPage());
     // we need to set pagination only if passed value integer and more that 0
     $limit = (int) $this->getLimit();
     if ($limit) {
         $this->_collection->setPageSize($limit);
     }
     if ($this->getCurrentOrder()) {
         $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
     }
     return $this;
 }
예제 #21
0
 /**
  * Hold selected orders
  *
  * @param AbstractCollection $collection
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $countHoldOrder = 0;
     foreach ($collection->getItems() as $order) {
         if (!$order->canHold()) {
             continue;
         }
         $this->orderManagement->hold($order->getEntityId());
         $countHoldOrder++;
     }
     $countNonHoldOrder = $collection->count() - $countHoldOrder;
     if ($countNonHoldOrder && $countHoldOrder) {
         $this->messageManager->addError(__('%1 order(s) were not put on hold.', $countNonHoldOrder));
     } elseif ($countNonHoldOrder) {
         $this->messageManager->addError(__('No order(s) were put on hold.'));
     }
     if ($countHoldOrder) {
         $this->messageManager->addSuccess(__('You have put %1 order(s) on hold.', $countHoldOrder));
     }
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath($this->getComponentRefererUrl());
     return $resultRedirect;
 }
예제 #22
0
 /**
  * @param \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection $collection
  */
 protected function _prepareCache($collection)
 {
     $stmt = $collection->getSelect()->query();
     $ids = array();
     foreach ($stmt as $item) {
         $ids = array_merge($ids, array_map('intval', explode('/', $item['path'])));
     }
     $ids = array_unique($ids);
     if (empty($ids)) {
         return;
     }
     /* @var $attribute \Magento\Eav\Model\Attribute */
     $attribute = $collection->getFirstItem()->getResource()->getAttribute('name');
     $resource = $collection->getResource();
     $tableName = \Magento\Catalog\Model\Category::ENTITY . '_entity_' . $attribute->getBackendType();
     $dbSelect1 = $resource->getConnection()->select()->from($resource->getTable($tableName), new \Zend_Db_Expr('MAX(`store_id`)'))->where("`entity_id` = `ccev`.`entity_id`")->where("`attribute_id` = `ccev`.`attribute_id`")->where("`store_id` = 0 OR `store_id` = ?", $this->getStoreId());
     $dbSelect2 = $resource->getConnection()->select()->from(array('ccev' => $resource->getTable($tableName)), array('name' => 'value', 'category_id' => 'entity_id'))->where('ccev.entity_id IN (' . implode(',', $ids) . ')')->where('ccev.attribute_id = ?', $attribute->getAttributeId())->where('ccev.store_id = (' . $dbSelect1->__toString() . ')');
     $cacheData = array();
     foreach ($resource->getConnection()->fetchAll($dbSelect2) as $row) {
         $cacheData[$row['category_id']] = $row['name'];
     }
     $this->setData('categories_cache', $cacheData);
 }
예제 #23
0
 /**
  * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Customer\Model\ResourceModel\Customer $customerResource
  * @param \Magento\Eav\Helper\Data $eavHelper
  * @param mixed $connection
  * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
  */
 public function __construct(
     \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
     \Psr\Log\LoggerInterface $logger,
     \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
     \Magento\Framework\Event\ManagerInterface $eventManager,
     \Magento\Customer\Model\ResourceModel\Customer $customerResource,
     \Magento\Eav\Helper\Data $eavHelper,
     \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
     \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
 ) {
     parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
     $this->_eavHelper = $eavHelper;
     $this->_customerResource = $customerResource;
 }
예제 #24
0
 /**
  * Cancel selected orders
  *
  * @param AbstractCollection $collection
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $countCancelOrder = 0;
     foreach ($collection->getItems() as $order) {
         if (!$order->canCancel()) {
             continue;
         }
         $order->cancel();
         $order->save();
         $countCancelOrder++;
     }
     $countNonCancelOrder = $collection->count() - $countCancelOrder;
     if ($countNonCancelOrder && $countCancelOrder) {
         $this->messageManager->addError(__('%1 order(s) cannot be canceled.', $countNonCancelOrder));
     } elseif ($countNonCancelOrder) {
         $this->messageManager->addError(__('You cannot cancel the order(s).'));
     }
     if ($countCancelOrder) {
         $this->messageManager->addSuccess(__('We canceled %1 order(s).', $countCancelOrder));
     }
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath($this->getComponentRefererUrl());
     return $resultRedirect;
 }
예제 #25
0
 /**
  * Fill array of options by item and product
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     foreach ($this as $option) {
         $optionId = $option->getId();
         $itemId = $option->getWishlistItemId();
         $productId = $option->getProductId();
         if (isset($this->_optionsByItem[$itemId])) {
             $this->_optionsByItem[$itemId][] = $optionId;
         } else {
             $this->_optionsByItem[$itemId] = [$optionId];
         }
         if (isset($this->_optionsByProduct[$productId])) {
             $this->_optionsByProduct[$productId][] = $optionId;
         } else {
             $this->_optionsByProduct[$productId] = [$optionId];
         }
     }
     return $this;
 }
 /**
  * Cancel selected orders
  *
  * @param AbstractCollection $collection
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 protected function massAction(AbstractCollection $collection)
 {
     $countCancelOrder = 0;
     $connection = $this->_resource->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);
     $showTables = $connection->fetchCol('show tables');
     //start get table name
     $tblSalesOrder = $connection->getTableName('sales_order');
     $tblSalesCreditmemoComment = $connection->getTableName('sales_creditmemo_comment');
     $tblSalesCreditmemoItem = $connection->getTableName('sales_creditmemo_item');
     $tblSalesCreditmemo = $connection->getTableName('sales_creditmemo');
     $tblSalesCreditmemoGrid = $connection->getTableName('sales_creditmemo_grid');
     $tblSalesInvoiceComment = $connection->getTableName('sales_invoice_comment');
     $tblSalesInvoiceItem = $connection->getTableName('sales_invoice_item');
     $tblSalesInvoice = $connection->getTableName('sales_invoice');
     $tblSalesInvoiceGrid = $connection->getTableName('sales_invoice_grid');
     $tblQuoteAddressItem = $connection->getTableName('quote_address_item');
     $tblQuoteItemOption = $connection->getTableName('quote_item_option');
     $tblQuote = $connection->getTableName('quote');
     $tblQuoteAddress = $connection->getTableName('quote_address');
     $tblQuoteItem = $connection->getTableName('quote_item');
     $tblQuotePayment = $connection->getTableName('quote_payment');
     $tblQuoteShippingRate = $connection->getTableName('quote_shipping_rate');
     $tblQuoteIDMask = $connection->getTableName('quote_id_mask');
     $tblSalesShipmentComment = $connection->getTableName('sales_shipment_comment');
     $tblSalesShipmentItem = $connection->getTableName('sales_shipment_item');
     $tblSalesShipmentTrack = $connection->getTableName('sales_shipment_track');
     $tblSalesShipment = $connection->getTableName('sales_shipment');
     $tblSalesShipmentGrid = $connection->getTableName('sales_shipment_grid');
     $tblSalesOrderAddress = $connection->getTableName('sales_order_address');
     $tblSalesOrderItem = $connection->getTableName('sales_order_item');
     $tblSalesOrderPayment = $connection->getTableName('sales_order_payment');
     $tblSalesOrderStatusHistory = $connection->getTableName('sales_order_status_history');
     $tblSalesOrderGrid = $connection->getTableName('sales_order_grid');
     $tblLogQuote = $connection->getTableName('log_quote');
     $showTablesLog = $connection->fetchCol('SHOW TABLES LIKE ?', '%' . $tblLogQuote);
     $tblSalesOrderTax = $connection->getTableName('sales_order_tax');
     foreach ($collection->getItems() as $order) {
         $orderId = $order->getId();
         if ($order->getIncrementId()) {
             $incId = $order->getIncrementId();
             if (in_array($tblSalesOrder, $showTables)) {
                 $result1 = $connection->fetchAll('SELECT quote_id FROM `' . $tblSalesOrder . '` WHERE entity_id=' . $orderId);
                 $quoteId = (int) $result1[0]['quote_id'];
             }
             $connection->rawQuery('SET FOREIGN_KEY_CHECKS=1');
             if (in_array($tblSalesCreditmemoComment, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesCreditmemoComment . '` WHERE parent_id IN (SELECT entity_id FROM `' . $tblSalesCreditmemo . '` WHERE order_id=' . $orderId . ')');
             }
             if (in_array('sales__creditmemo_item', $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesCreditmemoItem . '` WHERE parent_id IN (SELECT entity_id FROM `' . $tblSalesCreditmemo . '` WHERE order_id=' . $orderId . ')');
             }
             if (in_array($tblSalesCreditmemo, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesCreditmemo . '` WHERE order_id=' . $orderId);
             }
             if (in_array($tblSalesCreditmemoGrid, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesCreditmemoGrid . '` WHERE order_id=' . $orderId);
             }
             if (in_array($tblSalesInvoiceComment, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesInvoiceComment . '` WHERE parent_id IN (SELECT entity_id FROM `' . $tblSalesInvoice . '` WHERE order_id=' . $orderId . ')');
             }
             if (in_array($tblSalesInvoiceItem, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesInvoiceItem . '` WHERE parent_id IN (SELECT entity_id FROM `' . $tblSalesInvoice . '` WHERE order_id=' . $orderId . ')');
             }
             if (in_array($tblSalesInvoice, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesInvoice . '` WHERE order_id=' . $orderId);
             }
             if (in_array($tblSalesInvoiceGrid, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesInvoiceGrid . '` WHERE order_id=' . $orderId);
             }
             if ($quoteId) {
                 if (in_array($tblQuoteAddressItem, $showTables)) {
                     $connection->rawQuery('DELETE FROM `' . $tblQuoteAddressItem . '` WHERE parent_item_id IN (SELECT address_id FROM `' . $tblQuoteAddress . '` WHERE quote_id=' . $quoteId . ')');
                 }
                 if (in_array($tblQuoteShippingRate, $showTables)) {
                     $connection->rawQuery('DELETE FROM `' . $tblQuoteShippingRate . '` WHERE address_id IN (SELECT address_id FROM `' . $tblQuoteAddress . '` WHERE quote_id=' . $quoteId . ')');
                 }
                 if (in_array($tblQuoteIDMask, $showTables)) {
                     $connection->rawQuery('DELETE FROM `' . $tblQuoteIDMask . '` where quote_id=' . $quoteId);
                 }
                 if (in_array($tblQuoteItemOption, $showTables)) {
                     $connection->rawQuery('DELETE FROM `' . $tblQuoteItemOption . '` WHERE item_id IN (SELECT item_id FROM `' . $tblQuoteItem . '` WHERE quote_id=' . $quoteId . ')');
                 }
                 if (in_array($tblQuote, $showTables)) {
                     $connection->rawQuery('DELETE FROM `' . $tblQuote . '` WHERE entity_id=' . $quoteId);
                 }
                 if (in_array($tblQuoteAddress, $showTables)) {
                     $connection->rawQuery('DELETE FROM `' . $tblQuoteAddress . '` WHERE quote_id=' . $quoteId);
                 }
                 if (in_array($tblQuoteItem, $showTables)) {
                     $connection->rawQuery('DELETE FROM `' . $tblQuoteItem . '` WHERE quote_id=' . $quoteId);
                 }
                 if (in_array('sales__quotePayment', $showTables)) {
                     $connection->rawQuery('DELETE FROM `' . $tblQuotePayment . '` WHERE quote_id=' . $quoteId);
                 }
             }
             if (in_array($tblSalesShipmentComment, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesShipmentComment . '` WHERE parent_id IN (SELECT entity_id FROM `' . $tblSalesShipment . '` WHERE order_id=' . $orderId . ')');
             }
             if (in_array($tblSalesShipmentItem, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesShipmentItem . '` WHERE parent_id IN (SELECT entity_id FROM `' . $tblSalesShipment . '` WHERE order_id=' . $orderId . ')');
             }
             if (in_array($tblSalesShipmentTrack, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesShipmentTrack . '` WHERE order_id IN (SELECT entity_id FROM `' . $tblSalesShipment . '` WHERE parent_id=' . $orderId . ')');
             }
             if (in_array($tblSalesShipment, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesShipment . '` WHERE order_id=' . $orderId);
             }
             if (in_array($tblSalesShipmentGrid, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesShipmentGrid . '` WHERE order_id=' . $orderId);
             }
             if (in_array($tblSalesOrder, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesOrder . '` WHERE entity_id=' . $orderId);
             }
             if (in_array($tblSalesOrderAddress, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesOrderAddress . '` WHERE parent_id=' . $orderId);
             }
             if (in_array($tblSalesOrderItem, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesOrderItem . '` WHERE order_id=' . $orderId);
             }
             if (in_array($tblSalesOrderPayment, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesOrderPayment . '` WHERE parent_id=' . $orderId);
             }
             if (in_array($tblSalesOrderStatusHistory, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesOrderStatusHistory . '` WHERE parent_id=' . $orderId);
             }
             if ($incId && in_array($tblSalesOrderGrid, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesOrderGrid . '` WHERE increment_id=' . $incId);
             }
             if (in_array($tblSalesOrderTax, $showTables)) {
                 $connection->rawQuery('DELETE FROM `' . $tblSalesOrderTax . '` WHERE order_id=' . $orderId);
             }
             if ($quoteId && $showTablesLog) {
                 $connection->rawQuery('DELETE FROM `' . $tblLogQuote . '` WHERE quote_id=' . $quoteId);
             }
             $connection->rawQuery('SET FOREIGN_KEY_CHECKS=1');
         }
         $countCancelOrder++;
     }
     $countNonCancelOrder = $collection->count() - $countCancelOrder;
     if ($countNonCancelOrder && $countCancelOrder) {
         $this->messageManager->addError(__('%1 order(s) cannot be deleted.', $countNonCancelOrder));
     } elseif ($countNonCancelOrder) {
         $this->messageManager->addError(__('You cannot delete the order(s).'));
     }
     if ($countCancelOrder) {
         $this->messageManager->addSuccess(__('We deleted %1 order(s).', $countCancelOrder));
     }
     $resultRedirect = $this->resultRedirectFactory->create();
     $resultRedirect->setPath('sales/*/');
     return $resultRedirect;
 }
예제 #27
0
 /**
  * {@inheritdoc}
  */
 protected function _afterLoad()
 {
     $this->walk('afterLoad');
     $this->_items = $this->walk('unserializeProperties');
     return parent::_afterLoad();
 }
 /**
  * Join store relation table if there is store filter
  *
  * @return void
  */
 protected function _renderFiltersBefore()
 {
     if ($this->getFilter('store')) {
         $this->getSelect()->join(['store_table' => $this->getTable('magefan_blog_category_store')], 'main_table.category_id = store_table.category_id', []);
     }
     parent::_renderFiltersBefore();
 }
 /**
  * Get SQL for get record count
  *
  * Extra GROUP BY strip added.
  *
  * @return \Magento\Framework\DB\Select
  */
 public function getSelectCountSql()
 {
     $countSelect = parent::getSelectCountSql();
     $countSelect->reset(\Magento\Framework\DB\Select::GROUP);
     return $countSelect;
 }
예제 #30
0
 /**
  * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
  * @param \Psr\Log\LoggerInterface $logger
  * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
  * @param \Magento\Framework\Event\ManagerInterface $eventManager
  * @param \Magento\Framework\Model\Entity\MetadataPool $metadataPool
  * @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection
  * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource
  */
 public function __construct(\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Model\Entity\MetadataPool $metadataPool, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null)
 {
     $this->metadataPool = $metadataPool;
     parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
 }