定制 bitpolar/categoryimgwidget 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

bitpolar/categoryimgwidget

Composer 安装命令:

composer require bitpolar/categoryimgwidget

包简介

Magento2 Category List Widget with optional thumbnails

README 文档

README

Based on
https://github.com/studioraz/magento2-category-image
https://github.com/MageMontreal/magento2-category-list-widget

#Features

  • Add category list as a widget
  • Manage Image Size Output
  • Assign Custom Parent Category
  • Or list any category
  • Add and use additional thumbnail as preview image
  • Images are resized and cached to the user defined sizes
  • Uses the placeholder image as default

Composer Installation Instructions

  composer require bitpolar/categoryimgwidget

Enable Bitpolar/CategoryImgWidget Module

to Enable this module you need to follow these steps:
  • Enable the Module
    bin/magento module:enable Bitpolar_CategoryImgWidget
  • Run Upgrade Setup
    bin/magento setup:upgrade
  • Re-Compile (in-case you have compilation enabled)
    bin/magento setup:di:compile

How to add new category image ?

The module already creates one image field called Thumbnail.

If you need to additional image fields follow these steps:

  1. Create an upgrade data script to create the new category image attribute.
  2. Create new upload class for the new image attribute by copy-pasting the file Controller/Adminhtml/Category/Thumbnail/Upload.php. Change the class name and the following line:
  $result = $this->imageUploader->saveFileToTmpDir('{image-attribute-code}');
  1. Add the new fields to the admin html category form at view/adminhtml/ui_component/category_form.xml and change: the field name, the label and the uploader Url
 <field name="{image-attribute-code}">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">string</item>
                    <item name="source" xsi:type="string">category</item>
                    <item name="label" xsi:type="string" translate="true">{Image Label}</item>
                    <item name="visible" xsi:type="boolean">true</item>
                    <item name="formElement" xsi:type="string">fileUploader</item>
                    <item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
                    <item name="previewTmpl" xsi:type="string">Magento_Catalog/image-preview</item>
                    <item name="required" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">41</item>
                    <item name="uploaderConfig" xsi:type="array">
                        <item name="url" xsi:type="url" path="categoryimage/category_thumbnail/{upload-class-file-name}"/>
                    </item>
                </item>
            </argument>
        </field>
  1. Add the new image attribute code to the helper class Helper/Category.php line 16
public function getAdditionalImageTypes()
    {
        return array('thumbnail', '{image-attribute-code}');
    }
  1. Repeat step 4 in the Controller class Controller/Adminhtml/Category/Save.php line 18
protected function getAdditionalImages() {
        return array('thumbnail', '{image-attribute-code}');
}

If everything went well you should be able to see the new field on the category screen under the Content group. You should also be able to upload, save and delete the image file successfully.

How to show the new image on frontend ?

The module comes with a block that can print any new image field on the category page frontend. Just add the following XML block under the container/block you would like the image to appear.

 <block class="Bitpolar\CategoryImgWidget\Block\Image" name="bitpolar.category.image" template="Bitpolar_CategoryImgWidget::image.phtml">
    <arguments>
        <argument name="image_code" xsi:type="string">{image-attribute-code}</argument>
        <argument name="css_class" xsi:type="string">{div-css-class}</argument>
    </arguments>
</block>

The above block can print category images ONLY on category pages cause it assumes there is already stored category model in core registry. If you need to print the image on other pages use the following code snippet.

$category = 'load a category model class here'; // the decision how to load category model object is up to you.
$helper    = $this->helper('Bitpolar\CategoryImgWidget\Helper\Category');
$imageUrl = $helper->getImageUrl($category->getData('image-attribute-code'));

bitpolar/categoryimgwidget 适用场景与选型建议

bitpolar/categoryimgwidget 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 99 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 09 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 bitpolar/categoryimgwidget 我们能提供哪些服务?
定制开发 / 二次开发

基于 bitpolar/categoryimgwidget 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2019-09-02