cv65kr/sylius-personalized-products

为Sylius提供个性化产品,基于机器学习(Prediction IO)的选择。

安装: 0

依赖: 0

建议: 0

安全: 0

星标: 3

关注者: 1

分支: 0

开放问题: 0

类型:sylius-plugin

This package is auto-updated.

Last update: 2024-09-29 05:08:26 UTC


README

概述

我使用了 Apache PredictionIO 来创建插件,该插件显示基于观察到的产品的个性化推荐产品。

安装

Sylius

composer require cv65kr/sylius-personalized-products

将插件依赖项添加到您的 AppKernel.php 文件中

public function registerBundles()
{
    return array_merge(parent::registerBundles(), [
        ...
        
        new \cv65kr\SyliusPersonalizedProducts\SyliusPersonalizedProductsPlugin(),
    ]);
}

在您的 app/config/config.yml 文件中导入所需的配置并设置参数

imports:
    ...
    
    - { resource: "@SyliusPersonalizedProductsPlugin/Resources/config/services.yml" }
    
parameters:
    sylius_prediction_event_host: http://machine_learning
    sylius_prediction_event_port: 7070
    sylius_prediction_engine_host: https://machine_learning
    sylius_prediction_engine_port: 8000
    sylius_prediction_key: 'a-mevXQWyArRnxmHvlFKrjHLdjuvhnpqOgYEu8XgvfpLW0RTuPl_wUUQo3ZWQa5F'

在您的 app/config/routing.yml 文件中导入路由

app_personalized_products:
    resource: "@SyliusPersonalizedProductsPlugin/Resources/config/routing.yml"

嵌入到模板中

{{ render(path('sylius_personalized_products_controller')) }}

注意1: 仅应对登录客户使用控制器渲染。

注意2: 您可以在路由中使用 limittemplate 参数。

Apache PredictionIO

首先,在 docker-compose.yml 中添加机器学习

  machine_learning:
      build: ../ml
      ports:
        - "9000:9000"
        - "7070:7070"
        - "8000:8000"
      volumes:
        - /ml/engine:/CustomEngine

然后进入容器

docker exec -it machine_learning bash

下一步

cd /CustomEngine

我们需要下载0.9版本的模板

pio template get apache/predictionio-template-recommender --version v0.3.2 MyRecommendation

创建API密钥并将它们粘贴到Sylius配置参数 - sylius_prediction_key

pio app new SyliusPersonalizedProducts

让我们使用以下命令验证我们的新应用是否已添加

pio app list

在Sylius中运行

bin/console s:p:p

现在回到 machine_learning 容器

cd /CustomEngine/MyRecommendation

构建,可能需要几分钟

pio build --verbose

编辑 engine.json

vim engine.json

更改

"appName": "INVALID_APP_NAME"

"appName": "SyliusPersonalizedProducts"

下一步训练

为训练创建示例数据并导入它们

pio import --appid 1 --input data-sample.json

注意: 示例样本文件,您需要修改此文件:https://gist.githubusercontent.com/vaghawan/0a5fb8ddb85e03631dd500d7c8f0677d/raw/17487437dd8269588d9dd1ac859b129a43842ba5/data-sample.json

下一步运行

pio train

部署,太好了!

pio deploy

贡献

http://docs.sylius.org/en/latest/contributing/ 上了解更多关于我们的贡献工作流程的信息。