clerk/magento 问题修复 & 功能扩展

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

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

clerk/magento

Composer 安装命令:

composer require clerk/magento

包简介

Clerk.io Turns More Browsers Into Buyers

README 文档

README

The official Clerk.io extension for Magento 1. It connects your store to Clerk.io's AI platform, giving you personalized search, product recommendations, and visitor tracking out of the box.

Version: 4.8.6 · PHP: 5.3+ · Magento: 1.9.x

What It Does

This extension handles three things:

  1. Feeds your product data to Clerk.io — Exposes controller endpoints (/clerk/api/) that the Clerk.io platform calls to sync your catalog. Also pushes real-time updates when products are saved, deleted, or when catalog rules/stock changes.

  2. Renders Clerk.io on the frontend — Injects Clerk.js on every page, which handles search results, live search dropdowns, recommendation sliders, exit-intent popups, and tracking.

  3. Tracks visitor behavior — Logs page views, clicks, cart contents, completed orders, and refunds so Clerk.io's AI can learn and improve results.

Feature Overview

Feature What it does
Search Replaces Magento's native search results page with Clerk.io's. Overrides CatalogSearch/ResultController.
Live Search Type-ahead dropdown. Configurable input selector, suggestions/categories/pages count, dropdown position.
Faceted Search Configurable facet attributes with labels, multiselect support, and custom design template.
Recommendations Sliders on product, category, cart pages. Also available as a Magento widget for CMS pages.
Powerstep After add-to-cart, shows a page or popup with recommendations. Observes checkout_cart_add_product_complete.
Exit Intent Overlay triggered when the visitor moves to leave the page.
Sales Tracking <span> on checkout success page that logs the order to Clerk.io.
Basket Tracking Observes checkout_cart_save_after to sync cart contents to Clerk.io.
Real-Time Sync Observes catalog_product_save_commit_after, catalog_product_delete_before, catalog_product_attribute_update_after, catalogrule_rule_save_after, and clean_catalog_images_cache_after.
Return Tracking Observes sales_order_creditmemo_save_after to track refunded orders.

Installation

  1. Download the latest release from GitHub.
  2. Install via Magento Connect or extract into your Magento root directory preserving the folder structure.
  3. Log out and back in to the admin panel (required for ACL refresh).
  4. Configure at System > Configuration > Clerk > Settings.

Enter your API keys from my.clerk.io.

Full setup guide: help.clerk.io/integrations/magento-1/extension

How It Works Under the Hood

Data Feed Endpoints

All under the /clerk/api/ route. Auth logic is in ApiController.php.

Endpoint What it returns
/clerk/api/product Products with prices, stock, images, categories, child product data, additional fields
/clerk/api/order Orders with line items, quantities, prices, email, customer ID
/clerk/api/category Category tree with parent/child relationships
/clerk/api/customer Customers and subscribers
/clerk/api/page CMS pages
/clerk/api/version Magento version, extension version, PHP version

There are also diagnostic and configuration management endpoints available for Clerk.io platform integration.

Magento Events Observed

Global scope:

Event What it does
catalog_product_save_commit_after Real-time product sync to Clerk.io API
catalog_product_attribute_update_after Sync on mass attribute update
checkout_cart_save_after Basket tracking to Clerk.io API
checkout_cart_add_product_complete Powerstep popup trigger

Frontend scope:

Event What it does
controller_action_layout_generate_blocks_after Layout manipulation for search
core_block_abstract_to_html_before Block rendering modifications

Admin scope:

Event What it does
catalog_product_delete_before Real-time product removal from Clerk.io
catalogrule_rule_save_after Re-sync products when catalog price rules change
clean_catalog_images_cache_after Re-sync products when image cache is flushed
sales_order_creditmemo_save_after Track refunded orders

Frontend Router Overrides

The extension overrides two Magento frontend routers:

  • catalogsearchClerk_Clerk_CatalogSearch is loaded before Mage_CatalogSearch, replacing the search results controller.
  • checkoutClerk_Clerk_Checkout is loaded after Mage_Checkout, extending the cart controller for powerstep.

Structure

