Skip to content

docs: Document get_unmapped_attributes from Woo to Meta#3033

Closed
devbodaghe wants to merge 2 commits intofacebook:mainfrom
devbodaghe:unmapped-attributes-investigation
Closed

docs: Document get_unmapped_attributes from Woo to Meta#3033
devbodaghe wants to merge 2 commits intofacebook:mainfrom
devbodaghe:unmapped-attributes-investigation

Conversation

@devbodaghe
Copy link
Copy Markdown
Contributor

Investigation: WooCommerce to Facebook Product Attribute Syncing

Overview

This investigation documents how the get_unmapped_attributes() function handles the synchronization of WooCommerce product attributes that aren't explicitly mapped to standard Facebook catalog fields.

Technical Details

Core Function Implementation

The get_unmapped_attributes() method in WC_Facebook_Product class:

public function get_unmapped_attributes() {
    $unmapped_attributes = array();
    $attributes = $this->woo_product->get_attributes();

    foreach ($attributes as $attribute_name => $_) {
        $value = $this->woo_product->get_attribute($attribute_name);
        
        if (!empty($value)) {
            $mapped_field = $this->check_attribute_mapping($attribute_name);
            
            if ($mapped_field === false) {
                $unmapped_attributes[] = array(
                    'name' => $attribute_name,
                    'value' => $value
                );
            }
        }
    }

    return $unmapped_attributes;
}

Attribute Processing Flow

  1. Collection: Retrieves all WooCommerce product attributes
  2. Filtering:
    • Checks each attribute for non-empty values
    • Verifies if attribute is mapped to a Facebook field
  3. Storage:
    • Stores unmapped attributes in array format
    • Preserves both name and value pairs

Test Coverage

Comprehensive test cases verify:

  • Empty attribute handling
  • Mapped vs unmapped attribute differentiation
  • Mixed attribute scenarios
  • Value validation

Key Behaviors

  • ✅ Only processes attributes with non-empty values
  • ✅ Excludes attributes mapped to standard Facebook fields
  • ✅ Maintains original attribute names and values
  • ✅ Works with both simple and variable products

Example Usage

$facebook_product = new WC_Facebook_Product($product);
$unmapped_attributes = $facebook_product->get_unmapped_attributes();

// Returns:
[
    ['name' => 'weight', 'value' => '2kg'],
    ['name' => 'style', 'value' => 'Modern']
]

Related Components

  • check_attribute_mapping(): Validates attribute mapping status
  • Facebook catalog field mappings
  • WooCommerce attribute management
  • Product meta storage

Testing Validation

Test cases confirm proper handling of:

  • Products with no attributes
  • Products with only mapped attributes
  • Products with only unmapped attributes
  • Products with mixed attribute types
  • Empty attribute values

Next Steps

This investigation provides foundation for:

  • Improving attribute sync documentation
  • Enhancing mapping configurations
  • Optimizing attribute processing
  • Extending test coverage

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@devbodaghe devbodaghe force-pushed the unmapped-attributes-investigation branch from 45c36e0 to 976f7b4 Compare April 9, 2025 16:15
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@devbodaghe merged this pull request in c235f71.

vinkmeta pushed a commit that referenced this pull request Apr 13, 2025
Summary:
# Investigation: WooCommerce to Facebook Product Attribute Syncing

## Overview
This investigation documents how the `get_unmapped_attributes()` function handles the synchronization of WooCommerce product attributes that aren't explicitly mapped to standard Facebook catalog fields.

## Technical Details

### Core Function Implementation
The `get_unmapped_attributes()` method in `WC_Facebook_Product` class:
```php
public function get_unmapped_attributes() {
    $unmapped_attributes = array();
    $attributes = $this->woo_product->get_attributes();

    foreach ($attributes as $attribute_name => $_) {
        $value = $this->woo_product->get_attribute($attribute_name);

        if (!empty($value)) {
            $mapped_field = $this->check_attribute_mapping($attribute_name);

            if ($mapped_field === false) {
                $unmapped_attributes[] = array(
                    'name' => $attribute_name,
                    'value' => $value
                );
            }
        }
    }

    return $unmapped_attributes;
}
```

### Attribute Processing Flow
1. **Collection**: Retrieves all WooCommerce product attributes
2. **Filtering**:
   - Checks each attribute for non-empty values
   - Verifies if attribute is mapped to a Facebook field
3. **Storage**:
   - Stores unmapped attributes in array format
   - Preserves both name and value pairs

### Test Coverage
Comprehensive test cases verify:
- Empty attribute handling
- Mapped vs unmapped attribute differentiation
- Mixed attribute scenarios
- Value validation

