Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize bundle from Excel Connector Bundle
- Loading branch information
0 parents
commit 4cd530f
Showing
58 changed files
with
2,583 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
vendor | ||
composer.phar | ||
composer.lock | ||
/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
language: php | ||
sudo: false | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
|
||
matrix: | ||
allow_failures: | ||
- php: 7.1 | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache/files | ||
|
||
before_install: | ||
- echo "memory_limit=3G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
- phpenv config-rm xdebug.ini | ||
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config | ||
|
||
install: | ||
- composer self-update --no-interaction | ||
- composer update --no-interaction --no-scripts --prefer-dist | ||
|
||
script: | ||
- ./bin/phpspec run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Akeneo PIM | ||
|
||
The Open Software License version 3.0 | ||
|
||
Copyright (c) 2014, Akeneo SAS. | ||
|
||
Full license is at: http://opensource.org/licenses/OSL-3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Excel Installer Bundle | ||
|
||
[![Build Status](https://travis-ci.org/akeneo/ExcelInitBundle.svg?branch=master)](https://travis-ci.org/akeneo/ExcelInitBundle) | ||
|
||
![alt text](./src/Resources/doc/pictures/akeneo_excel.png "") | ||
|
||
This bundle adds support of Excel XSLX files as a source for initializing catalog structure for [Akeneo PIM](https://github.com/akeneo/pim-community-standard). | ||
|
||
**Note**: this bundle is not compatible with Excel 2003 xls files. | ||
|
||
## Requirements | ||
|
||
| ExcelInitBundle | Akeneo PIM Community Edition | | ||
|:---------------:|:----------------------------:| | ||
| v1.0.* | v1.6.* | | ||
|
||
## Installation | ||
|
||
From your application root: | ||
|
||
```bash | ||
php composer.phar require --prefer-dist akeneo/excel-installer-bundle:1.0.* | ||
``` | ||
|
||
Enable the bundle in the `app/AppKernel.php` file in the `registerProjectBundles()` method: | ||
|
||
```php | ||
$bundles = [ | ||
// ... | ||
new Pim\Bundle\ExcelInitBundle\PimExcelInitBundle(), | ||
] | ||
``` | ||
|
||
Now let's clean your cache and dump your assets: | ||
|
||
```bash | ||
php app/console cache:clear --env=prod | ||
php app/console pim:installer:assets --env=prod | ||
``` | ||
|
||
## Documentation | ||
|
||
### Getting started | ||
|
||
See [Resources/doc/Getting started](./Resources/doc/Getting-started.rst) for more details on how to set your catalog structure | ||
using the [init.xslx](./Resources/fixtures/minimal/init.xlsx) file. | ||
|
||
See [Resources/doc folder](./Resources/doc/Home.rst) for more details on how to set your catalog structure. | ||
|
||
### Supported file | ||
|
||
Input file must follow [init.xslx](./Resources/fixtures/minimal/init.xlsx) structure. | ||
Note that the file must be opened with Excel. | ||
LibreOffice/OpenOffice are not in compliance with validations data that are available in the spreadsheet. | ||
|
||
### Importation job | ||
|
||
This bundle allows you to import products files directly in the UI through Import > Import jobs. | ||
Please note that the init.xlsx import is also available via the UI. | ||
However, it should not be used as an import system for entities available within this file (families, categories, etc.) once the catalog structure has been set. | ||
|
||
## Troubleshooting | ||
|
||
###The import fails when importing families | ||
|
||
Check that your channels names are correct in both family and channel tabs. | ||
You might have a typo in the channels tab and not in the family tab. | ||
You will have to remove the mispelled channel once you corrected this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "akeneo/excel-init-bundle", | ||
"type": "symfony-bundle", | ||
"description": "Akeneo PIM Excel initialization bundle", | ||
"keywords": ["pim", "akeneo", "ecommerce", "e-commerce", "excel"], | ||
"homepage": "http://www.akeneo.com", | ||
"license": "OSL-3.0", | ||
"authors": [ | ||
{ | ||
"name": "Akeneo", | ||
"homepage": "http://www.akeneo.com" | ||
} | ||
], | ||
"repositories": [ | ||
{ | ||
"type": "vcs", | ||
"url": "https://github.com/akeneo/pim-community-dev.git", | ||
"branch": "master" | ||
} | ||
], | ||
"require": { | ||
"akeneo/pim-community-dev": "1.6.*@dev" | ||
}, | ||
"require-dev": { | ||
"phpspec/phpspec": "3.0.0", | ||
"friendsofphp/php-cs-fixer": "@stable", | ||
"squizlabs/php_codesniffer": "2.3.*", | ||
"phpmd/phpmd": "2.3.*", | ||
"henrikbjorn/phpspec-code-coverage": "3.0.1" | ||
}, | ||
"config": { | ||
"bin-dir": "bin" | ||
}, | ||
"autoload": { | ||
"psr-4": { "Pim\\Bundle\\ExcelInitBundle\\": "src/" } | ||
}, | ||
"minimum-stability": "stable", | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0.x-dev" | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
spec/Pim/Bundle/ExcelInitBundle/Iterator/ArrayHelperSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace spec\Pim\Bundle\ExcelInitBundle\Iterator; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
|
||
class ArrayHelperSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('Pim\Bundle\ExcelInitBundle\Iterator\ArrayHelper'); | ||
} | ||
|
||
function it_should_combine_arrays_with_less_keys_than_values() | ||
{ | ||
$keys = array('key1', 'key2'); | ||
$values = array('value1', 'value2', 'value3'); | ||
$this->combineArrays($keys, $values)->shouldReturn(array('key1' => 'value1', 'key2' => 'value2')); | ||
} | ||
|
||
function it_should_combine_arrays_with_more_keys_than_values() | ||
{ | ||
$keys = array('key1', 'key2', 'key3'); | ||
$values = array('value1', 'value2'); | ||
$this->combineArrays($keys, $values)->shouldReturn(array('key1' => 'value1', 'key2' => 'value2', 'key3' => '')); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
spec/Pim/Bundle/ExcelInitBundle/Iterator/InitAttributesFileIteratorSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace spec\Pim\Bundle\ExcelInitBundle\Iterator; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Pim\Bundle\ExcelInitBundle\Mapper\AttributeTypeMapperInterface; | ||
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; | ||
|
||
class InitAttributesFileIteratorSpec extends ObjectBehavior | ||
{ | ||
public function let(AttributeTypeMapperInterface $attributeTypesMapper) | ||
{ | ||
$this->beConstructedWith( | ||
'xlsx', | ||
$this->getPath() . DIRECTORY_SEPARATOR . 'dummy1.xlsx', | ||
[ | ||
'header_key' => 'header1', | ||
'include_worksheets' => ['/^Sheet4$/'], | ||
'attribute_types_mapper' => $attributeTypesMapper, | ||
] | ||
); | ||
} | ||
|
||
public function it_must_have_a_mapper_as_option() | ||
{ | ||
$this->beConstructedWith( | ||
'xlsx', | ||
$this->getPath() . DIRECTORY_SEPARATOR . 'dummy2.xlsx', | ||
[ | ||
'header_key' => 'header1', | ||
'include_worksheets' => ['/^Sheet4$/'], | ||
] | ||
); | ||
$this->shouldThrow(MissingOptionsException::class)->duringInstantiation(); | ||
} | ||
|
||
public function it_can_get_the_mapper($attributeTypesMapper) | ||
{ | ||
$this->getAttributeTypesMapper()->shouldReturn($attributeTypesMapper); | ||
} | ||
|
||
private function getPath() | ||
{ | ||
return __DIR__ . DIRECTORY_SEPARATOR . '..' . | ||
DIRECTORY_SEPARATOR . 'fixtures'; | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
spec/Pim/Bundle/ExcelInitBundle/Iterator/InitFileIteratorSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
|
||
namespace spec\Pim\Bundle\ExcelInitBundle\Iterator; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
|
||
class InitFileIteratorSpec extends ObjectBehavior | ||
{ | ||
public function it_can_read_multiple_tabs() | ||
{ | ||
$this->beConstructedWith( | ||
'xlsx', | ||
$this->getPath() . DIRECTORY_SEPARATOR . 'dummy1.xlsx', | ||
[ | ||
'header_key' => 'header1', | ||
'include_worksheets' => ['/^Sheet1$/', '/^Sheet2$/'], | ||
] | ||
); | ||
$this->rewind(); | ||
$values = [ | ||
['header1', 'header2', 'header3', 'header4', 'header5',], | ||
['Value-1-1-1', 'Value-1-1-2', 'Value-1-1-3', 'Value-1-1-4', 'Value-1-1-5',], | ||
['Value-1-2-1', 'Value-1-2-2', 'Value-1-2-3', 'Value-1-2-4', 'Value-1-2-5',], | ||
['Value-1-3-1', 'Value-1-3-2', 'Value-1-3-3', 'Value-1-3-4', 'Value-1-3-5',], | ||
['Value-1-4-1', 'Value-1-4-2', 'Value-1-4-3', 'Value-1-4-4', 'Value-1-4-5',], | ||
['Value-1-5-1', 'Value-1-5-2', 'Value-1-5-3', 'Value-1-5-4', 'Value-1-5-5',], | ||
['Value-2-1-1', 'Value-2-1-2', 'Value-2-1-3', 'Value-2-1-4', 'Value-2-1-5',], | ||
['Value-2-2-1', 'Value-2-2-2', 'Value-2-2-3', 'Value-2-2-4', 'Value-2-2-5',], | ||
['Value-2-3-1', 'Value-2-3-2', 'Value-2-3-3', 'Value-2-3-4', 'Value-2-3-5',], | ||
['Value-2-4-1', 'Value-2-4-2', 'Value-2-4-3', 'Value-2-4-4', 'Value-2-4-5',], | ||
['Value-2-5-1', 'Value-2-5-2', 'Value-2-5-3', 'Value-2-5-4', 'Value-2-5-5',], | ||
]; | ||
foreach ($values as $row) { | ||
$this->current()->shouldReturn($row); | ||
$this->next(); | ||
} | ||
$this->valid()->shouldReturn(false); | ||
} | ||
|
||
public function it_can_filter_excluded_tabs() | ||
{ | ||
$this->beConstructedWith( | ||
'xlsx', | ||
$this->getPath() . DIRECTORY_SEPARATOR . 'dummy1.xlsx', | ||
[ | ||
'header_key' => 'header1', | ||
'exclude_worksheets' => ['/^Sheet[134]$/'], | ||
] | ||
); | ||
$this->rewind(); | ||
$values = [ | ||
['header1', 'header2', 'header3', 'header4', 'header5',], | ||
['Value-2-1-1', 'Value-2-1-2', 'Value-2-1-3', 'Value-2-1-4', 'Value-2-1-5',], | ||
['Value-2-2-1', 'Value-2-2-2', 'Value-2-2-3', 'Value-2-2-4', 'Value-2-2-5',], | ||
['Value-2-3-1', 'Value-2-3-2', 'Value-2-3-3', 'Value-2-3-4', 'Value-2-3-5',], | ||
['Value-2-4-1', 'Value-2-4-2', 'Value-2-4-3', 'Value-2-4-4', 'Value-2-4-5',], | ||
['Value-2-5-1', 'Value-2-5-2', 'Value-2-5-3', 'Value-2-5-4', 'Value-2-5-5',], | ||
]; | ||
foreach ($values as $row) { | ||
$this->current()->shouldReturn($row); | ||
$this->next(); | ||
} | ||
$this->valid()->shouldReturn(false); | ||
} | ||
|
||
public function it_can_filter_included_and_excluded_tabs() | ||
{ | ||
$this->beConstructedWith( | ||
'xlsx', | ||
$this->getPath() . DIRECTORY_SEPARATOR . 'dummy1.xlsx', | ||
[ | ||
'header_key' => 'header1', | ||
'include_worksheets' => ['/^Sheet1$/', '/^Sheet2$/'], | ||
'exclude_worksheets' => ['/^Sheet1$/'], | ||
] | ||
); | ||
$this->rewind(); | ||
$values = [ | ||
['header1', 'header2', 'header3', 'header4', 'header5',], | ||
['Value-2-1-1', 'Value-2-1-2', 'Value-2-1-3', 'Value-2-1-4', 'Value-2-1-5',], | ||
['Value-2-2-1', 'Value-2-2-2', 'Value-2-2-3', 'Value-2-2-4', 'Value-2-2-5',], | ||
['Value-2-3-1', 'Value-2-3-2', 'Value-2-3-3', 'Value-2-3-4', 'Value-2-3-5',], | ||
['Value-2-4-1', 'Value-2-4-2', 'Value-2-4-3', 'Value-2-4-4', 'Value-2-4-5',], | ||
['Value-2-5-1', 'Value-2-5-2', 'Value-2-5-3', 'Value-2-5-4', 'Value-2-5-5',], | ||
]; | ||
} | ||
|
||
public function it_can_use_a_different_valdata_range() | ||
{ | ||
$this->beConstructedWith( | ||
'xlsx', | ||
$this->getPath() . DIRECTORY_SEPARATOR . 'dummy1.xlsx', | ||
[ | ||
'header_key' => 'header1', | ||
'include_worksheets' => ['/^Sheet3$/'], | ||
] | ||
); | ||
$this->rewind(); | ||
$values = [ | ||
['header1', 'header2', 'header3', 'header4', 'header5',], | ||
['Value-3-1-1', 'Value-3-1-2', 'Value-3-1-3', 'Value-3-1-4', 'Value-3-1-5',], | ||
['Value-3-2-1', 'Value-3-2-2', 'Value-3-2-3', 'Value-3-2-4', 'Value-3-2-5',], | ||
['Value-3-3-1', 'Value-3-3-2', 'Value-3-3-3', 'Value-3-3-4', 'Value-3-3-5',], | ||
['Value-3-4-1', 'Value-3-4-2', 'Value-3-4-3', 'Value-3-4-4', 'Value-3-4-5',], | ||
['Value-3-5-1', 'Value-3-5-2', 'Value-3-5-3', 'Value-3-5-4', 'Value-3-5-5',], | ||
]; | ||
foreach ($values as $row) { | ||
$this->current()->shouldReturn($row); | ||
$this->next(); | ||
} | ||
$this->valid()->shouldReturn(false); | ||
} | ||
|
||
|
||
private function getPath() | ||
{ | ||
return __DIR__ . DIRECTORY_SEPARATOR . '..' . | ||
DIRECTORY_SEPARATOR . 'fixtures'; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
spec/Pim/Bundle/ExcelInitBundle/Mapper/AttributeTypeMapperSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace spec\Pim\Bundle\ExcelInitBundle\Mapper; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
|
||
class AttributeTypeMapperSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable() | ||
{ | ||
$this->shouldImplement('Pim\Bundle\ExcelInitBundle\Mapper\AttributeTypeMapperInterface'); | ||
} | ||
|
||
function it_should_get_mapped_attribute_types() | ||
{ | ||
$this->addAttributeTypeMapping('label1', 'type1'); | ||
$this->addAttributeTypeMapping('label2', 'type2'); | ||
|
||
$this->getMappedValue('label1')->shouldReturn('type1'); | ||
$this->getMappedValue('label2')->shouldReturn('type2'); | ||
} | ||
|
||
function it_should_return_null_for_non_mapped_attribute_types() | ||
{ | ||
$this->addAttributeTypeMapping('label1', 'type1'); | ||
$this->addAttributeTypeMapping('label2', 'type2'); | ||
|
||
$this->getMappedValue('label3')->shouldReturn(null); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.