flamix/commerceml 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

flamix/commerceml

Composer 安装命令:

composer require flamix/commerceml

包简介

Flamix package to use CommerceML

README 文档

README

Screenshot

About

This package is intended for integration of product synchronization applications from FLAMIX. The package uses a simplified and improved version of the CommerceML exchange protocol.

Philosophy of Sync

  • Adding, editing, parsing, and deleting products, catalogs, and fields are carried out only on the site;
  • Bitrix24 synchronizes the catalog structure and products with fields;
  • Bitrix24 synchronizes product rests and prices to the site;

Warning! Bitrix24 does not upload the catalog and products to the website.

Screenshot

Concept Guides

We use CommerceML standards, but in order to simplify the exchange and in line with our sync philosophy, the following logical concepts have been adopted:

  • Main language - English (in some places it is translated into Russian to maintain backward compatibility);
  • Synchronization occurs step by step, 30 products per step;
  • After import, the import file is automatically deleted;
  • All data is compressed via zip;
  • If you need stop actions use throw new \Exception('Your message');

API and Actions

Inventory API and sync actions - https://inventory.app.flamix.solutions/docs

Can be imported and used as a Postman collection or OpenAPI Spec.

Install and usage

composer require flamix/commerceml

Create new class

<?php
/**
* Redefining how the plugin works
* If something is not clear, see how it is done in the parent class Flamix\CommerceML\Init
*/
namespace My\CMS;

use Flamix\CommerceML\Init;

class Exchange extends Init {
    /**
    * CALLBACKS
    * 
    * Called on export  
    * The export action calls these callbacks to get arrays of properties to be wrapped in xml
    * @axample public static function get(int $page, array $params = []): array
    * Note! Every callback must return EXTERNAL_ID as ID, and automatically create it, if it's empty or non exist
    * Note! $page will be passed automatically
    */
    protected static string $product_callback = '\Exchange\Woo\Products';
    protected static string $category_callback = '\Exchange\Woo\Categories';
    protected static string $attribute_callback = '\Exchange\Woo\Attributes';

    /**
    * ACTIONS
    * 
    * If you need to override the behavior of a standard action
    * For example, it is almost always necessary to override the authorization action behaviors
    */
    public static function actionCheck()
    {
        if (Setting::getOption('lead_domain') !== ($_SERVER['PHP_AUTH_USER'] ?? ''))
            throw new \Exception('Bad login!');

        if (Setting::getOption('lead_api') !== ($_SERVER['PHP_AUTH_PW'] ?? ''))
            throw new \Exception('Bad password!');

        // If OK - Print our session_id
        return CheckAuth::printPhpSession();
    }

    /****************** | HANDLERS | *******************/
    /**
    * HANDLERS (restsHandler, pricesHandler and productsHandler)
    * 
    * Called on import
    * If you need to override the behavior of a standard action
    * For example, it is almost always necessary to override the authorization action behaviors
    */
    public static function restsHandler($product_id, array $rests): bool
    {
        $woo_id = Products::getProductBy('EXTERNAL_ID', $product_id);
        commerceml_log('[restsHandler] Product ' . (($woo_id) ? 'founded with WooCommerce product ID ' . $woo_id : 'not found') . ' by EXTERNAL_ID: ' . $product_id, $rests);
        if (!$woo_id)
            return false;

        $general_quantity = array_sum(array_column($rests, 'quantity'));
        commerceml_log('[restsHandler] General quantity by all warehouses ' . $general_quantity);

        if (!$general_quantity)
            return false;

        // dd($woo_id, $general_quantity, $rests);
        return Products::set($woo_id, ['quantity' => $general_quantity]);
    }
}

Init sync

// Init main settings and include helpers
\Flamix\Sync\Init::init(__DIR__);

// Start exchange
// \My\CMS\Exchange replace to your class
if (($_GET['flamix_product'] ?? false) === 'Y')
    \My\CMS\Exchange::start();

Export: Products, category and fields from site to CRM

Screenshot

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-10-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固