Skip to content

Commit

Permalink
Build package 1.0.0-pl
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzwood committed Jan 3, 2021
1 parent 3890ffb commit e1ea5a4
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 273 deletions.
Empty file modified .gitignore
100755 → 100644
Empty file.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ Developed by Murray Wood at Digital Penguin in Hong Kong.

Introduction
-
Commerce for MODX defines products separately from any context or resource. This is a very good thing as it allows for faster speeds and more flexibility. It's also not opinionated, so you can build up your shop in any manner.
Having such flexibility however, does create difficulty in managing multiple language translations for each product. One option would be to use the lexicons, but that paves the way for a convoluted workflow when updating/creating products.

This is solved by Commerce_MultiLang.

Commerce_MultiLang brings multilingual products to Commerce on MODX. Multilingual Products are a custom product type, and can be selected when creating or updating a product.
They behave the same way as a regular product only they also carry easily editable translations.

![commerce_multilang](https://user-images.githubusercontent.com/5160368/103473202-f2625900-4dd0-11eb-852c-b8770cb44609.gif)

Requirements
-
Expand All @@ -34,6 +42,14 @@ System Settings
---------------
- A system setting called commerce_multilang.default_lang needs to be set with your default language code. (e.g. en, zh, fr etc.) This setting must be the cultureKey that is set on one of your contexts.

How it Works
==

Commerce_MultiLang will scan your contexts and include any context that has `cultureKey` context setting.
When creating a new product, you will see the option to create a `Multilingual Product`. In the edit window of a multilingual product, there is an extra tab which allows for the product name and product description to be entered in each language besides the default. The default language is entered the same as any standard product.
When the multilingual product is viewed on the customer-facing side of the webshop, the appropriate language will be displayed according to the active context.


Roadmap
==
- Allow for multilingual images to be used within each product. This way if text is included in the image, you can have a different one for each context.
Expand Down
96 changes: 1 addition & 95 deletions _build/build.transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function getSnippetContent($filename) {
define('PKG_NAME', 'Commerce_MultiLang');
define('PKG_NAMESPACE', 'commerce_multilang');
define('PKG_VERSION', '1.0.0');
define('PKG_RELEASE', 'Alpha1');
define('PKG_RELEASE', 'pl');

/* load modx */
require_once dirname(dirname(__FILE__)) . '/config.core.php';
Expand Down Expand Up @@ -67,24 +67,6 @@ function getSnippetContent($filename) {

$modx->log(modX::LOG_LEVEL_INFO,'Packaged in namespace.'); flush();


/**
* MENU & ACTION
*/
$menu = include $sources['data'].'transport.menu.php';
if (empty($menu)) {
$modx->log(modX::LOG_LEVEL_ERROR, 'Could not package in menu.');
} else {
$menuVehicle = $builder->createVehicle($menu, array(
xPDOTransport::PRESERVE_KEYS => true,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'text'
));
$builder->putVehicle($menuVehicle);
$modx->log(modX::LOG_LEVEL_INFO, 'Packaged in Menu');
unset($menuVehicle, $menu);
}

/**
* SYSTEM SETTINGS
*/
Expand Down Expand Up @@ -112,93 +94,17 @@ function getSnippetContent($filename) {
$modx->log(modX::LOG_LEVEL_INFO, 'Packaged in category.');
flush();

/**
* PLUGINS
*/
$plugins = include $sources['data'].'transport.plugins.php';
if (!is_array($plugins)) {
$modx->log(modX::LOG_LEVEL_FATAL, 'Adding plugins failed.');
} else {
$category->addMany($plugins);
$attributes = array(
xPDOTransport::UNIQUE_KEY => 'name',
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::RELATED_OBJECTS => true,
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array(
'PluginEvents' => array(
xPDOTransport::PRESERVE_KEYS => true,
xPDOTransport::UPDATE_OBJECT => false,
xPDOTransport::UNIQUE_KEY => array('pluginid', 'event'),
),
),
);
foreach ($plugins as $plugin) {
$vehicle = $builder->createVehicle($plugin, $attributes);
$builder->putVehicle($vehicle);
}
$modx->log(modX::LOG_LEVEL_INFO, 'Packaged in '.count($plugins).' plugins.');
flush();
}
unset($plugins, $plugin, $attributes);

/**
* SNIPPETS
*/
$snippets = include $sources['data'].'transport.snippets.php';
if (!is_array($snippets)) {
$modx->log(modX::LOG_LEVEL_ERROR, 'Could not package in snippets.');
} else {
$category->addMany($snippets);
$modx->log(modX::LOG_LEVEL_INFO, 'Packaged in '.count($snippets).' snippets.');
}

/**
* CHUNKS
*/
$chunks = include $sources['data'].'transport.chunks.php';
if (!is_array($chunks)) {
$modx->log(modX::LOG_LEVEL_ERROR, 'Could not package in chunks.');
} else {
$category->addMany($chunks);
$modx->log(modX::LOG_LEVEL_INFO, 'Packaged in '.count($snippets).' chunks.');
}

/* create category vehicle */
$attr = array(
xPDOTransport::UNIQUE_KEY => 'category',
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::RELATED_OBJECTS => true,
xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array(
'Chunks' => array(
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'name',
),
'Snippets' => array(
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'name',
),
'Plugins' => array(
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'name',
),
),
);
$vehicle = $builder->createVehicle($category, $attr);

// Add the validator to check server requirements
$vehicle->validate('php', array('source' => $sources['validators'] . 'requirements.script.php'));
/**
* ASSET FILES
*/
$vehicle->resolve('file',array(
'source' => $sources['source_assets'],
'target' => "return MODX_ASSETS_PATH . 'components/';",
));

/**
* CORE FILES
Expand Down
57 changes: 0 additions & 57 deletions _build/data/transport.chunks.php

This file was deleted.

15 changes: 0 additions & 15 deletions _build/data/transport.menu.php

This file was deleted.

64 changes: 0 additions & 64 deletions _build/data/transport.plugins.php

This file was deleted.

2 changes: 0 additions & 2 deletions _build/data/transport.properties.php

This file was deleted.

37 changes: 0 additions & 37 deletions _build/data/transport.snippets.php

This file was deleted.

Binary file not shown.
Empty file modified core/components/commerce_multilang/docs/license.txt
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ class Commerce_MultiLang {
public $namespace = 'commerce_multilang';
public $cache = null;
public $options = array();
public $sortby = 'CMLProduct.id';
public $sortdir = 'ASC';
public $limit = '30';


public function __construct(modX &$modx, array $options = array()) {
Expand Down
3 changes: 3 additions & 0 deletions core/components/commerce_multilang/src/Modules/MultiLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public function getDescription() {
}

public function initialize(EventDispatcher $dispatcher) {
// Load our lexicon
$this->adapter->loadLexicon('commerce_multilang:default');

// Add template path to twig
//$root = dirname(__DIR__, 2);
//$this->commerce->view()->addTemplatesPath($root . '/templates/');
Expand Down

0 comments on commit e1ea5a4

Please sign in to comment.