To change the layout of the product for related products, varying in size and other 'configurable' attributes
With regards to the referenced layout provided in the link, there are a couple of problems.
The procedure of listing related products has to be carried out for each of the SKUs. Failing which, the 2nd, 3rd or Nth SKU is listed without related product information. This can grow to N*(N-1) additional visible listings for each of the 'N' related SKUs.
Further, the listing is limited to a line item reduced to its price, devoid of accompanying image and description. This invariably leads to clicking through of the related product link, possibly minimizing the 'Add to Cart' conversions mostly tending to zero.
To overcome these issues, Magento Platform provides a much more intuitive solution by way of Configurable products, which I feel is best suited to your use case. In your listing scenario, products differ by either size or other minor 'configurable' attribute. Thus, it makes sense, to associate them as shown in above Configurable product.
How to setup a Configurable product.
Go to Admin Dashboard > Products > Add product
with required global attributes such as color, size.
Note, attributes need to be created first for selecting
while creating new product.
After entering above product information, you can create "simple products" which serves as the base for creating "configurable product" with variations.
Keep in mind that, to create varying price, lets say costlier red tops, you would need to configure "super product attributes". This is found in the "associated products" tab.
Example image, showing super product attributes configuration variations either by way of percentages or fixed price markups.
To summarise, Create simple products, which need not be individually 'visible' thus reducing clutter and enhancing customer experience. Then, associate the related products by way of attributes (color, size etc) to create a configurable product listing.
Also Note that, other options for "related products" layouts in Magento terminology are "Grouped products" and "Bundled products". Of course, programmatically, these could be customised as per our requirements. But for your use case, a simple Configurable product, may just suffice. Hope this helps.