承接 it-bens/shopware-bool-to-yes-no-updater 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

it-bens/shopware-bool-to-yes-no-updater

Composer 安装命令:

composer require it-bens/shopware-bool-to-yes-no-updater

包简介

Shopware package to update translations for boolean values to yes/no

README 文档

README

A lot of Shopware entities support translations. The translated fields are stored inside entity translation tables.

This package provides the ability to transform boolean entity fields into "translated booleans" like "Yes" and "No". These translated fields can come in handy if a boolean field should shown in a storefront.

Is this a Shopware Plugin?

No. While this package is tied to Shopware, it won't react on any events on it's own. It is meant to be used by a Shopware plugin.

How can add this package in a Shopware plugin?

First, the package has to be installed via composer:

composer require it-bens/shopware-bool-to-yes-no-updater

This can be done in the plugin's composer.json file. But don't forget to enable composer in the plugin class.

public function executeComposerCommands(): bool
{
    return true;
}

This package provides a Symfony compiler pass that will add all the services to the Shopware plugin service container. It can be added to the plugin's build method.

use ITB\ShopwareBoolToYesNoUpdater\DependencyInjection\BoolToYesNoCompilerPass;

public function build(ContainerBuilder $container): void
{
    // ...
    parent::build($container);

    $container->addCompilerPass(new BoolToYesNoCompilerPass());
}

How can I use this package?

The actual work is done by the BoolToYesNoUpdater service. It should be injected into the desired service via the BoolToYesNoUpdaterInterface. The update method will create an SQL update query that will writes the boolean-translations into given translation table. The boolean value is taken from en entity table and a defined list of fields. The method also requires a list of languages which should be considered and a list of entity IDs that should be updated.

The usage could look like this:

/** @var BoolToYesNoUpdaterInterface $boolToYesNoUpdater */
/** @var list<array{id: string, name: string}> $languages */
/** @var list<string> $fields */
/** @var list<string> $ids */

$boolToYesNoUpdater->update(
    $languages,
    $defaultLanguage,
    'entity_table',
    'entity_translation_table',
    ['field_1', 'field_2'],
    $ids
);

The language information looks a little strange but it can be fetched with services from this package. The AllLanguagesIdAndNameFetcher just returns a list of all language IDs and names, that are installed in Shopware. The EntityTranslationsLanguagesIdAndNameFetcher returns a list of language IDs and names based on the actual existent entity translations.

/** @var AllLanguagesIdAndNameFetcherInterface $allLanguagesIdAndNameFetcher */
$allLanguagesIdAndNameFetcher->fetch();
/** @var EntityTranslationsLanguagesIdAndNameFetcherInterface $entityTranslationsLanguagesIdAndNameFetcher */
/** @var string $entityTable */
/** @var string $entityTranslationTable */
/** @var list<string> $entityIds */

$entityTranslationsLanguagesIdAndNameFetcher->fetch(
    $entityTable,
    $entityTranslationTable,
    $entityIds
);

Default language and fallback translations

This package uses the it-bens/simple-words-translator. It provides translations for some languages but of cause not for all languages in the world ... or that are known to Shopware. That's why a default language can be defined. If a translation is not found for a language by it's name, the default language will be used instead.

Furthermore, a default value can be defined for all table entries that should be updated because the entity id was passed, but contains not valid boolean value for the given field. The most convenient default value is null.

Performance and Indexer loops

The BoolToYesNoUpdater service is designed to be used in a Shopware data indexer. To improve the performance and to prevent loop calls by triggering the DAL, the updater uses only plain SQL code and no higher abstractions. However, the queries are executed on a doctrine connection, so the queries should still be safe.

Contributing

I am really happy that the software developer community loves Open Source, like I do! ♥

That's why I appreciate every issue that is opened (preferably constructive) and every pull request that provides other or even better code to this package.

You are all breathtaking!

it-bens/shopware-bool-to-yes-no-updater 适用场景与选型建议

it-bens/shopware-bool-to-yes-no-updater 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.31k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 it-bens/shopware-bool-to-yes-no-updater 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 it-bens/shopware-bool-to-yes-no-updater 我们能提供哪些服务?
定制开发 / 二次开发

基于 it-bens/shopware-bool-to-yes-no-updater 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-05