Skip to content

Commit

Permalink
Move to github
Browse files Browse the repository at this point in the history
  • Loading branch information
imsamthomas committed Apr 11, 2018
1 parent b2a3f4a commit 99f30b9
Show file tree
Hide file tree
Showing 16 changed files with 303 additions and 0 deletions.
61 changes: 61 additions & 0 deletions Controller/Adminhtml/Order/Delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Mageplaza\DeleteOrder\Controller\Adminhtml\Order;

use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection as DbAC;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
use Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction;
use Magento\Sales\Model\OrderRepository;
use Magento\Framework\Controller\ResultFactory;
use Magento\Sales\Model\ResourceModel\Grid;
use Mageplaza\DeleteOrder\Helper\Data as DataHelper;


class Delete extends AbstractMassAction
{
protected $orderRepository;
protected $helper;

/**
* @param Context $context
* @param Filter $filter
* @param CollectionFactory $collectionFactory
*/
public function __construct(
Context $context,
Filter $filter,
CollectionFactory $collectionFactory,
OrderRepository $orderRepository,
DataHelper $dataHelper
) {
parent::__construct($context, $filter);
$this->collectionFactory = $collectionFactory;
$this->orderRepository = $orderRepository;
$this->helper = $dataHelper;
}

protected function massAction(DbAC $collection)
{
if ($this->helper->isEnabled()) {
$orderDeleted = 0;
foreach ($collection as $order) {
$this->orderRepository->deleteById($order->getId());
$orderDeleted++;
}
if ($orderDeleted) {
$this->messageManager->addSuccess(__('A total of %1 record(s) were deleted.', $orderDeleted));
}
} else {
$this->messageManager->addError(__('Delete Order module is Disabled'));
}

/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setPath($this->getComponentRefererUrl());

return $resultRedirect;
}

}
26 changes: 26 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Mageplaza\DeleteOrder\Helper;

use Mageplaza\Core\Helper\AbstractData;
use Magento\Store\Model\ScopeInterface;

class Data extends AbstractData
{
const XML_PATH_GENERAL_ENABLED = 'deleteorder/general/is_enabled';

public function getConfigValue($field, $storeId = null)
{
return $this->scopeConfig->getValue(
$field,
ScopeInterface::SCOPE_STORE,
$storeId
);
}

public function isEnabled($storeId = null)
{
return $this->getConfigValue(self::XML_PATH_GENERAL_ENABLED, $storeId);

}
}
33 changes: 33 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Mageplaza Co. Ltd.

This License is entered by Mageplaza to govern the usage or redistribution of Mageplaza software. This is a legal agreement between you (either an individual or a single entity) and Mageplaza for Mageplaza software product(s) which may include extensions, templates and services.

By purchasing, installing, or otherwise using Mageplaza products, you acknowledge that you have read this License and agree to be bound by the terms of this Agreement. If you do not agree to the terms of this License, do not install or use Mageplaza products.

The Agreement becomes effective at the moment when you acquire software from our site or receive it through email or on data medium or by any other means. Mageplaza reserves the right to make reasonable changes to the terms of this license agreement and impose its clauses at any given time.

1. GRANT OF LICENSE: By purchasing a product of Mageplaza:

1. Customer will receive source code open 100%.

2. Customer will obtain a License Certificate which will remain valid until the Customer stops using the Product or until Mageplaza terminates this License because of Customer’s failure to comply with any of its Terms and Conditions. Each License Certificate includes a license serial which is valid for one live Magento installation only and unlimited test Magento installations.

3. You are allowed to customize our products to fit with your using purpose.

4. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS

5. Installation and Use

6. For each new Software installation, you are obliged to purchase a separate License. You are not permitted to use any part of the code in whole or part in any other software or product or website. You are legally bound to preserve the copyright information intact including the text/link at bottom.

2. Distribution: You are not allowed to distribute Mageplaza software to third parties. Any distribution without our permission, including non commercial distribution is considered as violation of this Agreement and entails liability, according to the current law. You may not place the Software onto a server that allows access to the Software via a public network or the Internet for distribution purposes.

3. Rental: You may not give, sell, sub-license, rent, lease or lend any portion of the Software to anyone.

4. Compliance with Applicable Laws: You must comply with all applicable laws regarding use of software products. Mageplaza software and a portion of it are protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. Accordingly, customer is required to treat the software like any other copyrighted material. Any activity violating copyright law will be prosecuted according to the current law. We retain the right to revoke the license of any user holding an invalid license.

5. TERMINATION: Without prejudice to any other rights, Mageplaza may terminate this License at any time if you fail to comply with the terms and conditions of this License. In such event, it constitutes a breach of the agreement, and your license to use the program is revoked and you must destroy all copies of Mageplaza products in your possession. After being notified of termination of your license, if you continue to use Mageplaza software, you hereby agree to accept an injunction to prevent you from its further use and to pay all costs (including but not limited to reasonable attorney fees) to enforce our revocation of your license and any damages suffered by us because of your misuse of the Software. We are not bound to return you the amount spent for purchase of the Software for the termination of this License.

6. LIMITATION OF LIABILITY: In no event shall Mageplaza be liable for any damages (including, without limitation, lost profits, business interruption, or lost information) rising out of ‘Authorized Users’ use of or inability to use the Mageplaza products, even if Mageplaza has been advised of the possibility of such damages. In no event will Mageplaza be liable for prosecution arising from use of the Software against law or for any illegal use.

The latest License : https://www.mageplaza.com/LICENSE.txt
34 changes: 34 additions & 0 deletions USER-GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Delete Orders User Guide


