Skip to content

Commit

Permalink
Merge pull request #17 from DivanteLtd/feature/pimcore6.5
Browse files Browse the repository at this point in the history
Feature/pimcore6.5
  • Loading branch information
Kuba Płaskonka authored Feb 26, 2020
2 parents cec96df + 9d80541 commit abcbca0
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
],
"require": {
"pimcore/pimcore": "^6.3",
"divanteltd/pimcoredevkit": "^0.7",
"divanteltd/pimcoredevkit": "^0.10",
"dpfaffenbauer/process-manager": "^2.0"
},
"require-dev": {
Expand Down
Binary file removed docs/example.jpeg
Binary file not shown.
Binary file added docs/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 32 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
[![Total Downloads](https://poser.pugx.org/divante-ltd/pimcore-scheduled-export/downloads)](https://packagist.org/packages/divante-ltd/pimcore-scheduled-export)
[![License](https://poser.pugx.org/divante-ltd/pimcore-scheduled-export/license)](https://github.com/DivanteLtd/divante-ltd/pimcore-scheduled-export/blob/master/LICENSE)

Scheduled Export lets you run ordinary grid exports in background.
Scheduled Export lets you run ordinary grid exports in the background or using cli.

![Scheduled Export](docs/example.jpeg?raw=true "Scheduled Export")
![Scheduled Export](docs/example.png?raw=true "Scheduled Export")

**Table of Contents**
- [Scheduled Export](#scheduled-export)
- [Compatibility](#compatibility)
- [Installing/Getting started](#installinggetting-started)
- [Requirements](#requirements)
- [Configuration](#configuration)
- [Usage](#Usage)
- [Testing](#testing)
- [Contributing](#contributing)
- [Licence](#licence)
Expand All @@ -26,21 +26,45 @@ Scheduled Export lets you run ordinary grid exports in background.

This module is compatible with Pimcore 5.5.0 and higher.

## Installing/Getting startedr
## Installing

```bash
composer require divante-ltd/pimcore-scheduled-export
```

Make sure the dependencies are enabled and installed:
```bash
./bin/console pimcore:bundle:enable PimcoreDevkitBundle
./bin/console pimcore:bundle:enable ProcessManagerBundle
./bin/console pimcore:bundle:install ProcessManagerBundle
```

Enable the Bundle:
```bash
./bin/console pimcore:bundle:enable DivanteScheduledExportBundle
```

## Configuration
## Requirements

* Pimcore 5 or 6
* Pimcore Devkit
* ProcessManager

In Pimcore panel select Extensions click Install and Enable.
## Usage
Prepare a gridconfig that you want to export, open up ProcessManager, create a new Scheduled Export Executable.
In the configuration window, select the folder you want to export, gridconfig and where the exported file should be saved.

Adjust other settings at your will.

Configure the schedule using ProcessManager's cron settings or run the export manually.
Keep in mind, that currently there is no progress display support, so export will not be visible in Processes tab of the ProcessManager.

You can also run the export from the cli if desired:

```bash
bin/console scheduled-export:start -g 3 -f '/Product Data/Cars' -a '/Export' --filename 'cars' -t 1 --format '%s' -c 'o_key like "%Giu%"' --only-changes 1
```
Type `bin/console scheduled-export:start --help` to get detailed description of the parameters.
## Testing
Unit Tests:
```bash
Expand All @@ -58,11 +82,11 @@ PIMCORE_TEST_DB_DSN="mysql://username:password@localhost/pimcore_test" \
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.

## Licence
CoreShop VsBridge source code is completely free and released under the
Pimcore Scheduled Export source code is completely free and released under the
[GNU General Public License v3.0](https://github.com/DivanteLtd/divante-ltd/pimcore-scheduled-export/blob/master/LICENSE).

## Standards & Code Quality
This module respects all Pimcore 5 code quality rules and our own PHPCS and PHPMD rulesets.
This module respects all Pimcore code quality rules and our own PHPCS and PHPMD rulesets.

## About Authors
![Divante-logo](http://divante.co/logo-HG.png "Divante")
Expand Down
16 changes: 14 additions & 2 deletions src/ScheduledExportBundle/Controller/GridConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Divante\ScheduledExportBundle\Controller;

use Pimcore\Bundle\AdminBundle\Controller\AdminController;
use Pimcore\Bundle\AdminBundle\HttpFoundation\JsonResponse;
use Pimcore\Bundle\AdminBundle\Security\User\User;
use Pimcore\Model\DataObject\ClassDefinition;
use Pimcore\Model\GridConfig;
Expand All @@ -16,27 +17,38 @@
*/
class GridConfigController extends AdminController
{
/** @var string True indicator for share globally */
const SHARE_GLOBALLY_TRUE = "1";

/**
* @param Request $request
* @return \Pimcore\Bundle\AdminBundle\HttpFoundation\JsonResponse
* @throws \Exception
*
* @Route("/admin/scheduled-export/grid-config/get-list")
*/
public function getListAction(Request $request)
public function getListAction(Request $request) : JsonResponse
{
$user = $this->getAdminUser();
$gridConfigs = new GridConfig\Listing();
$gridConfigs->setCondition("ownerId = ? or shareGlobally = ?", [$user->getId(), self::SHARE_GLOBALLY_TRUE]);
$gridConfigs->load();
$result = [];


/** @var GridConfig $gridConfig */
foreach ($gridConfigs->getGridConfigs() as $gridConfig) {
$classDefinition = ClassDefinition::getById($gridConfig->getClassId());
$user = \Pimcore\Model\User::getById($gridConfig->getOwnerId());
if ($user) {
$userName = $user->getName();
} else {
$userName = "unknown";
}
$result[] = [
"id" => $gridConfig->getId(),
"name" => "[" . $gridConfig->getId() . "] " . $classDefinition->getName() . ": " .
$gridConfig->getName() . " (" . $user->getName() . ")"
$gridConfig->getName() . " (" . $userName . ")"
];
}

Expand Down
17 changes: 11 additions & 6 deletions src/ScheduledExportBundle/Export/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Divante\ScheduledExportBundle\Export;

use AppBundle\Util\StringWebsiteSettings;
use Pimcore\Bundle\AdminBundle\Controller\Admin\DataObject\DataObjectHelperController;
use Pimcore\Localization\LocaleService;
use Pimcore\Logger;
Expand Down Expand Up @@ -81,13 +80,18 @@ public function __construct(
$this->setContainer($container);
}

public function getExportSetting() : StringWebsiteSettings
public function getExportSetting() : WebsiteSetting
{
$settings = new StringWebsiteSettings(
$this->gridConfig->getId() .
$settings = WebsiteSetting::getByName($this->gridConfig->getId() .
"_" . Folder::getByPath($this->objectsFolder)->getId() .
"_" . self::WS_NAME
);
"_" . self::WS_NAME);
if (!$settings) {
$settings = new WebsiteSetting();
$settings->setName($this->gridConfig->getId() .
"_" . Folder::getByPath($this->objectsFolder)->getId() .
"_" . self::WS_NAME);
$settings->save();
}

return $settings;
}
Expand Down Expand Up @@ -349,6 +353,7 @@ private function updateSettingsDate(): void
if ($this->onlyChanges) {
$settings = $this->getExportSetting();
$settings->setData(strftime("%Y-%m-%d %T", $this->importStartTimestamp));
$settings->save();
}
}
}
4 changes: 4 additions & 0 deletions src/ScheduledExportBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ services:
public: true
tags: ['controller.service_arguments']

Divante\ScheduledExportBundle\Command\:
resource: '../../Command/*'
tags: ['console.command']

scheduledexport.process_manager.process:
class: Divante\ScheduledExportBundle\ProcessManager\ScheduledExportProcess
tags:
Expand Down

0 comments on commit abcbca0

Please sign in to comment.