定制 scriptdevelop/meta-catalog-manager 二次开发

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

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

scriptdevelop/meta-catalog-manager

Composer 安装命令:

composer require scriptdevelop/meta-catalog-manager

包简介

Laravel package for Meta Marketing API — multi-account catalog management, product feeds, batch inventory, offers, diagnostics and localized catalogs.

README 文档

README

Latest Version on Packagist PHP Version Laravel License

Laravel package for the Meta Marketing API — complete multi-account catalog management: products, feeds, batch inventory updates, offers, diagnostics, localized catalogs and more.

Features

  • Multi-account — multiple Meta Business Manager accounts, each with multiple catalogs
  • Token encryptionapp_id, app_secret, access_token encrypted at rest using Laravel's encrypt()
  • Product Feeds — primary, supplementary, and localized feeds (language / country / language+country)
  • Batch API — real-time inventory updates, create/update/delete items, localized batch
  • Inventory history — immutable audit log of every stock change (meta_inventory_logs)
  • Offers APISALE, AUTOMATIC_AT_CHECKOUT, BUYER_APPLIED (coupons, Buy X Get Y, free shipping)
  • Diagnostics — catalog errors, event source issues, pixel/app DA checks
  • Event Stats — pixel and app event metrics per catalog
  • Generic Feed Files API — promotions, shipping profiles, navigation menu, ratings & reviews
  • Commerce Merchant Settings — checkout config, merchant status, Korea FTC compliance
  • Page-Owned Catalogs — create and list catalogs owned by a Facebook Page
  • Override Details API — inspect localized overrides per product item
  • Best practices compliancegoogle_product_category, rich_text_description, product_type, internal_label
  • 17-file Spanish documentation included

Requirements

Dependency Version
PHP ^8.2
Laravel ^12.0 or ^13.0
Guzzle ^7.0

Installation

composer require scriptdevelop/meta-catalog-manager

Run the install wizard

php artisan meta-catalog:install

The wizard will:

  1. Publish the configuration file to config/meta-catalog.php
  2. Optionally merge the meta-catalog log channel into your config/logging.php
  3. Optionally run the package migrations

Publish manually

# Configuration
php artisan vendor:publish --tag=meta-catalog-config

# Migrations
php artisan vendor:publish --tag=meta-catalog-migrations

# Logging channel
php artisan vendor:publish --tag=meta-catalog-logging

Run migrations

php artisan migrate

Configuration

// config/meta-catalog.php

'api' => [
    'base_url'      => env('META_CATALOG_API_URL', 'https://graph.facebook.com'),
    'graph_version' => env('META_CATALOG_GRAPH_VERSION', 'v25.0'),
    'timeout'       => env('META_CATALOG_API_TIMEOUT', 30),
    'retries'       => env('META_CATALOG_API_RETRIES', 3),
],

Environment variables

META_CATALOG_API_URL=https://graph.facebook.com
META_CATALOG_GRAPH_VERSION=v25.0
META_CATALOG_API_TIMEOUT=30
META_CATALOG_API_RETRIES=3
META_CATALOG_AUTO_MIGRATIONS=true
META_CATALOG_LOG_CHANNEL=meta-catalog
META_CATALOG_APP_ID=
META_CATALOG_APP_SECRET=

Override models

You can swap any model for your own extended class:

// config/meta-catalog.php
'models' => [
    'meta_business_account' => \App\Models\MyMetaBusinessAccount::class,
    'meta_catalog'          => \App\Models\MyMetaCatalog::class,
    // ...
],

Quick Start

Facade

use ScriptDevelop\MetaCatalogManager\Facades\MetaCatalog;

// With context account
MetaCatalog::forAccount($account)->catalog()->syncFromApi();

// Direct access
MetaCatalog::account()->create([...]);
MetaCatalog::catalog()->syncFromApi($account);

Services

AccountService

// Manual flow (auto-fetches name + syncs catalogs)
$account = MetaCatalog::account()->create([
    'meta_business_id'   => '123456789',
    'access_token'       => 'EAABwz...',
]);