### Key Behaviors
- ✅ Only processes attributes with non-empty values
- ✅ Excludes attributes mapped to standard Facebook fields
- ✅ Maintains original attribute names and values
- ✅ Works with both simple and variable products

## Example Usage
```php
$facebook_product = new WC_Facebook_Product($product);
$unmapped_attributes = $facebook_product->get_unmapped_attributes();

// Returns:
[
    ['name' => 'weight', 'value' => '2kg'],
    ['name' => 'style', 'value' => 'Modern']
]
```

## Related Components
- `check_attribute_mapping()`: Validates attribute mapping status
- Facebook catalog field mappings
- WooCommerce attribute management
- Product meta storage

## Testing Validation
Test cases confirm proper handling of:
- Products with no attributes
- Products with only mapped attributes
- Products with only unmapped attributes
- Products with mixed attribute types
- Empty attribute values

## Next Steps
This investigation provides foundation for:
- Improving attribute sync documentation
- Enhancing mapping configurations
- Optimizing attribute processing
- Extending test coverage

Pull Request resolved: #3033

Reviewed By: vinkmeta

Differential Revision:
D72707817

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 0e66df271750005c8f2da74efde4e74db0759ceb
mradmeta pushed a commit that referenced this pull request Apr 14, 2025
Summary:
# Investigation: WooCommerce to Facebook Product Attribute Syncing

## Overview
This investigation documents how the `get_unmapped_attributes()` function handles the synchronization of WooCommerce product attributes that aren't explicitly mapped to standard Facebook catalog fields.

## Technical Details

### Core Function Implementation
The `get_unmapped_attributes()` method in `WC_Facebook_Product` class:
```php
public function get_unmapped_attributes() {
    $unmapped_attributes = array();
    $attributes = $this->woo_product->get_attributes();

    foreach ($attributes as $attribute_name => $_) {
        $value = $this->woo_product->get_attribute($attribute_name);

        if (!empty($value)) {
            $mapped_field = $this->check_attribute_mapping($attribute_name);

            if ($mapped_field === false) {
                $unmapped_attributes[] = array(
                    'name' => $attribute_name,
                    'value' => $value
                );
            }
        }
    }

    return $unmapped_attributes;
}
```

### Attribute Processing Flow
1. **Collection**: Retrieves all WooCommerce product attributes
2. **Filtering**:
   - Checks each attribute for non-empty values
   - Verifies if attribute is mapped to a Facebook field
3. **Storage**:
   - Stores unmapped attributes in array format
   - Preserves both name and value pairs

### Test Coverage
Comprehensive test cases verify:
- Empty attribute handling
- Mapped vs unmapped attribute differentiation
- Mixed attribute scenarios
- Value validation

### Key Behaviors
- ✅ Only processes attributes with non-empty values
- ✅ Excludes attributes mapped to standard Facebook fields
- ✅ Maintains original attribute names and values
- ✅ Works with both simple and variable products

## Example Usage
```php
$facebook_product = new WC_Facebook_Product($product);
$unmapped_attributes = $facebook_product->get_unmapped_attributes();

// Returns:
[
    ['name' => 'weight', 'value' => '2kg'],
    ['name' => 'style', 'value' => 'Modern']
]
```

## Related Components
- `check_attribute_mapping()`: Validates attribute mapping status
- Facebook catalog field mappings
- WooCommerce attribute management
- Product meta storage

## Testing Validation
Test cases confirm proper handling of:
- Products with no attributes
- Products with only mapped attributes
- Products with only unmapped attributes
- Products with mixed attribute types
- Empty attribute values

## Next Steps
This investigation provides foundation for:
- Improving attribute sync documentation
- Enhancing mapping configurations
- Optimizing attribute processing
- Extending test coverage

Pull Request resolved: #3033

Reviewed By: vinkmeta

Differential Revision:
D72707817

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 0e66df271750005c8f2da74efde4e74db0759ceb
vahidkay-meta pushed a commit that referenced this pull request Apr 15, 2025
Summary:

This investigation documents how the `get_unmapped_attributes()` function handles the synchronization of WooCommerce product attributes that aren't explicitly mapped to standard Facebook catalog fields.

The `get_unmapped_attributes()` method in `WC_Facebook_Product` class:
```php
public function get_unmapped_attributes() {
    $unmapped_attributes = array();
    $attributes = $this->woo_product->get_attributes();

    foreach ($attributes as $attribute_name => $_) {
        $value = $this->woo_product->get_attribute($attribute_name);

        if (!empty($value)) {
            $mapped_field = $this->check_attribute_mapping($attribute_name);

            if ($mapped_field === false) {
                $unmapped_attributes[] = array(
                    'name' => $attribute_name,
                    'value' => $value
                );
            }
        }
    }

    return $unmapped_attributes;
}
```

