Skip to content

Conversation

nmalevanec
Copy link
Contributor

@nmalevanec nmalevanec commented Feb 13, 2018

Original Pull Request

#13551 (created by @tkotosz)

Included Commits

  1. 85f36cd
  2. 3d10764

Manual testing scenarios

  1. Create custom product attribute with backend model = "\Magento\Eav\Model\Entity\Attribute\Backend\JsonEncoded" ex:
    /**
     * Installs data for a module
     *
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
     */
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        /** @var EavSetup $eavSetup */
        $eavSetup = ObjectManager::getInstance()->get(EavSetupFactory::class)->create();
        $eavSetup->addAttribute(
            4,
            'test_json_encoded_attribute',
            [
                'type' => 'text',
                'label' => 'Test Json Encoded Attribute',
                'backend' => \Magento\Eav\Model\Entity\Attribute\Backend\JsonEncoded::class,
                'input' => 'text',
                'required' => false,
                'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
            ]
        );
        $setup->endSetup();
    }
  1. Create product with sku = 's1' and with some value for newly created attribute.
  2. Save product couple times. Example console command:
   protected function execute(InputInterface $input, OutputInterface $output)
    {
        ObjectManager::getInstance()->get(State::class)->setAreaCode(Area::AREA_ADMINHTML);
        //Be sure, you have product with sku = "s1" and value for "test_json_encoded_attribute".
        $product = ObjectManager::getInstance()->get(ProductRepositoryInterface::class)->get('s1');
        $product->save();
        $product->save();
        $output->writeln($product->getCustomAttribute('test_json_encoded_attribute')->getValue());
    }
}
  1. Check, no exceptions have been thrown, in console shows up correct value for "test_json_encoded_attribute".

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team magento-engcom-team added this to the February 2018 milestone Feb 14, 2018
@okorshenko okorshenko modified the milestones: February 2018, March 2018 Mar 1, 2018
@sidolov sidolov self-assigned this Mar 2, 2018
@magento-engcom-team magento-engcom-team merged commit 412d8cc into magento:2.3-develop Mar 6, 2018
magento-engcom-team pushed a commit that referenced this pull request Mar 6, 2018
…d type to not encode attribute value multiple times #13640
magento-engcom-team pushed a commit that referenced this pull request Mar 6, 2018
…d type to not encode attribute value multiple times #13640
@nmalevanec nmalevanec deleted the forwardport-pull-13551 branch August 21, 2018 07:48
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.

4 participants