// Get the auto-fetched business name
echo $account->name; // "My Business Name" (from Meta API)

// Embedded Signup flow (WhatsApp OAuth)
$account = MetaCatalog::account()->createFromEmbeddedSignup([
    'business_id'       => '2729063490586005',
    'code'              => 'AQBhlXsctMxJYb...',
]);

// Find / list
$account = MetaCatalog::account()->find($ulid);
$account = MetaCatalog::account()->findByMetaBusinessId('123456789');
$accounts = MetaCatalog::account()->all();

CatalogService

// Sync catalogs from Meta API to local DB
$catalogs = MetaCatalog::catalog()->syncFromApi($account);

// Create a catalog
$catalog = MetaCatalog::catalog()->create($account, [
    'name'     => 'My Store Catalog',
    'vertical' => 'commerce',
]);

// Create a Page-Owned catalog
$catalog = MetaCatalog::catalog()->createForPage($account, $pageId, [
    'name' => 'Page Catalog',
]);

ProductService

// Sync all products (auto-pagination)
$count = MetaCatalog::product()->syncFromApi($catalog);

// Single product operations
MetaCatalog::product()->createSingle($catalog, [
    'retailer_id' => 'SKU-001',
    'name'       => 'Blue T-Shirt',
    'price'       => 1999,
    'currency'    => 'USD',
    'url'        => 'https://mystore.com/t-shirt',
    'image_url'  => 'https://mystore.com/t-shirt.jpg',
    'availability'=> 'in stock',
    'condition'   => 'new',
    'brand'       => 'MyBrand',
    'google_product_category' => 'Apparel & Accessories > Clothing > Shirts & Tops',
]);

// Get override details (localized data)
$overrides = MetaCatalog::product()->getOverrideDetails(
    $productItemId,
    $account,
    keys: ['US', 'es_XX'],
    type: FeedOverrideType::COUNTRY
);

FeedService

// Create a primary feed with daily schedule
$feed = MetaCatalog::feed()->create($catalog, [
    'name'     => 'Main Product Feed',
    'schedule' => [
        'interval' => 'DAILY',
        'url'      => 'https://mystore.com/feed.csv',
        'hour'     => 2,
    ],
]);

// Upload from URL (one-time)
MetaCatalog::feed()->uploadFromUrl($feed, 'https://mystore.com/feed.csv');

// Upload from local file
MetaCatalog::feed()->uploadFromFile($feed, '/path/to/feed.csv');

// Supplementary feed (updates without deleting items)
MetaCatalog::feed()->createSupplementaryFeed($catalog, [
    'name'            => 'Price Updates',
    'primary_feed_ids' => ['1234567890'],
    'schedule'        => ['interval' => 'HOURLY', 'url' => 'https://...'],
]);

// Localized feeds
MetaCatalog::feed()->createLanguageFeed($catalog, 'Language Feed ES/FR');
MetaCatalog::feed()->createCountryFeed($catalog, 'Country Feed US/UK');
MetaCatalog::feed()->createLanguageAndCountryFeed($catalog, 'Locale Feed fr|CA');

// Error reporting
$errors  = MetaCatalog::feed()->getUploadErrors($upload);
MetaCatalog::feed()->requestErrorReport($upload);
$report  = MetaCatalog::feed()->getErrorReport($upload);

BatchService

// Real-time inventory update (async)
$batch = MetaCatalog::batch()->updateItems($catalog, [
    ['retailer_id' => 'SKU-001', 'quantity_to_sell_on_facebook' => 50],
    ['retailer_id' => 'SKU-002', 'quantity_to_sell_on_facebook' => 0],
]);

// Check status
$status = MetaCatalog::batch()->checkStatus($catalog, $batch->handle);

// Create items
MetaCatalog::batch()->createItems($catalog, $items);

// Delete items
MetaCatalog::batch()->deleteItems($catalog, ['SKU-001', 'SKU-002']);

// Localized batch
MetaCatalog::batch()->sendLocalizedBatch($catalog, $localizedItems);

InventoryService