1. **Collection**: Retrieves all WooCommerce product attributes
2. **Filtering**:
   - Checks each attribute for non-empty values
   - Verifies if attribute is mapped to a Facebook field
3. **Storage**:
   - Stores unmapped attributes in array format
   - Preserves both name and value pairs

Comprehensive test cases verify:
- Empty attribute handling
- Mapped vs unmapped attribute differentiation
- Mixed attribute scenarios
- Value validation

- ✅ Only processes attributes with non-empty values
- ✅ Excludes attributes mapped to standard Facebook fields
- ✅ Maintains original attribute names and values
- ✅ Works with both simple and variable products

```php
$facebook_product = new WC_Facebook_Product($product);
$unmapped_attributes = $facebook_product->get_unmapped_attributes();

// Returns:
[
    ['name' => 'weight', 'value' => '2kg'],
    ['name' => 'style', 'value' => 'Modern']
]
```

- `check_attribute_mapping()`: Validates attribute mapping status
- Facebook catalog field mappings
- WooCommerce attribute management
- Product meta storage

Test cases confirm proper handling of:
- Products with no attributes
- Products with only mapped attributes
- Products with only unmapped attributes
- Products with mixed attribute types
- Empty attribute values

This investigation provides foundation for:
- Improving attribute sync documentation
- Enhancing mapping configurations
- Optimizing attribute processing
- Extending test coverage

Pull Request resolved: #3033

Reviewed By: vinkmeta

Differential Revision:
D72707817

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 0e66df271750005c8f2da74efde4e74db0759ceb
rubycalling pushed a commit that referenced this pull request Apr 16, 2025
Summary:
# Investigation: WooCommerce to Facebook Product Attribute Syncing

## Overview
This investigation documents how the `get_unmapped_attributes()` function handles the synchronization of WooCommerce product attributes that aren't explicitly mapped to standard Facebook catalog fields.

## Technical Details

### Core Function Implementation
The `get_unmapped_attributes()` method in `WC_Facebook_Product` class:
```php
public function get_unmapped_attributes() {
    $unmapped_attributes = array();
    $attributes = $this->woo_product->get_attributes();

    foreach ($attributes as $attribute_name => $_) {
        $value = $this->woo_product->get_attribute($attribute_name);

        if (!empty($value)) {
            $mapped_field = $this->check_attribute_mapping($attribute_name);

            if ($mapped_field === false) {
                $unmapped_attributes[] = array(
                    'name' => $attribute_name,
                    'value' => $value
                );
            }
        }
    }

    return $unmapped_attributes;
}
```

### Attribute Processing Flow
1. **Collection**: Retrieves all WooCommerce product attributes
2. **Filtering**:
   - Checks each attribute for non-empty values
   - Verifies if attribute is mapped to a Facebook field
3. **Storage**:
   - Stores unmapped attributes in array format
   - Preserves both name and value pairs

### Test Coverage
Comprehensive test cases verify:
- Empty attribute handling
- Mapped vs unmapped attribute differentiation
- Mixed attribute scenarios
- Value validation

### Key Behaviors
- ✅ Only processes attributes with non-empty values
- ✅ Excludes attributes mapped to standard Facebook fields
- ✅ Maintains original attribute names and values
- ✅ Works with both simple and variable products

## Example Usage
```php
$facebook_product = new WC_Facebook_Product($product);
$unmapped_attributes = $facebook_product->get_unmapped_attributes();

// Returns:
[
    ['name' => 'weight', 'value' => '2kg'],
    ['name' => 'style', 'value' => 'Modern']
]
```

## Related Components
- `check_attribute_mapping()`: Validates attribute mapping status
- Facebook catalog field mappings
- WooCommerce attribute management
- Product meta storage

## Testing Validation
Test cases confirm proper handling of:
- Products with no attributes
- Products with only mapped attributes
- Products with only unmapped attributes
- Products with mixed attribute types
- Empty attribute values

## Next Steps
This investigation provides foundation for:
- Improving attribute sync documentation
- Enhancing mapping configurations
- Optimizing attribute processing
- Extending test coverage

Pull Request resolved: #3033

Reviewed By: vinkmeta

Differential Revision:
D72707817

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 0e66df271750005c8f2da74efde4e74db0759ceb
@tzahgr tzahgr mentioned this pull request Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants