# sync-basalam/1.9.2/includes/Services/Products/ConnectSingleProductService.php

ووسلام – همگام سازی ووکامرس و باسلام, version 1.9.2. 32 lines.

- Page: https://pluginprobe.com/plugins/sync-basalam/1.9.2/code/includes/Services/Products/ConnectSingleProductService.php
- Raw: https://pluginprobe.com/plugins/sync-basalam/1.9.2/raw/includes/Services/Products/ConnectSingleProductService.php
- Modified: 2026-07-08T11:26:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/sync-basalam/1.9.2/code/includes/Services/Products/ConnectSingleProductService.php#L10-L20`.

```php
<?php

namespace SyncBasalam\Services\Products;

use SyncBasalam\Utilities\ProductMetaKey;

class ConnectSingleProductService
{
    public static function connectProductById($wooProductId, $syncBasalamProductId)
    {
        $existingPosts = get_posts([
            'post_type'  => 'product',
            'meta_query' => [
                [
                    'key'   => ProductMetaKey::basalamProductId(),
                    'value' => $syncBasalamProductId,
                ],
            ],
            'posts_per_page' => 1,
            'fields'         => 'ids',
        ]);

        if (!$existingPosts) {
            update_post_meta($wooProductId, ProductMetaKey::basalamProductId(), $syncBasalamProductId);
            update_post_meta($wooProductId, ProductMetaKey::basalamProductStatus(), 2976);
            update_post_meta($wooProductId, ProductMetaKey::basalamProductSyncStatus(), 'synced');

            return true;
        } else return false;
    }
}

```
