# PrestaShop + Docker

**URL:** https://forum.ficusonline.com/t/topic/380
**Category:** WEB Design
**Created:** [2020 年 7 月 14 日午前 9:37 UTC](https://forum.ficusonline.com/t/topic/380 "2020-07-14T09:37:52Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2020 年 7 月 14 日午前 9:37 UTC](https://forum.ficusonline.com/t/topic/380/1 "2020-07-14T09:37:52Z")

</div>

**GitHub Docker Prestashop**

> **[GitHub - PrestaShop/docker: 🐳](https://github.com/PrestaShop/docker)**
>
> 🐳

**DockerHub Prestashop**

> **[prestashop/prestashop - Docker Image](https://hub.docker.com/r/prestashop/prestashop/)**

Docker-Composeファイルによるコンテナ作成時の環境設定は以下の通り。

```auto
  prestashop-fpm:
    container_name: prestashop-fpm
    image: prestashop/prestashop:1.7-7.2-fpm    
    tty: true
    expose: 
      - "9000"
    environment:
      - PS_DEV_MODE=true
      - DB_SERVER=localhost
      - DB_USER=user
      - DB_PASSWD=passowrd
      - DB_NAME=store
      - PS_INSTALL_AUTO=1
      - PS_DOMAIN=www.testsite.com
      - PS_LANGUAGE=ja
      - PS_COUNTRY=JP
      - PS_FOLDER_ADMIN=your_admin
      - PS_ENABLE_SSL=1
      - ADMIN_MAIL=test001@gmail.com
      - ADMIN_PASSWD=adminpassword
      - TZ=Asia/Tokyo

```

⚠

**注1） PrestaShop** を指定ドメインのサブディレクトにインストールする場合は、PrestaShopデータベースのテーブル **“ps\_shop\_url”** の **“physical\_uri”** に **“/sub\_directory/”** を追加すること。 これをしないと **`Nginx 502 error`** が発生します。

**注2）Installディレクトリ** は自動削除されるため、途中手動で削除しないこと。

### ストア設定

**`Shop Parameters ---> Contact ---> Stores`** でストアの名称、場所、メールなどの設定・追加・変更が出来ます。

 ![prestashop_store](https://forum.ficusonline.com/uploads/default/original/2X/1/1629543247c8bda23baba341248bb7f284ef3528.png)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2020 年 7 月 16 日午前 8:59 UTC](https://forum.ficusonline.com/t/topic/380/2 "2020-07-16T08:59:17Z")

</div>

### pecl memcacheのインストール

Prestashopのキャッシュを有効化するため、php7.2-fpmコンテナにPECLによりPHP拡張機能memcacheを追加。

**PECL**

> **[PECL :: The PHP Extension Community Library](https://pecl.php.net/)**

php7.2-fpmコンテナ内で以下のpeclコマンドによりインストール

```auto
# pecl install memcache

```

peclコマンド一覧

```auto
# pecl
Commands:
build Build an Extension From C Source
bundle Unpacks a Pecl Package
channel-add Add a Channel
channel-alias Specify an alias to a channel name
channel-delete Remove a Channel From the List
channel-discover Initialize a Channel from its server
channel-info Retrieve Information on a Channel
channel-login Connects and authenticates to remote channel server
channel-logout Logs out from the remote channel server
channel-update Update an Existing Channel
clear-cache Clear Web Services Cache
config-create Create a Default configuration file
config-get Show One Setting
config-help Show Information About Setting
config-set Change Setting
config-show Show All Settings
convert Convert a package.xml 1.0 to package.xml 2.0 format
cvsdiff Run a "cvs diff" for all files in a package
cvstag Set CVS Release Tag
download Download Package
download-all Downloads each available package from the default channel
info Display information about a package
install Install Package
list List Installed Packages In The Default Channel
list-all List All Packages
list-channels List Available Channels
list-files List Files In Installed Package
list-upgrades List Available Upgrades
login Connects and authenticates to remote server [Deprecated in favor of channel-login]
logout Logs out from the remote server [Deprecated in favor of channel-logout]
makerpm Builds an RPM spec file from a PEAR package
package Build Package
package-dependencies Show package dependencies
package-validate Validate Package Consistency
pickle Build PECL Package
remote-info Information About Remote Packages
remote-list List Remote Packages
run-scripts Run Post-Install Scripts bundled with a package
run-tests Run Regression Tests
search Search remote package database
shell-test Shell Script Test
sign Sign a package distribution file
svntag Set SVN Release Tag
uninstall Un-install Package
update-channels Update the Channel List
upgrade Upgrade Package
upgrade-all Upgrade All Packages [Deprecated in favor of calling upgrade with no parameters]
Usage: pecl [options] command [command-options] <parameters>
Type "pecl help options" to list all options.
Type "pecl help shortcuts" to list all command shortcuts.
Type "pecl help version" or "pecl version" to list version information.
Type "pecl help <command>" to get the help for the specified command.

```

**キャッシュの有効化**

 ![prestashop_memcache](https://forum.ficusonline.com/uploads/default/original/1X/14c49f8236936e8c516a6ab6e20ecf420162a429.png)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2020 年 7 月 17 日午前 7:37 UTC](https://forum.ficusonline.com/t/topic/380/3 "2020-07-17T07:37:05Z")

</div>

### MBOモジュール 503 エラー

> <https://github.com/PrestaShopCorp/ps_mbo/pull/89>
>
> \### Changes
> \- Migrate to Symfony stuffs
> \- Use Module Catalog of the Core due t…o new API delayed
> \- Handle Module Selection & Theme Catalog on MBO
> \- \*\*Asynchronous requests\*\*
> \- \*\*Retrieve Recommended Modules with CircuitBreaker\*\*
> \- \*\*Use cache to store Recommended Modules after building\*\*
> \- Display Recommended Modules after page content in AdminCarriers & AdminPayment
> \- Display Recommended Modules on a popup in the others pages after click on Recommended Modules button in toolbar
> \- If no Recommended Modules is available, button should not be displayed. (Only if cache is set)
> 
> \### Warning
> \*\*This module is available start PrestaShop 1.7.5.0 with PHP 5.6 minimum.\*\*
> 
> Some modules are defined on https://api.prestashop.com/xml/tab\_modules\_list\_17.xml but not available in BO due to unavailable module data in current API, data retrieved from Core.
> Same as previously.
> 
> \--------------------------------------------
> \### How to test ?
> 
> \#### Migrated pages
> \* \`Modules \> Module Catalog\` is now handled by MBO, url should be \`/ps-admin/index.php/modules/addons/modules/catalog\` (MBO v2.0.0)
> instead of \`/ps-admin/index.php?controller=AdminPsMboModule\` (MBO v1.1.1)
> and instead of \`/ps-admin/index.php/improve/modules/catalog\` (Core)
> \* \`Modules \> Module Catalog \> Module Selection\` is now handled by MBO, url should be \`/ps-admin/index.php/modules/addons/modules/catalog/selection\` (MBO v2.0.0)
> instead of \`/ps-admin/index.php/improve/modules/addons-store\` (Core version)
> \* \`Design \> Theme Catalog\` is now handled by MBO, url should be \`/ps-admin/index.php/modules/addons/themes/catalog\` (MBO v2.0.0)
> instead of \`/ps-admin/index.php?controller=AdminPsMboTheme\` (MBO v1.1.1)
> and instead of \`/ps-admin/index.php/improve/design/themes-catalog/\` (Core)
> 
> \#### This pages should have a recommended button and a modal should be displayed on click with recommended modules list : 
> \- Orders \> Orders
> \- Orders \> Invoices
> \- Orders \> Credit Slips
> \- Orders \> Delivery Slips
> \- Orders \> Shopping Carts
> \- Catalog \> Products
> \- Catalog \> Attributes & Features \> Features
> \- Catalog \> Brands & Suppliers \> Brands
> \- Catalog \> Discounts \> Cart Rules
> \- Catalog \> Discounts \> Catalog Price Rules
> \- Customers \> Customers
> \- Customer Service \> Customer Service
> \- Customer Service \> Order Messages
> \- Stats \> Stats
> \- Design \> Pages
> \- Design \> Image Settings
> \- Shipping \> Preferences
> \- International \> Locations \> Zones
> \- Shop Parameters \> General
> \- Shop Parameters \> Order Settings \> Statuses
> \- Shop Parameters \> Product Settings
> \- Shop Parameters \> Customer Settings \> Customers
> \- Shop Parameters \> Customer Settings \> Groups
> \- Shop Parameters \> Contact \> Contacts
> \- Shop Parameters \> Traffic & SEO \> SEO & URLs
> \- Shop Parameters \> Traffic & SEO \> Search Engines
> \- Shop Parameters \> Traffic & SEO \> Referrers
> \- Shop Parameters \> Search \> Search
> \- Advanced Parameters \> Performance
> \- Advanced Parameters \> Administration
> \- Advanced Parameters \> E-mail
> 
> \#### This pages should display Recommended Modules and Services after content :
> \- Shipping \> Carriers
> \- Payment \> Payment Methods
> 
> \#### Without network connection
> 
> Please note MBO cache is build on click on a recommended button or on display page with recommended modules after content or on display page with external content from Addons (Module Selection and Theme Catalog).
> 
> \_If you clear Cache on Advanced Parameters \> Performance without network connection with PrestaShop 1.7.6, you should have an error but not related to MBO.\_
> 
> \_I recommend to clear cache on Advanced Parameters \> Performance with network connection then after cache clear confirmation you can disable network connection.\_
> 
> If MBO cache is not set and no network connection available :
> 
> \- Migrated pages except Module Catalog page should display : \`It looks like we have trouble connecting to Addons. Please refresh the page or check your firewall configuration.\`
> \- Pages with a recommended button should display in modal : \`Service Unavailable - It looks like we have trouble connecting to Addons. Please refresh the page or check your firewall configuration.\`
> \- Pages with recommended modules displayed after content should display in modal : \`Service Unavailable - It looks like we have trouble connecting to Addons. Please refresh the page or check your firewall configuration.\`
> 
> 
> \---
> This change is \[\<img src="https://reviewable.io/review\_button.svg" height="34" align="absmiddle" alt="Reviewable"/\>\](https://reviewable.io/reviews/prestashopcorp/ps\_mbo/89)

モジュールセレクション：modules/addons/modules/catalog/selection、  
テーマ一覧：modules/addons/themes/catalog  
"Recommended Modules and Services"ボタンなどでの表示エラー

 ![MBO_Error](https://forum.ficusonline.com/uploads/default/original/1X/b72ecb300c243b80678432614784af14fe1b73e8.png)

**\<原因1：doctrineマッピングエラー\>**

### Entities Mapping

| Class | Mapping errors |
| --- | --- |
| PrestaShopBundle\Entity\Tab | \* The association PrestaShopBundle\Entity\Tab#tabLangs refers to the owning side field PrestaShopBundle\Entity\TabLang#tab which does not exist. |

**\<対策：以下ファイルの該当箇所を修正\>**

```auto
# nano src/PrestaShopBundle/Entity/TabLang.php

```

**private $id —\> private $tab** へ修正

```php
class TabLang
{
    /**
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="PrestaShopBundle\Entity\Tab", inversedBy="tabLangs")
     * @ORM\JoinColumn(name="id_tab", referencedColumnName="id_tab", nullable=false)
     */
    private $tab;
.......
.......

```

### ＜2021/06/11 更新＞エラー対応

[https://www.prestashop.com/forums/topic/1028687-have-trouble-connecting-to-addons/](https://www.prestashop.com/forums/topic/1028687-have-trouble-connecting-to-addons/)

[https://www.prestashop.com/forums/topic/1030080-theme-catalog-error/?tab=comments#comment-3259123](https://www.prestashop.com/forums/topic/1030080-theme-catalog-error/?tab=comments#comment-3259123)

`/modules/ps_mbo/src/ExternalContentProvider/ExternalContentProvider.php`  
**0.6 —\> 20** へ変更。

```auto
class ExternalContentProvider implements ExternalContentProviderInterface
{
    .....

    const TIMEOUT_SECONDS = 20;

    .....

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2020 年 7 月 17 日午後 1:57 UTC](https://forum.ficusonline.com/t/topic/380/4 "2020-07-17T13:57:50Z")

</div>

**Symfonyデバックモードによる以下メッセージの非表示対応**

> Enabling the “sensio\_framework\_extra.router.annotations” configuration is deprecated since version 5.2. Set it to false and use the “Symfony\Component\Routing\Annotation\Route” annotation from Symfony itself

> <https://stackoverflow.com/questions/55029325/how-to-use-symfony-component-routing-annotation-route>

コンテナ内で設定ファイル **config.yml** に無効化するセクションを追加

```bash
# nano app/config/config.yml

```

```auto
sensio_framework_extra:
    router:
         annotations: false

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 1 月 5 日午前 6:25 UTC](https://forum.ficusonline.com/t/topic/380/5 "2021-01-05T06:25:19Z")

</div>

### Webhooks vs APIs(application programming interfaces) — What’s The Difference?

**Stripe** （支払いサービス）を例に、 **API** と **Webhook** の違いを説明

> **[Webhook.net](https://webhook.net)**
>
> Webhooks: The Definitive Guide (2022)

データプル型のAPIに対し、Webhookはデータプッシュ型

 ![apis-vs-webhooks](https://forum.ficusonline.com/uploads/default/original/1X/054b400d9f95646bb593a5fcb1c39bc57af5a035.png)

多くのイベント発生時や、より詳細なデータを取得する場合などにはAPIが有利。

 ![api-poll-vs-webhook-push](https://forum.ficusonline.com/uploads/default/original/1X/24379e52a68ebc30afd245cc4d497019aa15c67f.png)

**Stripe**

> **[Stripe | 収益向上のための金融インフラ](https://stripe.com/jp)**
>
> Stripe は、あらゆる規模や業種のビジネスにおける決済の受け入れ、柔軟な請求モデルの構築、および資金移動の管理を支援する、金融サービスプラットフォームです。

**Prestashop Stripe モジュール**  
[https://addons.prestashop.com/en/payment-card-wallet/24922-stripe-official-sca-ready.html](https://addons.prestashop.com/en/payment-card-wallet/24922-stripe-official-sca-ready.html)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 12 月 14 日午前 5:56 UTC](https://forum.ficusonline.com/t/topic/380/6 "2021-12-14T05:56:30Z")

</div>

## コマンドによるキャッシュクリア

コンテナ内で以下フォルダ削除

```auto
$ docker exec -ti prestashop-fpm bash
# rm -r var/cache/prod

```

または、 **`bin/console`** コマンドによりキャッシュクリア`(--env=prod or --env=dev)`

```auto
# bin/console cache:clear --env=prod

```

**`bin/console` コマンド一覧**

```auto
# bin/console list
Symfony 3.4.49 (kernel: app, env: dev, debug: true)

Usage:
  command [options] [arguments]

Options:
  -h, --help Display this help message
  -q, --quiet Do not output any message
  -V, --version Display this application version
      --ansi Force ANSI output
      --no-ansi Disable ANSI output
  -n, --no-interaction Do not ask any interactive question
  -e, --env=ENV The Environment name. [default: "dev"]
      --no-debug Switches off debug mode.
  -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  about Displays information about the current project
  help Displays help for a command
  list Lists commands
 assets
  assets:install Installs bundles web assets under a public directory
 cache
  cache:clear Clears the cache
  cache:pool:clear Clears cache pools
  cache:pool:prune Prunes cache pools
  cache:warmup Warms up an empty cache
 config
  config:dump-reference Dumps the default configuration for an extension
 debug
  debug:autowiring Lists classes/interfaces you can use for autowiring
  debug:config Dumps the current configuration for an extension
  debug:container Displays current services for an application
  debug:event-dispatcher Displays configured listeners for an application
  debug:form Displays form type information
  debug:router Displays current routes for an application
  debug:swiftmailer Displays current mailers for an application
  debug:tactician                                     
  debug:translation Displays translation messages information
  debug:twig Shows a list of twig functions, filters, globals and tests
 doctrine
  doctrine:cache:clear-collection-region Clear a second-level cache collection region
  doctrine:cache:clear-entity-region Clear a second-level cache entity region
  doctrine:cache:clear-metadata Clears all metadata cache for an entity manager
  doctrine:cache:clear-query Clears all query cache for an entity manager
  doctrine:cache:clear-query-region Clear a second-level cache query region
  doctrine:cache:clear-result Clears result cache for an entity manager
  doctrine:cache:contains Check if a cache entry exists
  doctrine:cache:delete Delete a cache entry
  doctrine:cache:flush [doctrine:cache:clear] Flush a given cache
  doctrine:cache:stats Get stats on a given cache provider
  doctrine:database:create Creates the configured database
  doctrine:database:drop Drops the configured database
  doctrine:database:import Import SQL file(s) directly to Database.
  doctrine:ensure-production-settings Verify that Doctrine is properly configured for a production environment
  doctrine:generate:entities [generate:doctrine:entities] Generates entity classes and method stubs from your mapping information
  doctrine:mapping:convert [orm:convert:mapping] Convert mapping information between supported formats
  doctrine:mapping:import Imports mapping information from an existing database
  doctrine:mapping:info                               
  doctrine:query:dql Executes arbitrary DQL directly from the command line
  doctrine:query:sql Executes arbitrary SQL directly from the command line.
  doctrine:schema:create Executes (or dumps) the SQL needed to generate the database schema
  doctrine:schema:drop Executes (or dumps) the SQL needed to drop the current database schema
  doctrine:schema:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata
  doctrine:schema:validate Validate the mapping files
 fos
  fos:js-routing:debug Displays currently exposed routes for an application
  fos:js-routing:dump Dumps exposed routes to the filesystem
 lint
  lint:twig Lints a template and outputs encountered errors
  lint:xliff Lints a XLIFF file and outputs encountered errors
  lint:yaml Lints a file and outputs encountered errors
 prestashop
  prestashop:licenses:update Rewrite your licenses to be up-to-date
  prestashop:linter:legacy-link Checks if _legacy_link is configured in BackOffice routes
  prestashop:linter:naming-convention Checks if Back Office routes and controllers follow naming convention.
  prestashop:linter:security-annotation Checks if Back Office route controllers has configured Security annotations.
  prestashop:list:commands-and-queries Lists available CQRS commands and queries
  prestashop:mail:generate Generate mail templates for a specified theme
  prestashop:module Manage your modules via command line
  prestashop:schema:update-without-foreign Update the database
  prestashop:taxes:update-eu-tax-rule-groups Update EU Tax rule groups
  prestashop:theme:enable Manage your themes via command line
  prestashop:theme:export Create zip to distribute theme with its dependencies
  prestashop:translation:find-duplicates Find duplicates of your translations
  prestashop:update:configuration-file-hooks-listing Appends configuration file hooks list
  prestashop:update:sql-upgrade-file-hooks-listing Adds sql to sql upgrade file which contains hook insert opeartion
 router
  router:match Helps debug routes by simulating a path info match
 security
  security:check Checks security issues in your project dependencies
  security:encode-password Encodes a password.
 server
  server:log Starts a log server that displays logs in real time
  server:run Runs a local web server
  server:start Starts a local web server in the background
  server:status Outputs the status of the local web server
  server:stop Stops the local web server that was started with the server:start command
 swiftmailer
  swiftmailer:email:send Send simple email message
  swiftmailer:spool:send Sends emails from the spool
 translation
  translation:update Updates the translation file

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 15 日午前 7:33 UTC](https://forum.ficusonline.com/t/topic/380/7 "2022-03-15T07:33:37Z")

</div>

### テンプレートのカスタマイズ

**テーマのテンプレートディレクトリ**  
`themes/classic/templates/_partials`

 ![prestashop__themes_templates](https://forum.ficusonline.com/uploads/default/original/2X/5/5ba1f2643889888d78bc02e6141ab13441dde010.png)

テンプレート編集後は管理画面から  
`Advanced Parameters ---> Performance` からキャッシュをクリアすることで変更内容が反映されます。

**ex) Footerの編集**

```auto
# nano themes/classic/templates/_partials/footer.tpl
<a href="https://www.prestashop.com" target="_blank" rel="noopener noreferrer nofollow">
              {l s='%copyright% %year% - Ecommerce software by %prestashop%' sprintf=['%prestashop%' => 'PrestaShop™', '%year%' => 'Y'|date, '%copyright%' => '©'] d='Shop.Theme.Global'}
            </a>

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 22 日午前 9:12 UTC](https://forum.ficusonline.com/t/topic/380/8 "2022-03-22T09:12:56Z")

</div>

### 通貨レートアップデート

[https://www.prestashop.com/forums/topic/1012820-solved-create-a-cronjob-to-auto-update-exchange-rate/](https://www.prestashop.com/forums/topic/1012820-solved-create-a-cronjob-to-auto-update-exchange-rate/)

モジュールによる通貨レートのアップデートではなく、ホストマシンのクローンジョブで対応。以下のコマンドをクローンジョブに追加。

```auto
# php /var/www/html/admin/cron_currency_rates.php secure_key=displayed_the_correct_secure_key

```

**`$secureKey`** は以下ファイルの一部を変更(echoによる確認）し抽出。抽出後削除すること。

**`/var/www/html/admin/cron_currency_rates.php`**

```auto
if (isset($_GET['secure_key'])) {
    $secureKey = md5(_COOKIE_KEY_.Configuration::get('PS_SHOP_NAME'));
    echo $secureKey;
    if (!empty($secureKey) && $secureKey === $_GET['secure_key']) {
        $shop_ids = Shop::getCompleteListOfShopsID();
        foreach ($shop_ids as $shop_id) {
            Shop::setContext(Shop::CONTEXT_SHOP, (int)$shop_id);
            Currency::refreshCurrencies();
        }
    }
}

```

secure\_key=xxxxx を適当に指定すると正しい$securekeyが表示されます。

```auto
# php /var/www/html/admin/cron_currency_rates.php secure_key=xxxxx
asd4567890jj

```

これをクローンジョブのsecure\_keyに指定します。

```auto
#Prestashop currency update schedule
* 2 * * * docker exec -u www-data prestashop-container php /var/www/html/admin/cron_currency_rates.php secure_key=asd4567890jj

```

> **[Pricing FAQ](https://devdocs.prestashop-project.org/1.7/faq/pricing/)**
>
> Learn how to extend, modify and test PrestaShop, create modules, themes, and more.

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 22 日午前 11:17 UTC](https://forum.ficusonline.com/t/topic/380/9 "2022-03-22T11:17:07Z")

</div>

### ロケーションデータの挿入

ロケーションデータ **GeoLite2 City** を下記サイトからダウンロード  
[https://www.maxmind.com/en/accounts/353548/geoip/downloads](https://www.maxmind.com/en/accounts/353548/geoip/downloads)

展開したファイル **`GeoLite2-City.mmdb`** を **`app/Resources/geoip`** へコピーして  
**“Geolocation by IP address”** を有効にします。

 ![geoip](https://forum.ficusonline.com/uploads/default/original/2X/2/21f4dab2256b38e2d29ebc84217d3ccffed8c1dd.png)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 26 日午前 5:52 UTC](https://forum.ficusonline.com/t/topic/380/10 "2022-03-26T05:52:39Z")

</div>

### Gmail SMTPサーバの設定

テストメール送信時のバグ。Chromeの自動入力によるアカウントのパスワードでSMTPサーバにアクセスしているため。Chromeの自動入力設定を削除するか、自動入力されないアカウントで設定することにより回避。

> <https://github.com/PrestaShop/PrestaShop/issues/28014>
>
> \### Prerequisites
> 
> \- \[X\] I understand and accept the project's \[code of conduc…t\](https://github.com/PrestaShop/PrestaShop/blob/develop/CODE\_OF\_CONDUCT.md)
> \- \[X\] I have already \[searched in existing issues\](https://github.com/PrestaShop/PrestaShop/issues?q=is%3Aissue+label%3ABug) and found no previous report of this bug.
> 
> \### Describe the bug and add screenshots
> 
> Try to enable Google 2FA and generate an "App Password" for autenticate SMT email send with not secure app, insert the password created in prestashop SMTP field, this result in error sending email.
> 
> \### Expected behavior
> 
> PS must send email with SMTP app password setup and google 2fa enabled.
> 
> \### Steps to reproduce
> 
> 1. Go to you gmail account
> 2. Disable imap
> 3. Open account management
> 4. Enable 2FA
> 5. Create a new app password
> 6. Copy password secret
> 7. Update prestashop SMTP password field with the new one created (instead the account password)
> 8. Try to send email
> 
> \### PrestaShop version(s) where the bug happened
> 
> 1.7.6.9
> 
> \### PHP version(s) where the bug happened
> 
> 7.2
> 
> \### If your bug is related to a module, specify its name and its version
> 
> \_No response\_

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 28 日午前 6:22 UTC](https://forum.ficusonline.com/t/topic/380/11 "2022-03-28T06:22:23Z")

</div>

### E-Mailテンプレートの編集

**ModernよりもClassicテーマの方がレイアウトが整然としていて見やすいです。**

> **[The Mail Template component](https://devdocs.prestashop-project.org/1.7/development/components/mail-templates/)**
>
> Learn how to extend, modify and test PrestaShop, create modules, themes, and more.

メールで使用される各テンプレートは、テーマ毎 `(Modern, Classic)` に **`mails/themes`** に纏められています。

**`mails/themes`** フォルダ内の各テーマの `twig` ファイルから、`html` または `txt` 形式のファイルが作成されます（この作成作業は、`管理画面のデザイン ---> Email Theme ---> Generate emails` から行うか、以下の`prestashop:mail:generate`でも可能です）。

### `prestashop:mail:generate`

> **[prestashop:mail:generate](https://devdocs.prestashop-project.org/1.7/development/components/console/prestashop-mail-generate/)**
>
> Generate email templates from layouts

```auto
# bin/console prestashop:mail:generate --help               
Usage:
  prestashop:mail:generate [options] [--] <theme> <locale> [<coreOutputFolder>] [<modulesOutputFolder>]

Arguments:
  theme Theme to use for mail templates.
  locale Which locale to use for the templates.
  coreOutputFolder Output folder to export core templates.
  modulesOutputFolder Output folder to export modules templates (by default same as core).

Options:
  -o, --overwrite[=OVERWRITE] Overwrite existing templates [default: false]
  -h, --help Display this help message
  -q, --quiet Do not output any message
  -V, --version Display this application version
      --ansi Force ANSI output
      --no-ansi Disable ANSI output
  -n, --no-interaction Do not ask any interactive question
  -e, --env=ENV The Environment name. [default: "dev"]
      --no-debug Switches off debug mode.
  -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

```

ロケールと上書きオプションを指定してジェネレートコマンドを実行

```auto
# bin/console prestashop:mail:generate -o true classic ja-JP
# bin/console prestashop:mail:generate -o true classic en-US

```

また、作成されたテーマごとのメール送信テストは、 `Email themes` から行うことが出来ます（選択したテーマでのみ送信テストが可能）。

* * *

作成されたテンプレートをさらに細かく編集したい場合には、以下翻訳メニューから行うことが出来ます。

`International ---> Translations ---> Modify Translations` から以下の項目を選択

 ![modify_email_template](https://forum.ficusonline.com/uploads/default/original/2X/4/49c3b81561fb316254dbf818ba59f99a7914fd75.png)

**`Core emails`** から編集するテンプレートを選択

 ![email_section_modify](https://forum.ficusonline.com/uploads/default/original/2X/4/41a5b06a7a9afda36cfc65a8b835ec7ee0a1e2de.png)

[https://www.prestashop.com/forums/topic/1061432-new-email-template-on-1784-error/](https://www.prestashop.com/forums/topic/1061432-new-email-template-on-1784-error/)

テンプレートの編集箇所が多い場合は、直接twigファイルを編集したほうが良いかもしれません。上記テンプレートの `{recycled_packaging_label} ` やフッター `prestashop` へのリンクを削除する場合は、メールコアの `order_conf` で該当する表の行を削除するか、

次のClassicテーマのtwigテンプレート

`mails/themes/classic/conponents/footer.html.twig`  
`mails/themes/classic/core/order_conf.html.twig`

から該当箇所を削除し、以下のメニュー画面に従って言語毎に再作成します（編集後、 **所有権の修正** を忘れずに）。

 ![generate_emails](https://forum.ficusonline.com/uploads/default/original/2X/b/b9212cb381d2af9b0a7b1fff99d7c8efe7c65257.png)

* * *

### Gmail SMTPサーバによる送信メール内のイメージについて

> <https://stackoverflow.com/questions/51471607/email-thumbnail-url-changed-to-googleusercontent-com-in-gmail>

* * *

### メール関連ファイル

コントローラ  
`src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/EmailController.php`

管理画面メール設定ファイル  
`src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/email.yml`

テンプレート設定ファイル  
`src/PrestaShopBundle/Resources/config/services/core/mail_template.yml`

```auto
  prestashop.core.mail_template.theme_folder_catalog:
    class: 'PrestaShop\PrestaShop\Core\MailTemplate\FolderThemeCatalog'
    arguments:
      - '%mail_themes_dir%'
      - '@prestashop.core.mail_template.theme_folder_scanner'
      - '@prestashop.core.hook.dispatcher'

  prestashop.core.mail_template.variables_builder:
    class: 'PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutVariablesBuilder'
    arguments:
      - '@prestashop.core.hook.dispatcher'
      - '@prestashop.core.language.language_default_fonts_catalog'
      - mailThemesUrl: "@=service('prestashop.adapter.legacy.context').getMailThemesUrl()"

```

上記 **`mailThemesUrl`** は、  
`src/Adapter/LegacyContext.php`

```auto
/**
     * Url to the mail themes folder
     *
     * @return string
     */
    public function getMailThemesUrl()
    {
        return $this->tools->getShopDomainSsl(true) . __PS_BASE_URI__. $this->mailThemesUri;
    }

```

管理画面メール設定テンプレートフォルダ  
`src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email`

Twig Configration  
`app/config/config.yml`

```auto
# Twig Configuration
twig:
    autoescape: "name"
    debug: "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form_themes:
        - 'PrestaShopBundle:Admin/TwigTemplateForm:bootstrap_4_horizontal_layout.html.twig'
    paths:
        '%admin_page%/Product': Product
        '%admin_page%/TwigTemplateForm': Twig
        '%admin_page%/Common': Common
        '%admin_page%/Configure/AdvancedParameters': AdvancedParameters
        '%admin_page%/Configure/ShopParameters': ShopParameters
        '%kernel.root_dir%/../modules': Modules
        '%mail_themes_dir%': MailThemes
    globals:
        webpack_server: false
        multistore_field_prefix: !php/const:PrestaShopBundle\Service\Form\MultistoreCheckboxEnabler::MULTISTORE_FIELD_PREFIX

```

* * *

送信メールテンプレート  
`mails/themes/modern/core/order_conf.html.twig`

```auto
<img src="{{ mailThemesUrl }}/modern/assets/baseline-local_shipping-24px.png" style="margin-{{ align_right }}:10px">

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 29 日午前 11:51 UTC](https://forum.ficusonline.com/t/topic/380/12 "2022-03-29T11:51:13Z")

</div>

### ストアURL、ドメイン変更

**ストアURLとSEO対策**

**`Shop Parameters ---> Traffic & SEO ---> SEO & URLs`**

 ![shop_parameters_seo-urls](https://forum.ficusonline.com/uploads/default/original/2X/b/b7c759a559480d3ec06f560edc56ea21684795dc.png)

‼ **注）ドメインを変更する場合** は上記URLとdocker-composeファイル（または.env）で指定したPS\_DOMAINを変更します。

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 29 日午前 11:55 UTC](https://forum.ficusonline.com/t/topic/380/13 "2022-03-29T11:55:40Z")

</div>

### Customer Reassurance Module

セキュリティ、デリバリー、リターンポリシーの設定

 ![reassurance](https://forum.ficusonline.com/uploads/default/original/2X/b/b0aab3c9e9846afef0a2bee325bfffe5bc51894f.png)

**`Modules ---> Module Manager ---> Theme Module ---> Customer Assurance`**

 ![customer_reassurance_module](https://forum.ficusonline.com/uploads/default/original/2X/7/7b5b2904401d6e454e661d243bde930c0e63c2d4.png)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 30 日午前 2:21 UTC](https://forum.ficusonline.com/t/topic/380/14 "2022-03-30T02:21:58Z")

</div>

### 登録ユーザ住所・配送先住所：国・都市選択メニュー

住所登録の際の国・都市のプルダウン選択メニューに表示させる項目の追加

左下 **“Bulk actions”** ボタンにより、一覧表から選択した **国(Countries)・都市(States)** を **有効** または **無効** にします。

**`International ---> Locations ---> "Countries" or "States"`**

**Countries**

 ![international_locations_countries](https://forum.ficusonline.com/uploads/default/original/2X/b/b9a13e257ee7e0e2812f8503380e30c58b1f3fc8.png)

**States**

 ![international_locations_states](https://forum.ficusonline.com/uploads/default/original/2X/f/fff97d2424038e2233957496d1b74171ad528c4f.png)

⚠  
**注）日本の都道府県がISOコード別に二重で登録されているため、片方を無効化。**

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 30 日午前 4:06 UTC](https://forum.ficusonline.com/t/topic/380/15 "2022-03-30T04:06:57Z")

</div>

### 日本語ローカライゼーション

**`Locarization ---> Languages ---> 日本語`**

**ISOコード** は **`jp`** ではなく **`ja`** にしないと日本語の翻訳データがダウンロード出来ません。

 ![localization_japanese](https://forum.ficusonline.com/uploads/default/original/2X/6/6fca107e7e26f2776d59ef008cd777d41e46311d.png)

**日本語の翻訳データのダウンロード**

**`Locarization ---> Languages ---> Import a localization pack ---> Japan`**  
で日本語翻訳データのインポート（税、単位、都市、通貨、言語をチェック）。

日本語翻訳文中の変数は **`%s`** で前後に半角スペースを挿入すること。

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 30 日午後 2:51 UTC](https://forum.ficusonline.com/t/topic/380/16 "2022-03-30T14:51:33Z")

</div>

# File Structure

> **[File structure](https://devdocs.prestashop-project.org/1.7/development/architecture/file-structure/)**
>
> Learn how to extend, modify and test PrestaShop, create modules, themes, and more.

### /app

This directory contains the configuration for the bundles and the framework.

It contains the following subdirectories:

- `/config`: configuration files for database, parameters, services, etc.
- `/logs`: execution logs
- `/Resources`: different resources for the software, most notably the `/translations` subdirectory which contains translation resources for all the installed languages.
- `/test`: reserved

This directory also includes the `AppKernel.php` file, which configures the Symfony application.

### /controllers

Contains controllers – as in Model-View-Controller (or MVC), the software architecture used by PrestaShop. Each file controls a specific part of PrestaShop.

Controllers are separated in two directories:

- `/admin`: contains legacy controllers for the Back Office
- `/front`: contains controllers for the Front Office

### /mails

Contains all HTML and text templates for e-mails sent by PrestaShop. Each language has its specific folder, where you can manually edit their content if you wish. PrestaShop contains a tool to edit your e-mails, located in the back office, in the Localization \> Translation page.

Since 1.7.6 this directory also contains [Mail themes](https://devdocs.prestashop.com/1.7/development/components/mail-templates/).

### /modules

Contains all of PrestaShop’s modules, each in its own folder.  
_If you wish to definitely remove a module, it is better to uninstall it from the back office._

### /src

Contains the new architecture files ( **Core** , **Adapter** and **PrestaShop Bundle** ). To learn more, see [Understanding the “src” folder](https://devdocs.prestashop.com/1.7/development/architecture/file-structure/understanding-src-folder/).

- **Core** : contains business logic classes
- **Adapter** : business logic classes that still depend on legacy framework (for instance: `Context`, `Dispatcher` or constants);
- **PrestaShopBundle** : classes that acts as a glue between PrestaShop classes and Symfony

* * *

# Symfony controllers & routing

> **[Symfony controllers & routing](https://devdocs.prestashop-project.org/1.7/development/architecture/modern/controller-routing/)**
>
> Learn how to extend, modify and test PrestaShop, create modules, themes, and more.

Read the Symfony documentation on [Controllers](https://symfony.com/doc/current/controller.html) and [Routing](https://symfony.com/doc/current/routing.html).

`src/PrestaShopBundle/Controller`

```auto
Controller/
└── Admin
    ├── Configure
    │ ├── AdvancedParameters
    │ └── ShopParameters
    ├── Improve
    │ ├── Design
    │ ├── International
    │ ├── Modules
    │ ├── Payment
    │ └── Shipping
    └── Sell
        ├── Catalog
        ├── Customers
        ├── CustomerService
        ├── Orders
        └── Stats

```

## Routing in PrestaShop

Routes are responsible for mapping a controller action to an url, you can read more about routing in [symfony docs](https://symfony.com/doc/current/routing.html).

PrestaShop uses YAML files for service declaration and routing (NOT ANNOTATIONS).

Routes are declared in

`src/PrestaShopBundle/Resources/config/admin`

folder, following the menu organization.

The routing is organized as follows:

```auto
.
├── admin
│ ├── _common.yml
│ ├── configure
│ │ ├── advanced_parameters
│ │ ├── _configure.yml
│ │ └── shop_parameters
│ ├── improve
│ │ ├── design
│ │ ├── _improve.yml
│ │ ├── international
│ │ ├── modules
│ │ ├── payment
│ │ └── shipping
│ ├── _security.yml
│ └── sell
│ ├── catalog
│ ├── orders
│ ├── _sell.yml
│ └── stocks.yml
├── admin.yml
├── api
│ ├── attributes.yml
│ ├── categories.yml
│ ├── features.yml
│ ├── i18n.yml
│ ├── improve
│ │ └── design
│ ├── manufacturers.yml
│ ├── stock_movements.yml
│ ├── stocks.yml
│ ├── suppliers.yml
│ └── translations.yml
└── api.yml

```

* * *

# URI, ディレクトリ

> <https://github.com/PrestaShop/PrestaShop/blob/develop/config/defines_uri.inc.php>

> **[Constants and variables for Prestashop 1.7 \[PHP, Smarty, Javascript, Twig\]](https://myrosblog.com/2018/04/constants-and-variables-for-prestashop/)**
>
> Ever wondered what constant to use in your controllers? Is it \_PS\_ROOT\_DIR\_ or \_\_PS\_BASE\_URI\_\_? In smarty templates, would you go for {$urls.img\_dir} or {$img\_dir}? Which constant to use? What variable are available? This article walks you through...

| Name | Language | Example | Type | Front, back? |
| --- | --- | --- | --- | --- |
| `_PS_ROOT_DIR_` | PHP | /var/www/html/prestashop | full path | front + back |
| root\_url | Twig | /prefix/ | | |
| ` __PS_BASE_URI__ ` | PHP | /prefix/ | relative url | |
| baseAdminDir | Javascript | /prefix/admin-dev/ | | back |
| baseDir | Javascript | /prefix/ | | back |
| basename(PS\_ADMIN\_DIR) | PHP | admin-dev | folder name | back |
| prestashop.urls | Javascript | base\_url:‘’, current\_url:‘’, shop\_domain\_url:‘’, img\_ps\_url:‘’, img\_cat\_url:’’, … | | front |
| {$base\_url} | Smarty | [https://myshop.com/prefix/](https://myshop.com/prefix/) | full url | back |
| {$base\_url} | Smarty | | | |
| {$baseAdminUrl} | Smarty | /prefix/admin-dev/ | relative url | back |
| {$img\_base\_path} | Smarty | /admin-dev/ | | back |
| {$urls.base\_url} | Smarty | [https://myshop.com/prefix/](https://myshop.com/prefix/) | full url | front |

* * *

### 管理画面コントローラ

国  
`controllers/admin/AdminCountriesController.php`

都市  
`controllers/admin/AdminStatesController.php`

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 31 日午前 5:21 UTC](https://forum.ficusonline.com/t/topic/380/17 "2022-03-31T05:21:03Z")

</div>

## PHP syntax check

> **[Basic checks](https://devdocs.prestashop-project.org/1.7/modules/testing/basic-checks/)**
>
> Learn how to extend, modify and test PrestaShop, create modules, themes, and more.

```auto
# php -l <file>
        Syntax check only (lint)

```

```auto
# find . -type f -name '*.php' ! -path "./vendor/*" ! -path "./tests/*" -exec php -l -n {} \; | (! grep -v "No syntax errors detected")

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 4 月 1 日午前 10:50 UTC](https://forum.ficusonline.com/t/topic/380/18 "2022-04-01T10:50:27Z")

</div>

## Fixed

`classes/State.php`  
`County ---> Country, Counties ---> Countries`

```auto
    /**
     * Has Countries.
     *
     * @param int $idState
     *
     * @return int
     */
    public static function hasCountries($idState)
    {
        return count(Country::getCountries((int) $idState));
    }

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 4 月 3 日午前 2:14 UTC](https://forum.ficusonline.com/t/topic/380/19 "2022-04-03T02:14:56Z")

</div>

### 多言語対応

データベース上のルール

> **[Database](https://devdocs.prestashop-project.org/1.7/development/database/)**
>
> Learn how to extend, modify and test PrestaShop, create modules, themes, and more.

- Tables which contain translations must end with the `_lang` suffix. For instance, `ps_product_lang` contains all the translations for the `ps_product` table.
- Use the `id_lang` field to store the language associated with a record.

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 4 月 4 日午後 2:22 UTC](https://forum.ficusonline.com/t/topic/380/20 "2022-04-04T14:22:03Z")

</div>

### SQLテーブルデータ一覧

> **[Database structure](https://devdocs.prestashop-project.org/1.7/development/database/structure/)**
>
> Learn how to extend, modify and test PrestaShop, create modules, themes, and more.

> **[Db class](https://devdocs.prestashop-project.org/1.7/development/components/database/db/)**
>
> Learn how to extend, modify and test PrestaShop, create modules, themes, and more.

テーブルの追加・編集は以下sqlデータを参照のこと（自動インストール後はinstallディレクトリは削除されます）。

[https://github.com/PrestaShop/PrestaShop/blob/1.7.8.x/install-dev/data/db\_structure.sql](https://github.com/PrestaShop/PrestaShop/blob/1.7.8.x/install-dev/data/db_structure.sql)

**テーブルコンテンツ**  
[https://github.com/PrestaShop/PrestaShop/tree/1.7.8.x/install-dev/data/xml](https://github.com/PrestaShop/PrestaShop/tree/1.7.8.x/install-dev/data/xml)

**`テーブル Country`**

```auto
/* Country specific data */
CREATE TABLE `PREFIX_country` (
  `id_country` int(10) unsigned NOT NULL auto_increment,
  `id_zone` int(10) unsigned NOT NULL,
  `id_currency` int(10) unsigned NOT NULL DEFAULT '0',
  `iso_code` varchar(3) NOT NULL,
  `call_prefix` int(10) NOT NULL DEFAULT '0',
  `active` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `contains_states` tinyint(1) NOT NULL DEFAULT '0',
  `need_identification_number` tinyint(1) NOT NULL DEFAULT '0',
  `need_zip_code` tinyint(1) NOT NULL DEFAULT '1',
  `zip_code_format` varchar(12) NOT NULL DEFAULT '',
  `display_tax_label` BOOLEAN NOT NULL,
  PRIMARY KEY (`id_country`),
  KEY `country_iso_code` (`iso_code`),
  KEY `country_` (`id_zone`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION;

/* Localized country information */
CREATE TABLE `PREFIX_country_lang` (
  `id_country` int(10) unsigned NOT NULL,
  `id_lang` int(10) unsigned NOT NULL,
  `name` varchar(64) NOT NULL,
  PRIMARY KEY (`id_country`, `id_lang`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION;

```

**`テーブル State`**

```auto
/* State localization info */
CREATE TABLE `PREFIX_state` (
  `id_state` int(10) unsigned NOT NULL auto_increment,
  `id_country` int(11) unsigned NOT NULL,
  `id_zone` int(11) unsigned NOT NULL,
  `name` varchar(64) NOT NULL,
  `iso_code` varchar(7) NOT NULL,
  `tax_behavior` smallint(1) NOT NULL DEFAULT '0',
  `active` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id_state`),
  KEY `id_country` (`id_country`),
  KEY `name` (`name`),
  KEY `id_zone` (`id_zone`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8mb4 COLLATION;

```

上記初期テーブル以外のテーブルは **Doctrine** により作成されます。

> **[Doctrine: PHP Open Source Project](https://www.doctrine-project.org/)**
>
> The Doctrine Project is an open-source PHP project that is home to home to several PHP libraries primarily focused on database storage and object mapping. The core projects are the Object Relational Mapper (ORM) and the Database Abstraction Layer...

**関連ディレクトリ**  
`src/PrestaShopBundle/Entity/`

[次のページ](https://forum.ficusonline.com/t/topic/380.md?page=2)
