Skip to content

Commit

Permalink
Update for pull request #17773 - now using SimpleDataObjectConverter:…
Browse files Browse the repository at this point in the history
…:snakeCaseToUpperCamelCase to maintain uniformity, and catch an additional case where the same issue occurred
  • Loading branch information
Richard Aspden authored and insanityinside committed Aug 31, 2018
1 parent cac184c commit f1a2770
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/code/Magento/Catalog/Model/ProductLink/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\Catalog\Api\Data\ProductLinkExtensionFactory;
use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks as LinksInitializer;
use Magento\Catalog\Model\Product\LinkTypeProvider;
use Magento\Framework\Api\SimpleDataObjectConverter;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\EntityManager\MetadataPool;
Expand Down Expand Up @@ -170,7 +171,7 @@ public function getList(\Magento\Catalog\Api\Data\ProductInterface $product)
foreach ($item['custom_attributes'] as $option) {
$name = $option['attribute_code'];
$value = $option['value'];
$setterName = 'set'.str_replace('_', '', ucwords($name, '_'));
$setterName = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($name);
// Check if setter exists
if (method_exists($productLinkExtension, $setterName)) {
call_user_func([$productLinkExtension, $setterName], $value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Magento\Catalog\Api\Data\ProductLinkExtensionFactory;
use Magento\Catalog\Api\Data\ProductLinkInterfaceFactory;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Framework\Api\SimpleDataObjectConverter;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\GroupedProduct\Model\Product\Type\Grouped as TypeGrouped;

Expand Down Expand Up @@ -111,7 +112,7 @@ public function beforeInitializeLinks(
foreach ($linkRaw['custom_attributes'] as $option) {
$name = $option['attribute_code'];
$value = $option['value'];
$setterName = 'set' . ucfirst($name);
$setterName = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($name);
// Check if setter exists
if (method_exists($productLinkExtension, $setterName)) {
call_user_func([$productLinkExtension, $setterName], $value);
Expand Down

0 comments on commit f1a2770

Please sign in to comment.