<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gj |</title>
	<atom:link href="https://blog.gaiterjones.com/category/magento2/catalog/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.gaiterjones.com/category/magento2/catalog/</link>
	<description>gaiterjones</description>
	<lastBuildDate>Thu, 20 Aug 2020 13:47:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>
	<item>
		<title>Improve Slow Loading Magento 2 Large Configurable Products</title>
		<link>https://blog.gaiterjones.com/improve-slow-loading-magento-2-large-configurable-products/</link>
					<comments>https://blog.gaiterjones.com/improve-slow-loading-magento-2-large-configurable-products/#comments</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Mon, 29 Jun 2020 17:41:34 +0000</pubDate>
				<category><![CDATA[Catalog]]></category>
		<category><![CDATA[Magento2]]></category>
		<guid isPermaLink="false">https://blog.gaiterjones.com/?p=2253</guid>

					<description><![CDATA[Configurable products have changed a lot in Magento 2. Compared to Magento 1, Magento 2 configurable products are just containers for simple products (variations). You can no longer configure pricing...<a class="more-link" href="https://blog.gaiterjones.com/improve-slow-loading-magento-2-large-configurable-products/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p>Configurable products have changed a lot in Magento 2.</p>
<p>Compared to Magento 1, Magento 2 configurable products are just containers for simple products (variations). You can no longer configure pricing data directly in the configurable product as the parent configurable inherits all it&#8217;s unit, tier price and inventory data from the child simple products. It&#8217;s also much easier to create products with variations such as size, colour etc. and display them in the frontend in various different ways i.e. visual swatches.</p>
<h1>Large Configurable Products are slow to Load!</h1>
<p>One of the downsides to Magento 2 configurable products is that large configurable products can be slow to load in the frontend if a lot of variations are configured. I worked on a store with a product that is available in over 250 colours and four sizes. This resulted in a configurable product with over 1000 child products and whilst theoretically there is no limit to the amount of simple products in a configurable container product in practice, the way Magento 2 builds the frontend product can lead to very slow load times.</p>
<blockquote><p>In the frontend, Magento 2 loads all variations in a giant JSON object and renders that into the DOM. This JSON object is 20 megabytes for 10,000 variations. In the backend, this JSON is also built and passed to a UI component wrapped in XML. PHP’s xmllib is not able to append extremely large XML structures to an existing XML structure.</p></blockquote>
<p>Even with 1000 variations page load time for an uncached configurable product was in excess of 30 seconds.</p>
<h1>Elgentos LCP</h1>
<p>Fortunately the nice people at <a href="https://elgentos.nl/">Elgentos </a>open sourced a <a href="https://github.com/elgentos/LargeConfigProducts">module</a> developed for a customer experiencing exactly this slow loading Magento 2 configurable product problem. <a href="https://github.com/elgentos/LargeConfigProducts"><em>elgentos/LargeConfigProducts</em></a> greatly improves the loading time of large configurable products by pre-caching the product variation data in the backend and loading the frontend variation JSON as an asynchronous ajax request. This results in a much faster load time of the parent product and the cached variation data.</p>
<p>When I tested the module there were some issues with Magento 2.3.x compatibility which the developer had not had time to correct. I made some changes to make it compatible and also added <span>AQMP/RabbitMQ integration. I am using the module in production without any issues and it has made a big difference to page loading times.</span></p>
<p>Here are a few notes on installing and using the module with Magento 2.3.x.</p>
<p>After installing <a href="https://github.com/gaiterjones/LargeConfigProducts"><em>elgentos/LargeConfigProducts</em></a> you should configure the prewarm settings</p>
<figure id="attachment_2254" aria-describedby="caption-attachment-2254" style="width: 600px" class="wp-caption aligncenter"><img fetchpriority="high" decoding="async" src="https://blog.gaiterjones.com/wp-content/uploads/2020/06/elgentos_lcp_1.jpg" alt="Elgentos LCP Prewarm Settings" width="600" height="251" class="size-full wp-image-2254" /><figcaption id="caption-attachment-2254" class="wp-caption-text">Elgentos LCP Prewarm Settings</figcaption></figure>
<p>&#8220;Prewarming&#8221; is the process of creating and caching the variation data for configurable products. The module uses Redis to cache the data and you should specify your Redis hostname/IP, TCP port and choose a new database for the data.</p>
<p>The module includes a new indexer that will prewarm all configurable products when you manually reindex with <code>bin/magento index:reindex</code></p>
<p>With the module configured and enabled all configurable products will now load variation data via an Ajax request. If variation product data has not been prewarmed or cached the cache will be updated when the product loads. You can also manually create the product variation data cache using a console command</p>
<p><code>bin/magento lcp:prewarm --products 1234,12345 -force</code></p>
<p>This will force a prewarm of variation data for a configurable product with the ids 1234 and 12345.</p>
<p>When you make a change to a configurable product, or a child of a configurable product the module uses a message queue to update the configurable product cached data. Magento 2.3 has built in <span>AQMP/RabbitMQ integration and you can add a Rabbit MQ server to your Magento 2 system by using the following <code>env.php</code> configuration :</p>
<p><code><br />
    'queue' => [<br />
        'amqp' => [<br />
            'host' => 'RABBITMQ_HOST_NAME',<br />
            'port' => 5672,<br />
            'user' => 'guest',<br />
            'password' => 'guest',<br />
            'virtualhost' => '/'<br />
        ]
    ],<br />
</code></p>
<p>Messages are created by a publisher and actioned by a consumer process in the module. To list all the configured Magento 2 consumer queues use:</p>
<p><code>bin/magento queue:consumers:list</code></p>
<p>You will see that <code>elgentos_magento_lcp_product_prewarm</code> is listed. To run the prewarm consumer use <code>bin/magento queue:consumers:start elgentos_magento_lcp_product_prewarm</code> this will start processing all messages generated by the module and updating the product variation data cache for any products that have been changed.</p>
<p>You should ensure that your consumer process is always running. If you use Docker you can create a small consumer container for this purpose.</p>
<pre class="brush: plain; title: ; notranslate">
    consumer1:
        hostname: shop01_consumer
        build:
            context: ./consumer/
        volumes:
            - &quot;${CONTAINERDATA}/${PROJECT_NAME}/www1/dev/magento2:/var/www/dev/magento2&quot;
        depends_on:
            - mysql
            - rabbitmq
        restart: always
        entrypoint: &#x5B;&quot;php&quot;, &quot;./bin/magento&quot;, &quot;queue:consumers:start&quot;, &quot;elgentos_magento_lcp_product_prewarm&quot;]
</pre>
<p>I can also recommend using the RabbitMQ Docker container <code>image: rabbitmq:management</code> the built in management gui is useful for monitoring message data here you can see the lcp message generation for the prewarm consumer after performing a reindex</p>
<figure id="attachment_2257" aria-describedby="caption-attachment-2257" style="width: 597px" class="wp-caption aligncenter"><img decoding="async" src="https://blog.gaiterjones.com/wp-content/uploads/2020/06/elgentos_lcp_2.jpg" alt="RabbitMQ Management Gui" width="597" height="514" class="wp-image-2257" /><figcaption id="caption-attachment-2257" class="wp-caption-text">RabbitMQ Management Gui</figcaption></figure>
<p>In my opinion this functionality should be built into Magento by default to improve the loading time of large configurable products. Changes might be coming to configurable products in Magento 2.4 so perhaps there will be improvements made in this area.</p>
<p>Many thanks to Elgentos and Peter Jaap Blaakmeer for making this module freely available to the community and allowing me to contribute to it.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/improve-slow-loading-magento-2-large-configurable-products/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>Create Custom Product Attributes and Groups in Magento 2</title>
		<link>https://blog.gaiterjones.com/create-custom-product-attributes-and-groups-in-magento-2/</link>
					<comments>https://blog.gaiterjones.com/create-custom-product-attributes-and-groups-in-magento-2/#respond</comments>
		
		<dc:creator><![CDATA[PAJ]]></dc:creator>
		<pubDate>Fri, 19 Jul 2019 10:14:08 +0000</pubDate>
				<category><![CDATA[Catalog]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[Magento2]]></category>
		<category><![CDATA[Magento2 Migration]]></category>
		<guid isPermaLink="false">http://blog.gaiterjones.com/?p=2075</guid>

					<description><![CDATA[Whilst migrating from Magento 1 to Magento 2 you might want to quickly recreate product attributes in Magento 2 programatically. Adding a lot of product attributes manually can be very...<a class="more-link" href="https://blog.gaiterjones.com/create-custom-product-attributes-and-groups-in-magento-2/" title="Continue reading">Continue reading</a>]]></description>
										<content:encoded><![CDATA[<p>Whilst migrating from Magento 1 to Magento 2 you might want to quickly recreate product attributes in Magento 2 programatically. Adding a lot of product attributes manually can be very time consuming so using the setup script in one of your modules let&#8217;s you quickly create new attributes.</p>
<p>An example of the install method is shown below with code for a confiurable product dropdown attribute and a text attribute.</p>
<p>To run the install script use <em>php bin/magento setup:upgrade</em></p>
<p>To force the install script to run again you can delete the module entry in the setup_module database table and run <em>setup:upgrade</em> again. I guess a cleverer way would be to use the upgrade feature but this is really just intended as a one off process to perhaps install 50 product attributes that would otherwise be time consuming to manually configure.</p>
<p><img decoding="async" src="https://blog.gaiterjones.com/wp-content/uploads/2019/07/gaiterjones_catalog_module_setup.jpg" alt="" width="564" height="300" class="aligncenter size-full wp-image-2088" /></p>
<p>Note the group name let&#8217;s you add these custom attributes into their own group which makes them more manageable in the admin interface.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php namespace GaiterJones\Catalog\Setup; use Magento\Eav\Setup\EavSetup; use Magento\Eav\Setup\EavSetupFactory; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { private $eavSetupFactory; public function __construct(EavSetupFactory $eavSetupFactory) { $this-&gt;eavSetupFactory = $eavSetupFactory;
    }

    // CUSTOM product attributes / groups
    //
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $eavSetup = $this-&gt;eavSetupFactory-&gt;create(&#x5B;'setup' =&gt; $setup]);

        // attribute for configurable product
        //
        //
        $eavSetup-&gt;addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'product_colour_x',
            &#x5B;
                'type' =&gt; 'int',
                'group' =&gt; 'GAITERJONES Product',
                'backend' =&gt; '',
                'frontend' =&gt; '',
                'label' =&gt; 'product_colour_x',
                'default' =&gt; '',
                'input' =&gt; 'select',
                'class' =&gt; '',
                'source' =&gt; 'Magento\Eav\Model\Entity\Attribute\Source\Table',
                'global' =&gt; \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible' =&gt; true,
                'required' =&gt; false,
                'user_defined' =&gt; true,
                'searchable' =&gt; false,
                'filterable' =&gt; true,
                'comparable' =&gt; false,
                'visible_on_front' =&gt; false,
                'used_in_product_listing' =&gt; false,
                'unique' =&gt; false,
                'apply_to' =&gt; ''
            ]
        );

        $eavSetup-&gt;addAttribute(
            \Magento\Catalog\Model\Product::ENTITY,
            'selling_unit',
            &#x5B;
                'type' =&gt; 'varchar',
                'group' =&gt; 'GAITERJONES Product',
                'backend' =&gt; '',
                'frontend' =&gt; '',
                'label' =&gt; 'Selling Unit',
                'input' =&gt; 'text',
                'class' =&gt; '',
                'source' =&gt; '',
                'global' =&gt; \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible' =&gt; true,
                'required' =&gt; false,
                'user_defined' =&gt; true,
                'default' =&gt; 'Stück',
                'searchable' =&gt; false,
                'filterable' =&gt; false,
                'comparable' =&gt; false,
                'visible_on_front' =&gt; false,
                'used_in_product_listing' =&gt; false,
                'unique' =&gt; false,
                'apply_to' =&gt; ''
            ]
        );

     }
}

</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.gaiterjones.com/create-custom-product-attributes-and-groups-in-magento-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
