main.php 7.3 KB
<?php
    use artbox\catalog\helpers\FilterHelper;
    use artbox\core\components\AliasCache;
    use artbox\core\components\SeoComponent;
    use artbox\odoo\components\OdooMapper;
    
    return [
        'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
        'modules'    => [
            'imagemanager'   => [
                'class'                => 'noam148\imagemanager\Module',
                'canUploadImage'       => true,
                'canRemoveImage'       => function () {
                    return true;
                },
                'setBlameableBehavior' => false,
                'cssFiles'             => [
                    'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css',
                ],
            ],
            'artbox-comment' => [
                'class'             => 'artbox\webcomment\Module',
                'enablePremoderate' => false,
            ],
        ],
        'components' => [
            'cache'        => [
                'class' => 'yii\caching\FileCache',
            ],
            'i18n'         => [
                'translations' => [
                    'core'           => [
                        'class'    => 'yii\i18n\PhpMessageSource',
                        'basePath' => '@artbox/core/messages',
                    ],
                    'catalog'        => [
                        'class'    => 'yii\i18n\PhpMessageSource',
                        'basePath' => '@artbox/catalog/messages',
                    ],
                    'app'            => [
                        'class'    => 'yii\i18n\PhpMessageSource',
                        'basePath' => '@common/messages',
                    ],
                    'blog'           => [
                        'class'    => 'yii\i18n\PhpMessageSource',
                        'basePath' => '@artbox/weblog/messages',
                    ],
                    'order'          => [
                        'class'    => 'yii\i18n\PhpMessageSource',
                        'basePath' => '@artbox/order/messages',
                    ],
                    'artbox-comment' => [
                        'class'    => 'yii\i18n\PhpMessageSource',
                        'basePath' => '@artbox/webcomment/messages',
                    ],
                    'eauth'          => [
                        'class'    => 'yii\i18n\PhpMessageSource',
                        'basePath' => '@eauth/messages',
                    ],
                    'odoo'           => [
                        'class'    => 'yii\i18n\PhpMessageSource',
                        'basePath' => '@artbox/odoo/messages',
                    ],
                ],
            ],
            'filedb'       => [
                'class' => 'yii2tech\filedb\Connection',
                'path'  => '@common/config',
            ],
            'sitemapdb'    => [
                'class'          => 'yii2tech\filedb\Connection',
                'path'           => '@common/config',
                'primaryKeyName' => 'id',
            ],
            'seo'          => [
                'class' => SeoComponent::className(),
            ],
            'filter'       => [
                'class' => FilterHelper::className(),
            ],
            'imagemanager' => [
                'class'       => 'noam148\imagemanager\components\ImageManagerGetPath',
                'mediaPath'   => dirname(dirname(__DIR__)) . '/storage',
                'cachePath'   => '../../storage/cache',
                'useFilename' => true,
                'absoluteUrl' => false,
            ],
            'aliasCache'   => [
                'class' => AliasCache::className(),
            ],
            'odooMapper'   => [
                'class' => OdooMapper::className(),
                'map'   => [
                    'id'              => 'remote_id',
                    'active'          => 'status',
                    'create_date'     => [
                        'attribute' => 'created_at',
                        'artbox'    => function ($field) {
                            return strtotime($field);
                        },
                        'odoo'      => function ($field) {
                            return date('Y-m-d H:i:s', $field);
                        },
                    ],
                    '__last_update'   => [
                        'attribute' => 'updated_at',
                        'artbox'    => function ($field) {
                            return strtotime($field);
                        },
                        'odoo'      => function ($field) {
                            return date('Y-m-d H:i:s', $field);
                        },
                    ],
                    'name'            => 'title',
                    'default_code'    => 'sku',
                    'list_price'      => 'price',
                    'product_id'      => [
                        'attribute' => 'variant_id',
                        'artbox'    => function ($field) {
                            return $field[ 0 ];
                        },
                        'odoo'      => function ($field) {
                            return [ $field ];
                        },
                    ],
                    'price_unit'      => 'price',
                    'product_uom_qty' => 'count',
                    'categ_id'        => 'category',
                    'contact_address' => [
                        'attribute' => 'address',
                        'artbox'    => function ($field) {
                            return strval($field);
                        },
                        'odoo'      => function ($field) {
                            return boolval($field);
                        },
                    ],
                    'phone'           => [
                        'attribute' => 'phone',
                        'artbox'    => function ($field) {
                            return strval($field);
                        },
                        'odoo'      => function ($field) {
                            return boolval($field);
                        },
                    ],
                    'email'           => [
                        'attribute' => 'email',
                        'artbox'    => function ($field) {
                            return strval($field);
                        },
                        'odoo'      => function ($field) {
                            return boolval($field);
                        },
                    ],
                    'city'            => [
                        'attribute' => 'city',
                        'artbox'    => function ($field) {
                            return strval($field);
                        },
                        'odoo'      => function ($field) {
                            return boolval($field);
                        },
                    ],
                    'comment'         => [
                        'attribute' => 'comment',
                        'artbox'    => function ($field) {
                            return strval($field);
                        },
                        'odoo'      => function ($field) {
                            return boolval($field);
                        },
                    ],
                ],
            ],
        ],
    ];