docs: Document get_unmapped_attributes from Woo to Meta#3033
Closed
devbodaghe wants to merge 2 commits intofacebook:mainfrom
Closed
docs: Document get_unmapped_attributes from Woo to Meta#3033devbodaghe wants to merge 2 commits intofacebook:mainfrom
devbodaghe wants to merge 2 commits intofacebook:mainfrom
Conversation
Contributor
|
@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
45c36e0 to
976f7b4
Compare
Contributor
|
@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
|
@devbodaghe merged this pull request in c235f71. |
Closed
6 tasks
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
This was referenced Apr 14, 2025
Closed
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
Merged
This was referenced Apr 18, 2025
This was referenced May 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inWC_Facebook_Productclass:Attribute Processing Flow
Test Coverage
Comprehensive test cases verify:
Key Behaviors
Example Usage
Related Components
check_attribute_mapping(): Validates attribute mapping statusTesting Validation
Test cases confirm proper handling of:
Next Steps
This investigation provides foundation for: