Skip to content

fix: Add parent product material inheritance for variations#3035

Closed
devbodaghe wants to merge 1 commit intofacebook:mainfrom
devbodaghe:fix-material-sync
Closed

fix: Add parent product material inheritance for variations#3035
devbodaghe wants to merge 1 commit intofacebook:mainfrom
devbodaghe:fix-material-sync

Conversation

@devbodaghe
Copy link
Copy Markdown
Contributor

@devbodaghe devbodaghe commented Apr 9, 2025

Description

This PR fixes an inconsistency in how product material attributes are handled for variable products in the Facebook for WooCommerce sync process. Previously, variations would not inherit their parent product's material attribute, unlike other attributes such as color and size.

What Changed

  • Added parent fallback logic to get_fb_material() method
  • Variations now check parent product's material value if no variation-specific material is set
  • Maintains existing string sanitization and length limits

Before

// Only checked variation attributes and direct meta
$fb_material = get_post_meta($this->id, self::FB_MATERIAL, true);

After

// Now includes parent fallback like other attributes
if (empty($fb_material) && $this->is_type('variation')) {
    $parent_id = $this->get_parent_id();
    if ($parent_id) {
        $fb_material = get_post_meta($parent_id, self::FB_MATERIAL, true);
    }
}
Screenshot 2025-04-09 at 19 47 45

Testing

  1. Create a variable product with a material set at the parent level
  2. Create variations without specific material values
  3. Verify variations inherit the parent's material when syncing to Facebook
  4. Verify variations with their own material values still use their specific value

Related Issues

  • Fixes inconsistent material attribute syncing for variable products
  • Aligns material handling with other product attributes

@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 d786cdd.

vinkmeta pushed a commit that referenced this pull request Apr 13, 2025
Summary:
## Description
This PR fixes an inconsistency in how product material attributes are handled for variable products in the Facebook for WooCommerce sync process. Previously, variations would not inherit their parent product's material attribute, unlike other attributes such as color and size.

### What Changed
- Added parent fallback logic to `get_fb_material()` method
- Variations now check parent product's material value if no variation-specific material is set
- Maintains existing string sanitization and length limits

### Before
```php
// Only checked variation attributes and direct meta
$fb_material = get_post_meta($this->id, self::FB_MATERIAL, true);
```

### After
```php
// Now includes parent fallback like other attributes
if (empty($fb_material) && $this->is_type('variation')) {
    $parent_id = $this->get_parent_id();
    if ($parent_id) {
        $fb_material = get_post_meta($parent_id, self::FB_MATERIAL, true);
    }
}
```

### Testing
1. Create a variable product with a material set at the parent level
2. Create variations without specific material values
3. Verify variations inherit the parent's material when syncing to Facebook
4. Verify variations with their own material values still use their specific value

### Related Issues
- Fixes inconsistent material attribute syncing for variable products
- Aligns material handling with other product attributes

Pull Request resolved: #3035

Reviewed By: vinkmeta

Differential Revision:
D72733411

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 28483bffcdc0563d1af8e98748e8d3a35e9da9b9
mradmeta pushed a commit that referenced this pull request Apr 14, 2025
Summary:
## Description
This PR fixes an inconsistency in how product material attributes are handled for variable products in the Facebook for WooCommerce sync process. Previously, variations would not inherit their parent product's material attribute, unlike other attributes such as color and size.

### What Changed
- Added parent fallback logic to `get_fb_material()` method
- Variations now check parent product's material value if no variation-specific material is set
- Maintains existing string sanitization and length limits

### Before
```php
// Only checked variation attributes and direct meta
$fb_material = get_post_meta($this->id, self::FB_MATERIAL, true);
```

### After
```php
// Now includes parent fallback like other attributes
if (empty($fb_material) && $this->is_type('variation')) {
    $parent_id = $this->get_parent_id();
    if ($parent_id) {
        $fb_material = get_post_meta($parent_id, self::FB_MATERIAL, true);
    }
}
```

### Testing
1. Create a variable product with a material set at the parent level
2. Create variations without specific material values
3. Verify variations inherit the parent's material when syncing to Facebook
4. Verify variations with their own material values still use their specific value

### Related Issues
- Fixes inconsistent material attribute syncing for variable products
- Aligns material handling with other product attributes

Pull Request resolved: #3035

Reviewed By: vinkmeta

Differential Revision:
D72733411

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 28483bffcdc0563d1af8e98748e8d3a35e9da9b9
vahidkay-meta pushed a commit that referenced this pull request Apr 15, 2025
Summary:
## Description
This PR fixes an inconsistency in how product material attributes are handled for variable products in the Facebook for WooCommerce sync process. Previously, variations would not inherit their parent product's material attribute, unlike other attributes such as color and size.

### What Changed
- Added parent fallback logic to `get_fb_material()` method
- Variations now check parent product's material value if no variation-specific material is set
- Maintains existing string sanitization and length limits

### Before
```php
// Only checked variation attributes and direct meta
$fb_material = get_post_meta($this->id, self::FB_MATERIAL, true);
```

### After
```php
// Now includes parent fallback like other attributes
if (empty($fb_material) && $this->is_type('variation')) {
    $parent_id = $this->get_parent_id();
    if ($parent_id) {
        $fb_material = get_post_meta($parent_id, self::FB_MATERIAL, true);
    }
}
```

### Testing
1. Create a variable product with a material set at the parent level
2. Create variations without specific material values
3. Verify variations inherit the parent's material when syncing to Facebook
4. Verify variations with their own material values still use their specific value

### Related Issues
- Fixes inconsistent material attribute syncing for variable products
- Aligns material handling with other product attributes

Pull Request resolved: #3035

Reviewed By: vinkmeta

Differential Revision:
D72733411

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 28483bffcdc0563d1af8e98748e8d3a35e9da9b9
rubycalling pushed a commit that referenced this pull request Apr 16, 2025
Summary:
## Description
This PR fixes an inconsistency in how product material attributes are handled for variable products in the Facebook for WooCommerce sync process. Previously, variations would not inherit their parent product's material attribute, unlike other attributes such as color and size.

### What Changed
- Added parent fallback logic to `get_fb_material()` method
- Variations now check parent product's material value if no variation-specific material is set
- Maintains existing string sanitization and length limits

### Before
```php
// Only checked variation attributes and direct meta
$fb_material = get_post_meta($this->id, self::FB_MATERIAL, true);
```

### After
```php
// Now includes parent fallback like other attributes
if (empty($fb_material) && $this->is_type('variation')) {
    $parent_id = $this->get_parent_id();
    if ($parent_id) {
        $fb_material = get_post_meta($parent_id, self::FB_MATERIAL, true);
    }
}
```

### Testing
1. Create a variable product with a material set at the parent level
2. Create variations without specific material values
3. Verify variations inherit the parent's material when syncing to Facebook
4. Verify variations with their own material values still use their specific value

### Related Issues
- Fixes inconsistent material attribute syncing for variable products
- Aligns material handling with other product attributes

Pull Request resolved: #3035

Reviewed By: vinkmeta

Differential Revision:
D72733411

Privacy Context Container: L1313315

Pulled By: devbodaghe

fbshipit-source-id: 28483bffcdc0563d1af8e98748e8d3a35e9da9b9
@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