## Documentation

- Installation guide: https://www.mageplaza.com/install-magento-2-extension/
- User guide:http://docs.mageplaza.com/delete-order-m2/index.html
- Introduction page: https://www.mageplaza.com/magento-2-delete-orders/
- Get Support: https://github.com/mageplaza/magento-2-delete-orders/issues
- Contribute on Github: https://github.com/mageplaza/magento-2-delete-orders
- Changelog: https://www.mageplaza.com/changelog/m2-delete-order.txt
- License https://www.mageplaza.com/LICENSE.txt


## How to install

### Install via composer [Recommend]

Run the following command in Magento 2 root folder

```
composer require mageplaza/magento-2-blog-extension
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
```


## FAQs

#### Q: I got error: `Mageplaza_Core has been already defined`
A: Read solution: https://github.com/mageplaza/module-core/issues/3

#### Q: My site is down
A: Please follow this guide: https://www.mageplaza.com/blog/magento-site-down.html
25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "mageplaza/module-delete-order",
"description": "",
"require": {
"mageplaza/module-core": "*"
},
"type": "magento2-module",
"version": "1.0.0",
"authors": [
{
"name": "Mageplaza",
"email": "[email protected]",
"homepage": "https://www.mageplaza.com",
"role": "Leader"
}
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Mageplaza\\DeleteOrder\\": ""
}
}
}
22 changes: 22 additions & 0 deletions etc/acl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Mageplaza_Core::menu">
<resource id="Mageplaza_DeleteOrder::deleteorder" title="Delete Order" sortOrder="30">
<resource id="Mageplaza_DeleteOrder::configuration" title="Configuration" sortOrder="10"/>
</resource>
</resource>
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Mageplaza_DeleteOrder::config_deleteorder" title="Delete Order"/>
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
15 changes: 15 additions & 0 deletions etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!--<preference for="Magento\Framework\Model\AbstractModel" type="Ibnab\DeleteOrder\Model\NormalModel" />-->
<type name="Mageplaza\DeleteOrder\Controller\Adminhtml\Order\MassDelete">
<arguments>
<argument name="deleteAction" xsi:type="array">
<item name="context" xsi:type="string">Magento\Backend\App\Action\Context</item>
<item name="resource" xsi:type="string">Magento\Framework\App\ResourceConnection</item>
<item name="filter" xsi:type="string">Magento\Ui\Component\MassAction\Filter</item>
<item name="collection" xsi:type="string">Magento\Sales\Model\ResourceModel\Order\CollectionFactory</item>
</argument>
</arguments>
</type>

</config>
7 changes: 7 additions & 0 deletions etc/adminhtml/menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Mageplaza_DeleteOrder::deleteorder" title="Delete Order" module="Mageplaza_DeleteOrder" sortOrder="100" resource="Mageplaza_DeleteOrder::deleteorder" parent="Mageplaza_Core::menu"/>
<add id="Mageplaza_DeleteOrder::configuration" title="Configuration" module="Mageplaza_DeleteOrder" sortOrder="10" action="adminhtml/system_config/edit/section/deleteorder" resource="Mageplaza_DeleteOrder::configuration" parent="Mageplaza_DeleteOrder::deleteorder"/>
</menu>
</config>
8 changes: 8 additions & 0 deletions etc/adminhtml/routes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="deleteorder" frontName="deleteorder">
<module name="Mageplaza_DeleteOrder" before="Magento_Backend"/>
</route>
</router>
</config>
18 changes: 18 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="deleteorder" translate="label" type="text" sortOrder="450" showInDefault="1" showInWebsite="1" showInStore="1">
<class>separator-top</class>
<label>Delete Order</label>
<tab>mageplaza</tab>
<resource>Mageplaza_DeleteOrder::config_deleteorder</resource>
<group id="general" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General</label>
<field id="is_enabled" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
</section>
</system>
</config>
10 changes: 10 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<deleteorder>
<general>
<is_enabled>1</is_enabled>
</general>
</deleteorder>
</default>
</config>
8 changes: 8 additions & 0 deletions etc/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mageplaza_DeleteOrder" setup_version="1.0.0">
<sequence>
<module name="Magento_Sales"/>
<module name="Mageplaza_Core"/>
</sequence>
</module>
</config>
4 changes: 4 additions & 0 deletions i18n/en_US.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"Delete Order","Delete Order"
"Delete Order module is Disabled","Delete Order module is Disabled"
"Enable","Enable"
"General","General"
6 changes: 6 additions & 0 deletions registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Mageplaza_DeleteOrder',
__DIR__
);
20 changes: 20 additions & 0 deletions view/adminhtml/ui_component/sales_order_grid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<massaction name="listing_massaction">
<action name="delete">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="type" xsi:type="string">delete</item>
<item name="label" xsi:type="string" translate="true">Delete</item>
<item name="url" xsi:type="url" path="deleteorder/order/delete"/>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete items</item>
<item name="message" xsi:type="string" translate="true">Do you really want to delete?</item>
</item>
</item>
</argument>
</action>
</massaction>
</listingToolbar>
</listing>
6 changes: 6 additions & 0 deletions view/adminhtml/web/css/source/_module.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.admin__menu #menu-mageplaza-core-menu .item-deleteorder.parent.level-1 > strong:before {
content: '\e630';
font-family: 'Admin Icons';
font-size: 1.5rem;
margin-right: .8rem;
}

0 comments on commit 99f30b9

Please sign in to comment.