نعم. الآن سنحوّل الفكرة إلى مواصفة هندسية فعلية v1.0، مع اعتبار ميزة Salla Product Sync / Product-as-a-Service جزءًا أساسيًا من المنتج وليست إضافة جانبية.
والفكرة التي أضفتها تغيّر نموذج المنصة جذريًا:
العميل لا يشتري منتجات فقط؛ بل يشترك في قدرة المنصة على تزويد متجره بمنتجات وبيانات وصور وتصنيفات وخدمات بصورة مستمرة.
وبذلك تصبح المنصة أقرب إلى:
Commerce Infrastructure + SaaS + Marketplace + AI
وليس مجرد متجر أو Plugin.
ملاحظة هندسية مهمة: بحسب وثائق Salla الحالية، التكامل الصحيح يكون عبر تطبيق Salla وOAuth 2.0 والصلاحيات المحددة، وليس عبر تخزين بيانات دخول المتجر. Salla توفر APIs للمنتجات والتصنيفات والصور وتغيير حالة المنتج، كما توفر Webhooks، وتوفر كذلك بنية لاشتراكات التطبيقات.
1. إعادة تعريف المنصة بالكامل
الاسم الوظيفي
Commerce Intelligence OS
أو:
AI Commerce & Product Infrastructure Platform
بالعربية
منصة البنية التحتية الذكية للتجارة والمنتجات الرقمية
2. ماذا تفعل المنصة؟
تربط أربعة عوالم:
PLATFORM
│
┌───────────────┼────────────────┐
│ │ │
SOURCES INTELLIGENCE STORES
│ │ │
▼ ▼ ▼
Amazon/Salla AI Engine Salla
WooCommerce Enrichment WooCommerce
Shopify Mapping Other Stores
CSV/API Pricing
Websites Images
Suppliers Categories
ثم تضيف:
Subscription
+
Entitlements
+
Usage
+
Automation
+
AI
3. المثال الذي ذكرته يصبح منتجًا مستقلاً
لنفرض أن لديك عميلًا:
غيم
لديه متجر Salla.
يدخل إلى منصتك.
يختار:
باقة متجر 500
500 Products
2,000 Images
50 Categories
Product Sync
Price Sync
Inventory Sync
AI Description
AI Translation
Monthly Updates
يدفع شهريًا.
ثم يربط متجر Salla.
بعد نجاح الربط:
Platform
↓
Salla OAuth
↓
Store Connected
↓
Select Products
↓
Import
↓
Transform
↓
Publish
فتظهر المنتجات في متجره.
4. وعند انتهاء الاشتراك؟
هنا نحتاج تصميمًا أكثر ذكاءً من مجرد حذف المنتجات.
لا أنصح بالحذف مباشرة.
بل لدينا:
Product Lease
المنتج الذي أضافته المنصة إلى متجر العميل يحمل:
managed_by = platform
subscription_id = xxx
source_id = xxx
وعند انتهاء الاشتراك:
ACTIVE
↓
GRACE_PERIOD
↓
SUSPENDED
↓
LOCKED
والمنتجات المدارة بواسطة المنصة تصبح:
hidden
والتصنيفات المدارة:
hidden
لكن لا نحذفها تلقائيًا في أول مرحلة.
Salla تدعم تغيير حالة المنتج، وتدعم تحديث التصنيف بحالة hidden، كما أن حذف المنتج والتصنيف متاح عبر صلاحيات الكتابة.
وهذا أفضل بكثير تجاريًا وتقنيًا.
5. لماذا لا نحذف؟
لأن العميل قد يقول:
دفعت مرة أخرى.
نريد:
Subscription expired
↓
Products locked
↓
Renew
↓
Products restored
بدلاً من:
Expired
↓
DELETE 5,000 PRODUCTS
↓
Renew
↓
Rebuild 5,000 PRODUCTS
الأول أسرع وأكثر أمانًا.
6. أهم مفهوم جديد
Product Ownership Model
كل منتج له:
source
owner
manager
license
subscription
status
مثلاً:
Product #1024
Source:
Supplier A
Imported:
2026-09-22
Managed by:
Ghaim Platform
Subscription:
PRO-500
Salla Product:
889231
Status:
ACTIVE
7. ثلاثة أنواع من المنتجات
A — Owned
منتج يملكه العميل.
ownership = merchant
لا نلمسه عند انتهاء الاشتراك.
B — Managed
أدخلته المنصة.
ownership = platform_managed
يمكن قفله عند انتهاء الاشتراك.
C — Synced
منتج تتم مزامنته من مصدر خارجي.
ownership = external_sync
وهو مرتبط بمصدر خارجي.
8. هذه النقطة تحمي العميل
لو العميل لديه 5,000 منتج خاص به:
5,000 owned
واستورد من منصتك:
500 managed
ثم انتهى الاشتراك.
نقوم بإخفاء:
500 managed
ولا نلمس:
5,000 owned
9. Architecture الجديدة
CUSTOMER
│
▼
COMMERCE OS
│
┌───────────────────┼───────────────────┐
│ │ │
SUBSCRIPTION AI ENGINE CONNECTORS
│ │ │
│ │ ┌────────┼────────┐
│ │ │ │ │
▼ ▼ SALLA WC SHOPIFY
ENTITLEMENT TRANSFORM
│ │
└───────────┬───────┘
▼
PRODUCT ENGINE
│
┌───────────┼────────────┐
│ │ │
Catalog Media Pricing
│ │ │
└───────────┼────────────┘
▼
STORE
10. الطبقات الأساسية
Layer 1
Identity
Layer 2
Tenant
Layer 3
Subscription
Layer 4
Entitlement
Layer 5
Commerce
Layer 6
Catalog
Layer 7
Connector
Layer 8
AI
Layer 9
Automation
Layer 10
Analytics
11. هيكل Plugin
اسم مقترح:
zezo-commerce-os
أو:
ai-commerce-os
أنا أفضل:
commerce-os-core
لأن الاسم لا يقيدنا بالـAI.
commerce-os-core/
│
├── commerce-os-core.php
│
├── composer.json
│
├── uninstall.php
│
├── readme.txt
│
├── config/
│ ├── capabilities.php
│ ├── plans.php
│ └── connectors.php
│
├── database/
│ ├── migrations/
│ └── schema.php
│
├── src/
│ │
│ ├── Core/
│ ├── Contracts/
│ ├── Domain/
│ │
│ ├── Identity/
│ ├── Tenancy/
│ ├── Billing/
│ ├── Entitlements/
│ ├── Usage/
│ │
│ ├── Catalog/
│ ├── Products/
│ ├── Categories/
│ ├── Media/
│ ├── Pricing/
│ │
│ ├── Connectors/
│ │ ├── Salla/
│ │ ├── WooCommerce/
│ │ ├── Shopify/
│ │ └── Generic/
│ │
│ ├── Sync/
│ ├── Import/
│ ├── Export/
│ │
│ ├── AI/
│ ├── Automation/
│ ├── Analytics/
│ ├── Licensing/
│ └── API/
│
├── admin/
├── public/
├── resources/
├── routes/
├── templates/
└── tests/
12. PHP Namespace
Zezo\CommerceOS
مثلاً:
namespace Zezo\CommerceOS\Connectors\Salla;
والـCore:
namespace Zezo\CommerceOS\Core;
13. أهم Classes
Application
Container
ServiceProvider
DatabaseManager
MigrationManager
EventBus
Logger
14. Tenant
TenantManager
TenantRepository
TenantContext
TenantResolver
TenantUserRepository
15. Subscription
SubscriptionManager
SubscriptionRepository
PlanManager
PlanRepository
BillingManager
RenewalManager
GracePeriodManager
16. Entitlement
EntitlementManager
EntitlementRepository
CapabilityManager
UsageLimiter
QuotaManager
17. Product
ProductManager
ProductRepository
ProductMapper
ProductTransformer
ProductImporter
ProductExporter
ProductLocker
ProductRestorer
18. Salla
SallaClient
SallaOAuth
SallaTokenManager
SallaProductService
SallaCategoryService
SallaMediaService
SallaWebhookService
SallaSyncService
SallaRateLimiter
19. AI
AiGateway
AiProviderInterface
AiRouter
AiUsageTracker
AiCostCalculator
AiContextBuilder
AiPromptManager
20. Database
الآن الجزء الحقيقي.
wp_cos_tenants
id
uuid
name
slug
status
owner_user_id
created_at
updated_at
wp_cos_tenant_users
id
tenant_id
user_id
role
status
created_at
21. Plans
wp_cos_plans
id
uuid
name
slug
billing_period
price
currency
status
trial_days
created_at
updated_at
مثلاً:
starter
monthly
99 SAR
22. Plan Features
wp_cos_plan_features
id
plan_id
feature_key
limit_value
limit_period
enabled
مثلاً:
products.import = 500
images.storage = 2000
stores.connect = 1
ai.description = 500
sync.daily = true
23. Subscriptions
wp_cos_subscriptions
id
uuid
tenant_id
user_id
plan_id
status
provider
provider_subscription_id
started_at
current_period_start
current_period_end
trial_ends_at
grace_ends_at
cancelled_at
created_at
updated_at
24. Entitlements
wp_cos_entitlements
id
tenant_id
subscription_id
capability
value
status
starts_at
ends_at
created_at
مثلاً:
products.import
500
products.publish
500
stores.salla
1
ai.product_description
500
25. Usage
wp_cos_usage
id
tenant_id
user_id
subscription_id
feature
quantity
period_start
period_end
metadata
created_at
26. Connected Stores
هذه من أهم الجداول.
wp_cos_stores
id
uuid
tenant_id
provider
store_id
store_name
status
access_token_encrypted
refresh_token_encrypted
token_expires_at
scopes
connected_at
disconnected_at
created_at
updated_at
Access tokens لا تُخزن plain text.
Salla تعتمد OAuth 2.0 للوصول إلى متاجر التجار، والصلاحيات محددة بالـscopes.
27. Store Products
wp_cos_store_products
id
store_id
source_product_id
remote_product_id
sku
ownership
sync_status
remote_status
last_synced_at
last_hash
created_at
updated_at
مثلاً:
ownership = platform_managed
28. Sources
نحتاج نظام مصادر.
wp_cos_sources
id
tenant_id
type
name
base_url
credentials
status
created_at
updated_at
أنواع:
salla
woocommerce
shopify
csv
xml
json
api
manual
supplier
29. Source Products
wp_cos_source_products
id
source_id
external_id
sku
name
description
price
cost_price
quantity
currency
status
raw_data
content_hash
last_seen_at
created_at
updated_at
30. Media
wp_cos_media
id
tenant_id
source_product_id
external_url
local_url
hash
mime_type
width
height
size
status
created_at
31. Categories
wp_cos_categories
id
tenant_id
source_category_id
parent_id
name
slug
path
status
created_at
updated_at
32. Mapping
وهذه من أهم الجداول.
wp_cos_category_mappings
id
source_id
source_category_id
target_store_id
target_category_id
status
created_at
updated_at
مثلاً:
Source:
Modern Chandeliers
Salla:
ثريات مودرن
33. Product Mapping
wp_cos_product_mappings
id
source_product_id
target_store_id
target_product_id
source_sku
target_sku
mapping_status
last_synced_at
created_at
updated_at
34. Sync Jobs
wp_cos_sync_jobs
id
uuid
tenant_id
store_id
type
status
total
processed
success
failed
started_at
finished_at
error
created_at
مثلاً:
IMPORT
SYNC
PUBLISH
UPDATE
LOCK
RESTORE
35. Sync Items
wp_cos_sync_items
id
job_id
source_id
source_product_id
target_product_id
action
status
attempts
error
processed_at
36. Audit Log
wp_cos_audit_logs
id
tenant_id
user_id
action
entity_type
entity_id
ip
metadata
created_at
مثلاً:
product.imported
product.published
subscription.expired
store.connected
product.locked
37. REST API
Base:
/wp-json/cos/v1/
Authentication
GET /me
Tenant
GET /tenant
POST /tenant
PUT /tenant
GET /tenant/users
POST /tenant/users
38. Plans
GET /plans
GET /plans/{id}
39. Subscriptions
GET /subscription
POST /subscription
POST /subscription/upgrade
POST /subscription/downgrade
POST /subscription/cancel
POST /subscription/resume
40. Entitlements
GET /entitlements
GET /entitlements/{capability}
GET /usage
41. Stores
GET /stores
POST /stores/salla/connect
GET /stores/salla/callback
DELETE /stores/{id}
POST /stores/{id}/sync
POST /stores/{id}/pause
POST /stores/{id}/resume
42. Products
GET /products
GET /products/{id}
POST /products/import
POST /products/publish
POST /products/bulk-publish
POST /products/bulk-lock
POST /products/bulk-restore
43. Categories
GET /categories
POST /categories/import
POST /categories/publish
POST /categories/lock
POST /categories/restore
44. Sync
POST /sync/start
GET /sync/jobs
GET /sync/jobs/{id}
GET /sync/jobs/{id}/items
POST /sync/jobs/{id}/retry
45. AI
POST /ai/product-description
POST /ai/translate
POST /ai/category-map
POST /ai/image-analysis
POST /ai/product-enrichment
POST /ai/bulk-enrich
46. Webhooks
POST /webhooks/salla
POST /webhooks/billing
POST /webhooks/internal
47. Salla Integration
المنصة تصبح Salla App.
التدفق:
Merchant
↓
Connect Salla
↓
Salla OAuth
↓
Approve Scopes
↓
Callback
↓
Exchange Code
↓
Encrypted Token
↓
Store Connected
وهذا يتوافق مع تدفق OAuth الرسمي لدى Salla.
48. Scopes المطلوبة
بحسب الوظائف التي نريدها نطلب أقل صلاحيات لازمة.
للمزامنة والكتابة نحتاج عمليًا صلاحيات مثل:
products.read
products.read_write
categories.read
categories.read_write
webhooks.read
webhooks.read_write
وتختلف الصلاحيات حسب الوظائف التي ننفذها؛ Salla توثق أن عمليات المنتجات والـcategories تستخدم scopes منفصلة.
49. Import Pipeline
المستخدم يضغط:
Import Products
فتحدث:
Source
↓
Fetch
↓
Normalize
↓
Validate
↓
Deduplicate
↓
Map Category
↓
Map Price
↓
Download Media
↓
AI Enrichment
↓
Preview
↓
Publish
50. لا ننشر مباشرة
هذه نقطة احترافية.
نحتاج:
Import Preview
مثلاً:
Found:
1,284 products
New:
1,012
Existing:
210
Duplicates:
42
Invalid:
20
ثم:
[Review]
[Publish 1,012 Products]
51. Product Transformation
المصدر:
{
"name": "Modern Gold Chandelier",
"price": 1200,
"image": "...",
"category": "Lighting"
}
يتحول إلى:
Canonical Product
ثم:
Salla Product
وهذه فكرة مهمة جدًا:
Canonical Product Model
لأننا لا نريد أن يكون النظام مربوطًا ببنية Salla.
External Source
↓
Canonical Product
↓
Connector
↓
Salla
52. مثال
WooCommerce
\
Shopify ----> Canonical Product ---> Salla
/
CSV
\
Supplier API
وهنا تصبح المنصة Connector Platform.
53. الصور
Salla تدعم إضافة الصور للمنتجات عبر API، ومنها الرفع باستخدام SKU، كما توثق إدارة صور المنتج بشكل مستقل.
نحن نخزن:
Original URL
Local Copy
Hash
Salla Image ID
وبالتالي نعرف:
هل الصورة تغيرت؟
بدون إعادة رفعها في كل Sync.
54. Price Engine
مثلاً المصدر:
Cost = 100
والعميل يريد:
+30%
النظام:
100 × 1.30
= 130
أو:
Cost
+
Fixed Margin
+
Percentage
55. Pricing Rules
Rule
│
├── Source
├── Category
├── Product
├── Vendor
├── Store
└── Global
مثلاً:
Lighting
+25%
Bathroom
+35%
Electronics
+15%
56. AI Product Engine
بعد الاستيراد:
Raw Product
↓
AI
↓
Title
Description
SEO
Arabic
English
Attributes
Tags
Category Suggestion
لكن AI لا يغير السعر أو البيانات الحساسة دون سياسة واضحة.
57. Subscription Lock Engine
وهنا نصل إلى أهم ميزة في طلبك.
حالة الاشتراك:
ACTIVE
TRIAL
PAST_DUE
GRACE
SUSPENDED
CANCELLED
EXPIRED
58. عند انتهاء الاشتراك
Subscription
↓
Expired
↓
Entitlements disabled
↓
Find managed products
↓
Queue Lock Job
↓
Salla API
↓
Product = hidden
↓
Category = hidden
Salla توثق تغيير حالة المنتج إلى hidden عبر endpoint مستقل، كما يمكن تحديث حالة التصنيف إلى hidden.
59. لا نقفل فورًا
أفضل:
Day 0
Payment failed
Day 1–3
Grace Period
Day 4
Limited Access
Day 7
Lock Managed Catalog
الأرقام قابلة للإعداد.
60. Renewal
إذا عاد العميل:
Payment Success
↓
Subscription ACTIVE
↓
Entitlements Restored
↓
Restore Job
↓
Salla
↓
Products sale
↓
Categories visible
61. مهم جدًا: حفظ الحالة السابقة
لا نقول:
restore → sale
دائمًا.
بل:
previous_remote_status
مثلاً:
Before lock:
hidden
بعد التجديد:
restore:
hidden
أما إذا كانت:
sale
فنستعيد:
sale
وهذا يمنع تخريب حالة المتجر.
62. Product Lease Record
أقترح جدولًا إضافيًا:
wp_cos_product_leases
id
tenant_id
store_id
product_id
subscription_id
remote_product_id
locked_at
locked_reason
previous_status
restore_status
created_at
updated_at
63. Category Lease
wp_cos_category_leases
id
tenant_id
store_id
category_id
subscription_id
remote_category_id
previous_status
locked_at
restore_status
created_at
64. Roles
super_admin
platform_admin
support
finance
tenant_owner
tenant_admin
manager
vendor
editor
developer
designer
customer
65. Capabilities
مثلاً:
cos.manage_platform
cos.manage_tenants
cos.manage_subscription
cos.view_billing
cos.connect_store
cos.manage_store
cos.import_products
cos.publish_products
cos.lock_products
cos.restore_products
cos.manage_categories
cos.manage_media
cos.use_ai
cos.use_advanced_ai
cos.create_vendor
cos.manage_vendor
cos.view_analytics
cos.manage_api
66. قاعدة مهمة
Role لا يعطي صلاحية مباشرة.
بل:
Role
↓
Capabilities
↓
Entitlement
↓
Resource
مثلاً:
Vendor
+
products.import
+
Plan allows 500
=
Allowed
67. Dashboard — العميل
Commerce Workspace
┌──────────────────────────────────────┐
│ Store Status ● Connected │
│ Subscription PRO │
│ Renewal 14 days │
└──────────────────────────────────────┘
Products
1,248 / 2,000
Images
4,210 / 10,000
Categories
82 / 200
Sync
● Healthy
AI
68% Used
68. Dashboard — Sync
SYNC CENTER
Salla Store
──────────────
Last Sync:
Today 14:32
Products
1,284
Updated
218
Created
96
Skipped
22
Failed
3
[View Errors]
[Sync Now]
69. Dashboard — Subscription
PLAN
PRO
Products 2,000
Images 10,000
Stores 3
AI Requests 5,000
Renewal:
October 22
[Upgrade]
[Manage Subscription]
70. Dashboard — Vendor
Revenue
Orders
Products
Customers
AI
Marketplace
Analytics
71. Dashboard — Admin
PLATFORM
Tenants 2,483
Stores 3,291
Products 1.8M
Active Subs 1,922
MRR
AI Cost
Sync Jobs
Failures
API Usage
72. AI Gateway
الـAI لا يعرف شيئًا عن WooCommerce أو Salla مباشرة.
interface AiProviderInterface
{
public function generate(array $request): AiResponse;
}
ثم:
OpenAIProvider
AnthropicProvider
GoogleProvider
LocalProvider
وفوقها:
AiRouter
73. AI Router
Task
↓
Classify
↓
Select Model
↓
Check Entitlement
↓
Check Usage
↓
Execute
↓
Log Cost
74. AI Request
wp_cos_ai_requests
id
tenant_id
user_id
provider
model
task
input_tokens
output_tokens
estimated_cost
status
latency_ms
created_at
75. WooCommerce Hooks
نربط WooCommerce بالأحداث المناسبة:
woocommerce_order_status_completed
woocommerce_subscription_status_active
woocommerce_subscription_status_expired
woocommerce_subscription_status_cancelled
woocommerce_product_set_stock
woocommerce_update_product
لكن يجب وضع Adapter خاص بـWooCommerce حتى لا تنتشر hooks داخل كل المشروع.
WooCommerceAdapter
76. Salla Webhooks
نستقبل:
Product changes
Category changes
Order events
App events
ونحولها إلى:
Domain Events
مثلاً:
ExternalProductUpdated
بدلاً من جعل Core يعرف اسم event الخاص بمزود خارجي.
Salla توفر Webhook registration وactive webhook APIs لهذا النوع من التكامل.
77. Event Bus
Salla Product Updated
↓
Salla Adapter
↓
ProductUpdated
↓
Event Bus
│
┌────┼─────┐
▼ ▼ ▼
Update AI Analytics
78. Queue
كل العمليات الثقيلة:
Import
Export
Sync
Image Processing
AI Bulk
Lock
Restore
تذهب إلى Queue.
لا نريد:
HTTP Request
↓
5,000 products
↓
timeout
79. Idempotency
هذه ضرورية.
إذا نفذنا:
Publish Product #123
مرتين، لا نريد:
Product #123
Product #123 Copy
نستخدم:
source_id
+
target_store_id
+
external_id
كمفتاح منطقي.
80. Sync Strategy
ليس:
Delete Everything
Re-import Everything
بل:
Compare
↓
Create
Update
Skip
Archive
ونستخدم:
content_hash
لتحديد التغييرات.
81. مثال حقيقي
المصدر:
Product A
Price 100
آخر hash:
abc123
بعد يوم:
Product A
Price 100
نفس hash:
SKIP
لكن:
Price 120
hash:
xyz456
إذن:
UPDATE
82. Product Count Entitlement
المستخدم لديه:
PRO = 500 products
وهو يحاول استيراد:
700
النظام:
Requested 700
Available 500
لا يفشل بشكل غامض.
بل:
500 → Allowed
200 → Locked
ويظهر:
لديك 500 مقعد منتج متاح من أصل 700.
83. Images Entitlement
مثلاً:
PRO
10,000 images
الاستيراد يحتاج:
12,400
نفس الفكرة.
84. Store Entitlement
Starter
1 Store
Pro
3 Stores
Business
10 Stores
85. Automation
SubscriptionExpired
↓
Grace Period
↓
LockManagedCatalog
↓
CreateJob
↓
Salla API
↓
Verify
↓
Audit
↓
Notify
86. Notification
Email
Dashboard
Webhook
SMS
WhatsApp
لكن كل Provider عبر:
NotificationInterface
87. أهم تحسين تجاري
لا تجعل الرسالة:
“إذا لم تدفع سنخفي منتجاتك.”
هذه تجربة سيئة.
بل:
“تنتهي صلاحية إدارة المنتجات والمحتوى المقدم من المنصة عند انتهاء الاشتراك. سيبقى متجرك وبياناتك الأصلية دون تعديل، بينما يتم إيقاف العناصر التي تديرها المنصة حتى إعادة التفعيل.”
وهذا أكثر وضوحًا وعدلاً.
88. Salla Subscription مقابل Platform Subscription
وهنا يوجد تفصيل مهم جدًا.
لدينا اشتراكان مختلفان:
الأول
Customer
↓
Your Platform
↓
Monthly/Yearly Subscription
الثاني
Your App
↓
Salla App / Merchant relationship
Salla نفسها لديها بنية App Subscriptions وRecurring Payments للتطبيقات، لكن لا ينبغي خلطها تلقائيًا مع نموذج اشتراك العميل الذي نصممه لمنصتك. Salla توثق حاليًا APIs للاشتراكات المتكررة، بما فيها الإنشاء والفوترة والتجديد والإلغاء، وتتطلب صلاحية subscriptions.read_write عند استخدام هذا المسار.
معماريًا سأفصل الاثنين.
89. نموذج الدفع المقترح
Customer
↓
Your Platform Checkout
↓
Subscription
↓
Entitlements
↓
Salla Connector
وبذلك لو أردت لاحقًا:
WooCommerce Store
Shopify Store
Salla Store
لا يتغير نظام الاشتراك.
90. Connector SDK
هذه أهم خطوة تجعل المشروع عالميًا.
interface CommerceConnectorInterface
{
public function authenticate();
public function getProducts();
public function createProduct(array $product);
public function updateProduct($id, array $product);
public function updateProductStatus($id, string $status);
public function getCategories();
public function createCategory(array $category);
public function updateCategory($id, array $category);
public function uploadImage($productId, $image);
public function registerWebhooks();
}
ثم:
SallaConnector
WooCommerceConnector
ShopifyConnector
MagentoConnector
GenericApiConnector
CsvConnector
91. هذه هي نقطة التحول
عندما تنتهي من Salla:
لا تقول:
نحن منصة Salla.
بل:
نحن Commerce Connectivity Platform.
Salla تصبح Connector رقم 1.
92. الهيكل النهائي
COMMERCE OS
│
┌─────────────────┼──────────────────┐
│ │ │
BILLING AI COMMERCE
│ │ │
Subscription Agents Catalog
Plans Enrichment Products
Entitlements Translation Pricing
Usage Automation Media
│ │ │
└─────────────────┼──────────────────┘
│
CONNECTOR ENGINE
│
┌──────────┬──────┼──────┬──────────┐
│ │ │ │ │
SALLA WC SHOPIFY CSV CUSTOM API
93. خطة أول 60 دقيقة — ملفًا بملف
الآن نصل إلى الجزء الذي طلبته تحديدًا.
الدقيقة 0–5
إنشاء:
commerce-os-core/
commerce-os-core.php
composer.json
uninstall.php
ثم:
src/Core/Plugin.php
src/Core/Container.php
src/Core/ServiceProvider.php
5–10
src/Database/Database.php
src/Database/Migrator.php
src/Database/Migrations/
ثم أول Migration:
001_create_tenants.php
002_create_plans.php
003_create_subscriptions.php
004_create_entitlements.php
10–15
src/Tenancy/TenantManager.php
src/Tenancy/TenantRepository.php
src/Tenancy/TenantContext.php
وتسجيل:
wp_cos_tenants
wp_cos_tenant_users
15–20
src/Billing/PlanManager.php
src/Billing/SubscriptionManager.php
src/Billing/UsageManager.php
src/Entitlements/EntitlementManager.php
src/Entitlements/CapabilityManager.php
20–25
src/Commerce/ProductRepository.php
src/Commerce/ProductManager.php
src/Commerce/CategoryRepository.php
والجداول:
sources
source_products
categories
product_mappings
25–30
نبدأ Connector Interface:
src/Connectors/CommerceConnectorInterface.php
ثم:
src/Connectors/Salla/SallaConnector.php
src/Connectors/Salla/SallaClient.php
src/Connectors/Salla/SallaOAuth.php
src/Connectors/Salla/SallaTokenManager.php
30–35
REST API:
src/API/RestController.php
routes/
tenants.php
subscriptions.php
stores.php
products.php
sync.php
ai.php
35–40
Salla OAuth:
/connect/salla
/connect/salla/callback
ثم:
encrypted_token
refresh_token
expires_at
scopes
40–45
Product Sync:
SallaProductService
SallaCategoryService
SallaMediaService
SallaSyncService
ثم:
SyncJob
SyncItem
45–50
Subscription Lock:
ProductLocker
CategoryLocker
ProductRestorer
CategoryRestorer
LeaseManager
50–55
AI:
AiGateway
AiProviderInterface
AiRouter
AiUsageTracker
ثم أول وظيفة:
POST /ai/product-description
55–60
Dashboard:
admin/
Dashboard.php
StoresPage.php
ProductsPage.php
SubscriptionPage.php
SyncPage.php
ثم:
Activation
Database Migration
Smoke Test
Salla Connection Test
Product Import Test
Lock Test
Restore Test
94. لكن هناك تعديل واحد سأجريه على “الساعة الأولى”
لن نحاول خلال الساعة الأولى بناء:
50 ميزة.
سنثبت Vertical Slice واحدًا:
REGISTER
↓
SUBSCRIBE
↓
CONNECT SALLA
↓
IMPORT 10 PRODUCTS
↓
MAP CATEGORY
↓
UPLOAD IMAGES
↓
PUBLISH
↓
EXPIRE SUBSCRIPTION
↓
LOCK PRODUCTS
↓
RENEW
↓
RESTORE
إذا عمل هذا المسار:
المنتج موجود فعليًا.
بعدها كل شيء توسعة.
95. MVP الحقيقي
أول نسخة يجب أن تحتوي فقط على:
✓ Authentication
✓ Tenant
✓ Plans
✓ Subscription
✓ Entitlements
✓ Salla OAuth
✓ Store Connection
✓ Product Import
✓ Category Mapping
✓ Image Import
✓ Product Publish
✓ Product Update
✓ Product Lock
✓ Product Restore
✓ Sync Jobs
✓ Usage Metering
✓ Admin Dashboard
✓ Customer Dashboard
✓ Audit Log
ثم:
AI
Multi-source
Vendor Marketplace
White Label
Mobile
Advanced Analytics
96. النسخة التجارية
بعد MVP:
STARTER
────────────
1 Store
100 Products
500 Images
Basic Sync
PRO
────────────
3 Stores
2,000 Products
10,000 Images
AI
Advanced Sync
BUSINESS
────────────
10 Stores
10,000 Products
50,000 Images
AI Automation
Team
ENTERPRISE
────────────
Custom
Unlimited/Contractual
Private Infrastructure
API
SSO
SLA
الأرقام هنا نماذج تصميمية وليست تسعيرًا نهائيًا.
97. كيف سيستخدمها العميل؟
الخطوة 1
يدخل:
Commerce OS
الخطوة 2
يختار:
ابدأ متجرك
الخطوة 3
يختار:
PRO
الخطوة 4
يدفع.
الخطوة 5
يظهر:
Connect Your Store
[Salla]
[WooCommerce]
[Shopify]
[CSV]
[API]
الخطوة 6
يختار Salla.
الخطوة 7
Salla OAuth.
الخطوة 8
يختار المصدر:
Supplier
CSV
WooCommerce
Salla
API
الخطوة 9
Products
Categories
Images
Prices
Descriptions
الخطوة 10
Preview.
الخطوة 11
Import
الخطوة 12
المنصة تعرض:
✓ 500 products
✓ 1,842 images
✓ 47 categories
✓ 0 critical errors
98. التجربة عند انتهاء الاشتراك
بدلاً من أن يكتشف العميل فجأة أن المتجر اختفى:
14 days before
Renewal reminder
7 days
Reminder
3 days
Warning
1 day
Final notice
Expired
Grace Period
Grace expired
Managed catalog locked
99. والعميل يرى داخل Salla
المنتجات التي تديرها منصتنا:
Hidden
لكن المنتجات الأصلية:
Sale
تظل كما هي.
وهذه النقطة ضرورية لبناء ثقة المنتج.
100. التعريف النهائي للمنصة
يمكن الآن إعادة صياغة المنتج بالكامل:
Commerce OS
منصة SaaS ذكية لإدارة وتوزيع وتشغيل المنتجات الرقمية والتجارية عبر المتاجر والمنصات المختلفة.
تربط المتجر بمصادر المنتجات الخارجية، وتستورد المنتجات والصور والأسعار والتصنيفات، وتحول البيانات الخام إلى كتالوج جاهز للنشر، ثم تزامنه تلقائيًا مع المتجر وفق صلاحيات واشتراك العميل.
وتضيف المنصة طبقة ذكاء اصطناعي لإثراء المنتجات، كتابة الوصف، الترجمة، تصنيف المنتجات، تحليل البيانات، وأتمتة عمليات التجارة.
لا يدفع العميل مقابل برنامج فقط؛ بل يشترك في قدرة تشغيلية مستمرة تشمل عدد المتاجر والمنتجات والصور والمزامنة والذكاء الاصطناعي والخدمات المتاحة له.
وعند انتهاء الاشتراك، يتم إيقاف العناصر التي تديرها المنصة فقط، مع حفظ حالتها السابقة، ثم يمكن استعادتها تلقائيًا عند إعادة الاشتراك.
101. الجملة التي تلخص الفكرة
Connect once. Import anything. Transform intelligently. Sell everywhere.
بالعربية:
اربط متجرك مرة واحدة، استورد من أي مكان، حوّل البيانات بذكاء، وبِع في كل مكان.
102. والرؤية الأكبر
اليوم:
Salla
غدًا:
Salla
WooCommerce
Shopify
Magento
Custom API
CSV
Suppliers
وبعدها:
Commerce OS
↓
Connector Marketplace
↓
Developer SDK
↓
Third-party Connectors
أي أن المبرمج يستطيع لاحقًا بناء:
MyConnector
وتثبيته في منصتك.
وهنا لا تعود أنت من يبني كل Connector بنفسه.
أنت بنيت النظام الذي يسمح للآخرين ببناء Connectors عليه.
وهذه هي النقلة من SaaS Product إلى Platform.
ملاحظة تقنية مهمة جدًا قبل التنفيذ
Salla توثق حاليًا إنشاء وتحديث المنتجات والتصنيفات، وتغيير حالة المنتج، وإدارة صور المنتجات، وحذف المنتجات، إضافة إلى Webhooks وOAuth. لذلك فإن السيناريو الذي طلبته قابل للتنفيذ من حيث واجهات Salla الأساسية، لكن لا ينبغي أن نفترض أن كل عملية bulk ستكون فورية؛ بعض عمليات Salla الجماعية توضع في Queue، ولذلك يجب أن يكون نظامنا نفسه Job/Queue-based من البداية.
والأهم: لن أبني منطق “انتهاء الاشتراك = حذف منتجات”. التصميم الصحيح هو Lease + Lock + Restore مع ownership واضح، لأن ذلك يحمي بيانات المتجر ويجعل الاشتراك قابلًا للاستعادة.
إذا انتقلنا للخطوة التنفيذية التالية، فالمخرج الصحيح ليس وصفًا آخر؛ بل الـRepository الأول فعليًا: commerce-os-core مع composer.json، ملف الـPlugin الرئيسي، الـautoloading، أول 15 Migration، الـPHP Classes، REST Controllers، Salla OAuth/Client، نظام Plans/Entitlements، والكود الفعلي لأول Vertical Slice من التسجيل حتى Import → Publish → Lock → Restore.