Magento 2.4.7 Now Available – Time to Upgrade Your Store

Magento 2.4.7 Now Available – Time to Upgrade Your Store

The latest version of the popular e-commerce platform Magento was recently released. Magento 2.4.7 includes several new features, performance optimizations, and bug fixes to provide an even better experience for online merchants and their customers.
What’s New in Magento 2.4.7?

Some of the key highlights of the Magento 2.4.7 release include:

Improved security with stricter Content Security Policy (CSP)

Support for PHP 8.2 for better performance

Compatibility with OpenSearch as an alternative search engine to Elasticsearch

Enhancements to Page Builder content migration tool

Various bug fixes and optimizations for a more stable platform

For a full list of changes, refer to the Magento 2.4.7 release notes.
Benefits of Upgrading to Magento 2.4.7

By upgrading your Magento store to version 2.4.7, you can take advantage of:

The latest security patches to better protect your site from potential vulnerabilities

Improved site speed and performance from PHP 8.2 support and other optimizations

New features like OpenSearch compatibility and Page Builder enhancements

A more stable environment with various bug fixes

Continued support and security updates from Adobe

Getting Help with Your Magento Upgrade from CodeDecorator

Upgrading Magento can be a complex process, especially if you have customized your site. It’s important to carefully plan your upgrade and thoroughly test everything to avoid any issues that could impact your sales.

If you need help upgrading your Magento store to 2.4.7, consider using the professional Magento upgrade services from CodeDecorator. As an experienced Magento development agency, CodeDecorator can handle the entire upgrade process for you, including:

Evaluating your current site and creating a comprehensive upgrade plan

Performing the actual software upgrade to Magento 2.4.7 with expert precision

Conducting thorough testing and quality assurance on your upgraded site

Training your team on any new features and changes in Magento 2.4.7

Providing ongoing support and maintenance to keep your site running smoothly

CodeDecorator’s team of certified Magento developers has a proven track record of delivering successful upgrades for clients. With their expert assistance, you can smoothly upgrade to Magento 2.4.7 and start benefiting from the latest improvements to this leading e-commerce platform.

To learn more about CodeDecorator’s Magento 2.4.7 upgrade services, contact us now.

How to add a new option in Bundle Item?

Magento2 doesn’t provide the option ‘Is Hidden’ which was there in Magneto1. So here we will explain to you how to add the ‘Is Hidden’ option with help of that anyone can create any other option based on their requirement.

First, need to create a plugin to inject your option. For that, we will add the below code in di.xml to add a plugin for Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\Composite.

<type name="Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\Composite">
   <plugin name="cd_add_new_bundle_option" type="Namespace\Extension\Plugin\Bundle\Ui\DataProvider\Product\Form\Modifier\BundleOptions"/>
</type>

Now we will need to add the code below in the file BundleOptions.php which is located at ‘Codedecorator\Learn\Plugin\Bundle\Ui\DataProvider\Product\Form\Modifier to add the option in all existing options for render.

<?php
namespace Codedecorator\Learn\Plugin\Bundle\Ui\DataProvider\Product\Form\Modifier;

use Magento\Ui\Component\Form;
use Magento\Bundle\Model\Product\Type;
use Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\BundlePanel;
use Magento\Catalog\Model\Locator\LocatorInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Bundle\Api\ProductOptionRepositoryInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;

class BundleOptions extends \Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\Composite
{
    protected $optionFactory;

    public function __construct(
        LocatorInterface $locator,
        ObjectManagerInterface $objectManager,
        ProductOptionRepositoryInterface $optionsRepository,
        ProductRepositoryInterface $productRepository,
        \Magento\Bundle\Model\OptionFactory $OptionFactory,
        array $modifiers = []
    )
    {
        parent::__construct($locator, $objectManager, $optionsRepository, $productRepository, $modifiers);
        $this->optionFactory = $OptionFactory;
    }

    public function afterModifyMeta(
        \Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\Composite $subject,
        $meta
    )
    {
        $meta["bundle-items"]["children"]["bundle_options"]["children"]["record"]["children"]["product_bundle_container"]["children"]["option_info"]["children"]["is_hidden"] = [
            'arguments' => [
                'data' => [
                    'config' => [
                        'dataType' => Form\Element\DataType\Number::NAME,
                        'formElement' => Form\Element\Checkbox::NAME,
                        'componentType' => Form\Field::NAME,
                        'description' => __('Is Hidden'),
                        'dataScope' => 'is_hidden',
                        'label' => ' ',
                        'valueMap' => [
                            'true' => '1',
                            'false' => '0',
                        ],
                        'sortOrder' => 30,
                    ],
                ],
            ],
        ];

        return $meta;
    }

    /**
     * @param \Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\Composite $subject
     * @param $data
     * @return mixed
     * @throws \Magento\Framework\Exception\InputException
     * @throws \Magento\Framework\Exception\NoSuchEntityException
     */
    public function afterModifyData(
        \Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\Composite $subject,
        $data
    )
    {
        $product = $this->locator->getProduct();
        $modelId = $product->getId();
        $isBundleProduct = $product->getTypeId() === Type::TYPE_CODE;
        $optionfactory = $this->optionFactory->create()->load($modelId, 'parent_id');
        $optionfactorycollection = $optionfactory->getCollection()->getData();

        if ($isBundleProduct && $modelId) {
            foreach ($data[$modelId][BundlePanel::CODE_BUNDLE_OPTIONS][BundlePanel::CODE_BUNDLE_OPTIONS] as $key => $val) {
                $data[$modelId][BundlePanel::CODE_BUNDLE_OPTIONS][BundlePanel::CODE_BUNDLE_OPTIONS][$key]['is_hidden'] = ($optionfactorycollection[$key]['is_hidden']) ? '1' : '0';
            }
        }

        return $data;

    }
}

Now in the last step, we need to create the column in the ‘catalog_product_bundle_option’ table. For this, we can create an InstallSchema file.

$setup->startSetup();
$connection = $setup->getConnection();
$tableName = $setup->getTable(self::TABLE_NAME);

if ($connection->isTableExists($tableName) == true) {
    $columns = [
        'is_hidden' => [
            'type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
            'nullable' => false,
            'unsigned' => true,
            'comment' => __('Bundel Item Hidden Status')
        ]
    ];

    foreach ($columns as $name => $definition) {
        $connection->addColumn($tableName, $name, $definition);
    }
}
$setup->endSetup();

That’s all, thanks for your attention. Happy coding 😀