├── code/
│   ├── controllers/
│   │   ├── ApiController.php              ← Data feed API (product, order, category, etc.)
│   │   ├── CatalogSearch/ResultController.php ← Overrides native search results
│   │   ├── Checkout/CartController.php    ← Extends cart for powerstep redirect
│   │   ├── BasketController.php           ← Cart contents endpoint
│   │   ├── ClerkLogger.php                ← Logging
│   │   └── Adminhtml/ClerkController.php  ← Admin dashboard controllers
│   │
│   ├── Model/
│   │   ├── Observer.php                   ← All event observers (product sync, basket, powerstep, refunds)
│   │   ├── Config.php                     ← Config path constants
│   │   ├── Communicator.php               ← Clerk.io API client
│   │   ├── Catalog/Product.php            ← Product model rewrite
│   │   ├── Catalog/Productbase.php        ← Product data builder
│   │   ├── Productpage.php                ← Product page data
│   │   └── Orderpage.php                  ← Order page data
│   │
│   ├── Block/
│   │   ├── Tracking.php                   ← Clerk.js init block
│   │   ├── Search.php                     ← Search results block
│   │   ├── SalesTracking.php              ← Order tracking block
│   │   ├── Powerstep.php                  ← Powerstep block
│   │   ├── ExitIntent.php                 ← Exit intent block
│   │   ├── Widget/Content.php             ← Recommendations widget
│   │   └── Adminhtml/Dashboard.php        ← Admin dashboard (my.clerk.io iframe)
│   │
│   ├── Helper/Data.php                    ← Data helper
│   │
│   └── etc/
│       ├── config.xml                     ← Module config (routes, observers, events, defaults)
│       ├── system.xml                     ← Admin configuration fields
│       ├── widget.xml                     ← Clerk Content widget definition
│       └── adminhtml.xml                  ← ACL & admin menu
│
├── design/
│   └── frontend/base/default/
│       ├── layout/clerk.xml               ← Frontend layout (block placement)
│       └── template/clerk/
│           ├── tracking.phtml             ← Clerk.js loader + config + basket tracking
│           ├── search.phtml               ← Search results page
│           ├── livesearch.phtml           ← Live search span
│           ├── facets.phtml               ← Faceted search container
│           ├── salestracking.phtml        ← Order tracking span
│           ├── powerpage.phtml            ← Powerstep page template
│           ├── powerpopup.phtml           ← Powerstep popup template
│           ├── exitintent.phtml           ← Exit intent span
│           └── widget/content.phtml       ← Recommendation widget
│
├── etc/modules/Clerk_Clerk.xml            ← Module declaration
│
└── devenv/                                ← Docker development environment
    └── restart.sh

Customizing & Extending

If you need to customize the extension, here are the parts to be careful with.

CatalogSearch/ResultController.php overrides native search. The extension registers its router before Mage_CatalogSearch, completely replacing the search results page. If another extension also overrides CatalogSearch, there will be a conflict.

Checkout/CartController.php extends the cart controller. Registered after Mage_Checkout to add the powerstep redirect after add-to-cart. Other extensions modifying the cart controller need to be aware of this.

Model/Catalog/Product.php is a model rewrite. The extension rewrites the product model via config.xml (<rewrite><product>Clerk_Clerk_Model_Catalog_Product</product></rewrite>). Only one module can rewrite a model — this will conflict with other extensions that rewrite the same class.

All observers are in one file. Model/Observer.php contains every event observer. If you need to modify observer behavior, this is the single file to look at.

Local code pool overrides. Copy any class from app/code/community/Clerk/Clerk/ to app/code/local/Clerk/Clerk/ to override it safely. Magento loads local before community.

Template overrides. Copy templates from app/design/frontend/base/default/template/clerk/ to your theme's template directory.

Layout overrides. Override clerk.xml in your theme's layout directory to move, remove, or add blocks.

Development Environment

A Docker environment is included for local development.

# Start Magento 1.9.2 with sample data + Clerk extension
./devenv/restart.sh -b http://$(docker ip)/
Service URL Credentials
Admin http://[docker-ip]/admin admin / magentorocks1
phpMyAdmin http://[docker-ip]/phpmyadmin

Shell access:

docker exec -i -t clerk-magento /bin/bash

Troubleshooting

  • Extension not appearing: Check app/etc/modules/Clerk_Clerk.xml exists. Clear cache (rm -rf var/cache/*). Log out and back in to admin.
  • Config not showing: Log out and back in (ACL refresh required after install).
  • Search not working: Verify API keys in System > Configuration > Clerk.
  • Products missing from feed: Visit /clerk/api/product?limit=1 (with auth) to check the feed. Check product visibility settings.
  • Real-time sync not working: Check realtime_updates is enabled in config. Check var/log/clerk_log.log for errors.

Enable logging at System > Configuration > Clerk > Logging Settings — set to "File" to write to var/log/clerk_log.log.

Links

Contributing

  1. Fork and branch from master
  2. Use the included Docker environment for testing
  3. Open a PR with a clear description

Issues & feature requests: github.com/clerkio/clerk-magento/issues

Support

clerk/magento 适用场景与选型建议

clerk/magento 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29.98k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2017 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 10
  • Watchers: 6
  • Forks: 20
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-07-19