-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit from internal project, cleaned up sources to make them…
… more generic
- Loading branch information
0 parents
commit 2543c17
Showing
56 changed files
with
2,606 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,88 @@ | ||
FROM php:7.2-cli-alpine | ||
|
||
LABEL maintainer="Grégory Planchat <[email protected]>" | ||
|
||
ARG APP_UID=1000 | ||
ARG APP_GID=1000 | ||
ARG APP_USERNAME=docker | ||
ARG APP_GROUPNAME=docker | ||
|
||
RUN set -ex\ | ||
&& apk update \ | ||
&& apk upgrade \ | ||
&& echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ | ||
&& apk add \ | ||
shadow@testing \ | ||
ca-certificates \ | ||
wget \ | ||
autoconf \ | ||
bash \ | ||
binutils \ | ||
expat \ | ||
file \ | ||
g++ \ | ||
gcc \ | ||
m4 \ | ||
make \ | ||
git \ | ||
nodejs \ | ||
npm \ | ||
&& update-ca-certificates | ||
|
||
RUN docker-php-ext-install opcache | ||
|
||
RUN apk add --update icu-dev icu \ | ||
&& docker-php-ext-configure intl \ | ||
&& docker-php-ext-install intl \ | ||
&& apk del icu-dev | ||
|
||
RUN apk del \ | ||
autoconf \ | ||
bash \ | ||
binutils \ | ||
expat \ | ||
file \ | ||
g++ \ | ||
gcc \ | ||
gdbm \ | ||
gmp \ | ||
isl \ | ||
libatomic \ | ||
libbz2 \ | ||
libc-dev \ | ||
libffi \ | ||
libgcc \ | ||
libgomp \ | ||
libldap \ | ||
libltdl \ | ||
libmagic \ | ||
libstdc++ \ | ||
libtool \ | ||
m4 \ | ||
make \ | ||
mpc1 \ | ||
mpfr3 \ | ||
musl-dev \ | ||
perl \ | ||
pkgconf \ | ||
pkgconfig \ | ||
python \ | ||
re2c \ | ||
readline \ | ||
sqlite-libs \ | ||
&& rm -rf /tmp/* /var/cache/apk/* | ||
|
||
RUN addgroup -g ${APP_GID} ${APP_USERNAME} \ | ||
&& adduser -u ${APP_UID} -h /opt/${APP_USERNAME} -H -G ${APP_GROUPNAME} -s /sbin/nologin -D ${APP_USERNAME} | ||
|
||
COPY config/memory.ini /usr/local/etc/php/conf.d/memory.ini | ||
|
||
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ | ||
&& php -r "if (hash_file('SHA384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \ | ||
&& php composer-setup.php --install-dir /usr/local/bin --filename composer\ | ||
&& php -r "unlink('composer-setup.php');" | ||
|
||
RUN mkdir -p /opt/docker/.npm \ | ||
&& chown docker:docker /opt/docker/.npm | ||
|
||
WORKDIR /app |
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 @@ | ||
memory_limit=-1 |
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,163 @@ | ||
Akeneo Fixtures Generation Toolbox | ||
================================== | ||
|
||
This classes and templates toolbox helps generating CSV fixtues from Magento 1.9CE or 1.14EE catalog. | ||
|
||
Example | ||
------- | ||
|
||
```php | ||
#!/ur/bin/env php | ||
<?php | ||
|
||
require __DIR__ . '/vendor/autoload.php'; | ||
|
||
use Kiboko\Bridge\Akeneo\Magento\Attribute; | ||
use Kiboko\Bridge\Akeneo\Magento\AttributeRenderer; | ||
use Kiboko\Bridge\Akeneo\Magento\FieldResolver; | ||
use Kiboko\Bridge\Akeneo\Magento\MagentoStore; | ||
use Kiboko\Bridge\Akeneo\Magento\Locale; | ||
use Kiboko\Bridge\Akeneo\Magento\Scope; | ||
use Kiboko\Bridge\Akeneo\Magento\Renderer; | ||
use Kiboko\Bridge\Akeneo\Magento\TwigExtension; | ||
|
||
$twig = new \Twig\Environment( | ||
new Twig\Loader\FilesystemLoader([ | ||
__DIR__ . '/../templates' | ||
]) | ||
); | ||
$twig->addExtension(new TwigExtension()); | ||
|
||
$locales = [ | ||
$fr_FR = new Locale\Locale('fr_FR', new MagentoStore(1)), | ||
$de_DE = new Locale\Locale('de_DE', new MagentoStore(2)), | ||
$en_GB = new Locale\Locale('en_GB', new MagentoStore(2)), | ||
$en_US = new Locale\Locale('en_US', new MagentoStore(4)), | ||
$ja_JP = new Locale\Locale('ja_JP', new MagentoStore(5)), | ||
$fr_CA = new Locale\Locale('fr_CA', new MagentoStore(8)), | ||
]; | ||
|
||
$scopes = [ | ||
new Scope\Scope( | ||
'europe', | ||
new MagentoStore(1), | ||
$fr_FR, | ||
$de_DE, | ||
$en_GB | ||
), | ||
new Scope\Scope( | ||
'america', | ||
new MagentoStore(4), | ||
$en_US, | ||
$fr_CA, | ||
new Locale\LocaleMapping($en_US, new MagentoStore(9)) // Additional locale mapping for Canada | ||
), | ||
new Scope\Scope( | ||
'asia', | ||
new MagentoStore(5), | ||
$ja_JP, | ||
new Locale\LocaleMapping($en_GB, new MagentoStore(6)) // Additional locale mapping for Hong Kong | ||
), | ||
]; | ||
|
||
$globalized = new FieldResolver\Globalised(); | ||
$localized = new FieldResolver\Localized(...$locales); | ||
$scoped = new FieldResolver\Scoped(...$scopes); | ||
$scopedAndLocalized = new FieldResolver\ScopedAndLocalized(...$scopes); | ||
$axis = new FieldResolver\VariantAxis(); | ||
|
||
$renderer = new Renderer( | ||
'initialize.sql.twig', | ||
'finalize-product-parents.sql.twig', | ||
['configurable'], | ||
// 1st level Product Models | ||
new AttributeRenderer\Image( | ||
new Attribute\AdHoc('image'), | ||
$scoped | ||
), | ||
new AttributeRenderer\Varchar( | ||
new Attribute\AdHoc('name'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\Text( | ||
new Attribute\AdHoc('description'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\Text( | ||
new Attribute\AdHoc('short_description'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\Varchar( | ||
new Attribute\AdHoc('meta_title'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\Text( | ||
new Attribute\AdHoc('meta_description'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\SimpleSelect( | ||
new Attribute\AdHoc('model'), | ||
$scoped | ||
), | ||
new AttributeRenderer\SimpleSelect( | ||
new Attribute\AdHoc('manufacturer'), | ||
$scoped | ||
) | ||
); | ||
|
||
$renderer(fopen('products_models1.sql', 'w'), $twig); | ||
|
||
$renderer = new Renderer( | ||
'initialize.sql.twig', | ||
'finalize-product-children.sql.twig', | ||
[], | ||
// 2nd level Product Models | ||
new AttributeRenderer\SimpleSelect( | ||
new Attribute\AdHoc('color'), | ||
$axis | ||
) | ||
); | ||
|
||
$renderer(fopen('products_models2.sql', 'w'), $twig); | ||
|
||
$renderer = new Renderer( | ||
'initialize.sql.twig', | ||
'finalize-products.sql.twig', | ||
['simple', 'virtual'], | ||
// Product & Product variants | ||
new AttributeRenderer\Status( | ||
new Attribute\AdHoc('status'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\Visibility( | ||
new Attribute\AdHoc('visibility'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\SimpleSelect( | ||
new Attribute\AdHoc('size'), | ||
$axis | ||
), | ||
new AttributeRenderer\Image( | ||
new Attribute\Aliased('image', 'variation_image'), | ||
$scoped | ||
), | ||
new AttributeRenderer\Varchar( | ||
new Attribute\Aliased('name', 'variation_name'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\Text( | ||
new Attribute\Aliased('description', 'variation_description'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\Datetime( | ||
new Attribute\AdHoc('news_from_date'), | ||
$scopedAndLocalized | ||
), | ||
new AttributeRenderer\Datetime( | ||
new Attribute\AdHoc('news_to_date'), | ||
$scopedAndLocalized | ||
) | ||
); | ||
|
||
$renderer(fopen('products.sql', 'w'), $twig); | ||
``` |
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,44 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
try { | ||
$pdo = new \PDO($argv[1], $argv[2], $argv[3], [ | ||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, | ||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', | ||
]); | ||
|
||
for ($i = 4; $i < $argc; ++$i) { | ||
$requests = array_filter(explode(';', file_get_contents($argv[$i])), function($request) { | ||
return !empty(trim($request)); | ||
}); | ||
|
||
foreach ($requests as $request) { | ||
$pdo->exec($request); | ||
} | ||
} | ||
|
||
$statement = $pdo->prepare($request = file_get_contents('php://stdin')); | ||
$statement->setFetchMode(PDO::FETCH_ASSOC); | ||
$statement->execute(); | ||
} catch (\PDOException $e) { | ||
file_put_contents('php://stderr', var_export($request, true) . PHP_EOL); | ||
file_put_contents('php://stderr', var_export($e->errorInfo, true) . PHP_EOL); | ||
file_put_contents('php://stderr', $e); | ||
return -1; | ||
} catch (\Error $e) { | ||
file_put_contents('php://stderr', $e); | ||
return -1; | ||
} | ||
|
||
$file = new SplFileObject('php://stdout', 'w'); | ||
$file->setCsvControl(';'); | ||
|
||
$i = 0; | ||
foreach ($statement as $index => $row) { | ||
if ($index === 0) { | ||
$file->fputcsv(array_keys($row)); | ||
} | ||
|
||
$file->fputcsv($row); | ||
(++$i % 100) || ob_flush(); | ||
} |
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,14 @@ | ||
{ | ||
"name": "kiboko/akeneo-initialize-from-magento", | ||
"type": "project", | ||
"require": { | ||
"php": "^7.2", | ||
"twig/twig": "^2.10" | ||
}, | ||
"minimum-stability": "stable", | ||
"autoload": { | ||
"psr-4": { | ||
"Kiboko\\Bridge\\Akeneo\\Magento\\": "src/" | ||
} | ||
} | ||
} |
Oops, something went wrong.