定制 swordfox/silverstripe-shopify 二次开发

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

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

swordfox/silverstripe-shopify

Composer 安装命令:

composer require swordfox/silverstripe-shopify

包简介

Import Shopify products into your Silverstripe site, implements the buy button sdk to create a cart and checkout

README 文档

README

This module is for users that want to implement there shopify products into a SilverStripe storefront.

Based on xddesigners/silverstripe-shopify - but completely reworked.

  • Collections are added / removed on a per product basis.
  • Import task with options: default, productsonly & productsall (See 'Set up import script' below).
  • Buy Button scripts included in templates to make it easy to modify & implement in your own way.
  • Versioning removed.
  • Images are not imported from Shopify, instead we use Images.weserv.nl - An image cache & resize service.
  • Optional: Webhooks from Shopify to keep your store updated without having to rely on the import task which can be resource consuming (See 'Set up webhooks' below).
  • Optional: delete_on_shopify for shops that want to delete their products from Shopify after they have been sold, useful for shops that have one-off products (See 'Set up delete_on_shopify' below).

It makes use of the Shopify Buy Button to create the cart and checkout interface.
You'll end up with a import job that fetches all the products and variants and stores them as Product DataObject in your site.

Requirements

  • SilverStripe 4.x

Installation

Install the module trough composer and configure the api keys.

composer require swordfox/silverstripe-shopify

Get up your api keys by creating a new Private App in your Shopify admin interface. If you want to use webhooks via the API e.g. dev/tasks/Swordfox-Shopify-Task-Webhooks/create you need to ensure 'webhooks_shared_secret' is the same as 'shared_secret', however if you want to use manually added webhooks, you will need to get your webhooks shared secret from admin/settings/notifications

Config

Swordfox\Shopify\Client:
  api_key: 'YOUR_API_KEY'
  api_password: 'YOUR_API_PASSWORD'
  api_limit: 50 # Default limit, 250 max
  api_version: '2021-01' # Default 2021-01
  storefront_access_token: 'YOUR_ACCESS_TOKEN' # for buybutton code
  shopify_domain: 'YOUR_SHOPIFY_DOMAIN' # mydomain.myshopify.com
  shared_secret: 'YOUR_API_SHARED_SECRET'
  webhooks_shared_secret: 'YOUR_WEBHOOKS_SHARED_SECRET' # Use same as above for webhooks added via API e.g. dev/tasks/Swordfox-Shopify-Task-Webhooks/create
  webhooks_create:
    'products/update': 'shop/webhook/update/product'
    'products/create': 'shop/webhook/update/product'
    'products/delete': 'shop/webhook/delete/product'
    'collections/create': 'shop/webhook/update/collection'
    'collections/update': 'shop/webhook/update/collection'
    'collections/delete': 'shop/webhook/delete/collection'
    'inventory_levels/connect': 'shop/webhook/update/inventory'
    'inventory_levels/update': 'shop/webhook/update/inventory'
  delete_on_shopify: false
  delete_on_shopify_after: '+3 days' # strtotime('+3 days')
  delete_on_shopify_keep_active: false
  hide_out_of_stock: false
  hide_if_no_image: false
  hide_if_collection_not_active: false
  new_based_on: 'Created' # LastEdited or ImageAdded (use with hide_if_no_image)
  new_timeframe: '+7 days' # strtotime('+7 days')
  cron_interval: '-18 hours' # Allow for timezone offset, e.g. if your timezone is +12:00, add your cron_interval to that as a negative value. So if your cron runs every 6 hours, set the cron_interval to '-18 hours'
  custom_metafields: true # product.metafields.custom.metatitle & product.metafields.custom.brand
  googlefeed_gtinbarcode: false # Show gtin as Barcode from Shopify
  googlefeed_mpnsku: true # Show mpn as SKU from Shopify
  googlefeed_condition: new # The condition of items
  googlefeed_storecode: 'code' # Show store_code in feed, e.g. Queenstown

# Override $default_sort
Swordfox\Shopify\Model\Product:
  default_sort: 'Created DESC' # LastEdited DESC or ImageAdded DESC

Set up import script

You can run the import script manually trough the dev/tasks interface or set up up to run as a cron task. The default task is designed to run once per day and imports / updates the latest 50 api_limit from admin/products.json, admin/custom_collections.json & admin/smart_collections.json. http://example.com/dev/tasks/Swordfox-Shopify-Task-Import or sake dev/tasks/Swordfox-Shopify-Task-Import

The productsonly task is designed to run a few times a day if webhooks are not being used, it imports the latest 50 api_limit from admin/products.json.

http://example.com/dev/tasks/Swordfox-Shopify-Task-Import/productsonly or sake dev/tasks/Swordfox-Shopify-Task-Import/productsonly

The productsall task is designed to run on initial set up and imports all from admin/products.json, admin/custom_collections.json & admin/smart_collections.json.

http://example.com/dev/tasks/Swordfox-Shopify-Task-Import/productsall or sake dev/tasks/Swordfox-Shopify-Task-Import/productsall

Set up webhooks

The following webhooks are supported and can be created automatically via the API using http://example.com/dev/tasks/Swordfox-Shopify-Task-Webhooks/create or sake dev/tasks/Swordfox-Shopify-Task-Webhooks/create

Shopify webhooks

Set up delete_on_shopify

You can run the delete on Shopify script manually trough the dev/tasks interface or set up up to run as a cron task. This task is useful for stores that sell one-off products and want to delete the products off Shopify after a certain period of time delete_on_shopify_after: '+3 days' which is set on ShopifyProduct::DeleteOnShopify during the import tasks if delete_on_shopify: true

http://example.com/dev/tasks/Swordfox-Shopify-Task-DeleteOnShopify or sake dev/tasks/Swordfox-Shopify-Task-DeleteOnShopify

swordfox/silverstripe-shopify 适用场景与选型建议

swordfox/silverstripe-shopify 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.37k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「shopify」 「silverstripe」 「buybutton」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 swordfox/silverstripe-shopify 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-06-02