// Update a single item's stock
MetaCatalog::inventory()->updateSingle(
    $catalogItem,
    25,
    InventoryChangeSource::MANUAL,
    'Manual stock adjustment'
);

// Batch update via Meta Batch API
MetaCatalog::inventory()->updateBatch($catalog, [
    ['retailer_id' => 'SKU-001', 'quantity' => 10],
    ['retailer_id' => 'SKU-002', 'quantity' => 0],
]);

// History and reporting
$history  = MetaCatalog::inventory()->getHistory($catalogItem);
$last     = MetaCatalog::inventory()->getLastLog($catalogItem);
$lowStock = MetaCatalog::inventory()->getLowStock($catalog, threshold: 5);
$outOfStock = MetaCatalog::inventory()->getOutOfStock($catalog);

ProductSetService

$set = MetaCatalog::productSet()->create($catalog, [
    'name'   => 'Summer Sale',
    'filter' => ['availability' => ['eq' => 'in stock']],
]);

MetaCatalog::productSet()->syncFromApi($catalog);

DiagnosticsService

// Catalog-level diagnostics
$diagnostics = MetaCatalog::diagnostics()->fetchFromApi($catalog);
MetaCatalog::diagnostics()->syncFromApi($catalog);

// Event source issues
$issues = MetaCatalog::diagnostics()->getEventSourceIssues($catalog, $account);
$hasCritical = MetaCatalog::diagnostics()->hasCriticalEventSourceIssues($catalog, $account);

EventStatsService

$stats = MetaCatalog::eventStats()->fetchFromApi($catalog);
MetaCatalog::eventStats()->syncFromApi($catalog);

OfferService

$offer = MetaCatalog::offer()->createOffer($catalog, [
    'offer_id'         => 'SUMMER20',
    'title'            => 'Summer Sale 20% Off',
    'application_type' => OfferApplicationType::SALE->value,
    'value_type'       => 'PERCENTAGE',
    'percent_off'      => 20,
    'start_date_time'  => '2025-06-01T00:00:00',
    'end_date_time'    => '2025-08-31T23:59:59',
]);

$activeSales   = MetaCatalog::offer()->getActiveSales($catalog);
$activeCoupons = MetaCatalog::offer()->getActiveCoupons($catalog);

GenericFeedService

// Upload shipping profiles
MetaCatalog::genericFeed()->uploadShippingProfiles(
    $account,
    $commercePartnerIntegrationId,
    '/path/to/shipping.csv'
);

// Upload promotions
MetaCatalog::genericFeed()->uploadPromotions(
    $account,
    $commercePartnerIntegrationId,
    '/path/to/promotions.csv'
);

// Upload ratings & reviews
MetaCatalog::genericFeed()->uploadRatingsAndReviews($catalog, '/path/to/reviews.csv');

MerchantSettingsService

$settings = MetaCatalog::merchantSettings()->get($account, $commerceMerchantSettingsId);

MetaCatalog::merchantSettings()->enable($account, $commerceMerchantSettingsId);

MetaCatalog::merchantSettings()->setCheckoutConfig(
    $account,
    $commerceMerchantSettingsId,
    checkoutUrl: 'https://mystore.com/checkout',
    countryCode: 'US'
);

Localized Catalogs

Support for language, country, and language+country override feeds:

use ScriptDevelop\MetaCatalogManager\Enums\FeedOverrideType;

// Language feed (translations: title, description)
MetaCatalog::feed()->createLanguageFeed($catalog, 'Language Feed ES/FR', [
    'interval' => 'DAILY',
    'url'      => 'https://mystore.com/feeds/languages.csv',
    'hour'     => 22,
]);

// Country feed (prices, availability, links by country)
MetaCatalog::feed()->createCountryFeed($catalog, 'Country Feed US/UK/AR', [
    'interval' => 'DAILY',
    'url'      => 'https://mystore.com/feeds/countries.csv',
    'hour'     => 3,
]);

// Language+country feed (advanced: fr_XX|CA, fr_XX|US)
MetaCatalog::feed()->createLanguageAndCountryFeed($catalog, 'Locale Feed', [
    'interval' => 'DAILY',
    'url'      => 'https://mystore.com/feeds/locales.tsv',
    'hour'     => 4,
]);

// Inspect overrides for a specific product
$overrides = MetaCatalog::product()->getOverrideDetails($productItemId, $account);

Priority order: language_and_countrylanguagecountry → main catalog.

Webhooks

The package exposes a webhook endpoint at POST /meta-catalog-webhook for receiving real-time notifications from Meta:

Topic Trigger Description
product_feed Feed upload completes Data from a Product Feed has persisted
items_batch Batch completes Product Catalog Items Batch session has persisted

Customizing the Webhook Processor

// Implement your own processor
class MyWebhookProcessor implements \ScriptDevelop\MetaCatalogManager\Contracts\WebhookProcessorInterface
{
    public function handle(Request $request): Response|JsonResponse { ... }
    public function verifyWebhook(Request $request, string $verifyToken): Response { ... }
    public function processProductFeed(array $payload): void { ... }
    public function processItemsBatch(array $payload): void { ... }
}

// Set in .env
META_CATALOG_WEBHOOK_PROCESSOR=\\App\\Webhooks\\MyWebhookProcessor
META_CATALOG_WEBHOOK_VERIFY_TOKEN=your_secret_token

Database Schema

Table Description
meta_business_accounts Accounts with encrypted tokens
meta_catalogs Product catalogs
meta_product_feeds Primary, supplementary, and localized feeds
meta_product_feed_uploads Upload sessions and error tracking
meta_catalog_items Product items with full field set
meta_product_sets Product sets with filter JSON
meta_batch_requests Batch API requests and status
meta_catalog_diagnostics Catalog error cache
meta_event_sources Pixels and apps linked to catalogs
meta_event_stats Event metric cache
meta_inventory_logs Immutable inventory change audit log
meta_catalog_offers Offers (sale, coupon, Buy X Get Y)
meta_generic_feeds Generic feed files (shipping, promotions, etc.)

Available Enums

Enum Values
AccountStatus ACTIVE, DISCONNECTED, REMOVED
CatalogVertical commerce, hotels, flights, destinations, vehicles, home_listings
CatalogItemType PRODUCT_ITEM, VEHICLE, HOTEL, FLIGHT, DESTINATION, HOME_LISTING, VEHICLE_OFFER
ItemAvailability in stock, out of stock, preorder, available for order, discontinued
ItemCondition new, refurbished, used
FeedIngestionSourceType PRIMARY_FEED, SUPPLEMENTARY_FEED
FeedOverrideType language, country, language_and_country
FeedFormat csv, tsv, rss_xml, atom_xml, google_sheets
FeedScheduleType HOURLY, DAILY, WEEKLY
BatchRequestStatus IN_PROGRESS, FINISHED, ERROR
InventoryChangeSource feed_upload, batch_api, manual, system
OfferApplicationType SALE, AUTOMATIC_AT_CHECKOUT, BUYER_APPLIED
OfferValueType FIXED_AMOUNT, PERCENTAGE
GenericFeedType PROMOTIONS, SHIPPING_PROFILES, NAVIGATION_MENU, PRODUCT_RATINGS_AND_REVIEWS
EventSourceIssueType PIXEL_MISSING_SIGNAL, PIXEL_NOT_MAPPED, LOW_MATCH_RATE, ...

Documentation

Full Spanish documentation is available in documentation/es/:

  1. Instalación
  2. Configuración
  3. Cuentas de Negocio
  4. Catálogos
  5. Productos
  6. Inventario
  7. Feeds
  8. Batch API
  9. Conjuntos de Productos
  10. Diagnósticos
  11. Ofertas
  12. Diagnósticos Avanzados
  13. Microdatos
  14. Calificaciones y Opiniones
  15. Feeds Genéricos
  16. Merchant Settings
  17. Catálogos Localizados

Changelog

See CHANGELOG.md for release history.

License

MIT © Wilfredo Perilla

scriptdevelop/meta-catalog-manager 适用场景与选型建议

scriptdevelop/meta-catalog-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 573 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 03 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 scriptdevelop/meta-catalog-manager 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-23