cancel
Showing results for 
Search instead for 
Did you mean: 

Grab Simple Product SKUs for a congifurable product (Integrate with Trustpilot).

Grab Simple Product SKUs for a congifurable product (Integrate with Trustpilot).

Hi Guys,

 

I'm looking to integrate Trustpilot product reviews into the product page. Now, to do this, Trustpilot provide the following code;

 

<!-- TrustBox widget - Product Reviews SEO (Beta) -->
<div class="trustpilot-widget" data-locale="en-GB" data-template-id="5717796816f630043868e2e8" data-businessunit-id="537243f2000064000578bf02" data-style-height="700px" data-style-width="100%" data-theme="light" data-sku="SKU-HERE" data-name="Bedroom Athletics">
<a href="https://uk.trustpilot.com/review/bedroomathletics.com" target="_blank">Trustpilot</a>
</div>
<!-- End TrustBox widget -->

"SKU-HERE" is where the SKU goes. Now, to grab the SKU, I have used this code which works great;

 

<!-- TrustBox widget - Product Reviews SEO (Beta) --> <div class="trustpilot-widget" data-locale="en-GB" data-template-id="5717796816f630043868e2e8" data-businessunit-id="537243f2000064000578bf02" data-style-height="700px" data-style-width="100%" data-theme="light" data-sku="<?php echo $_product->getSku(); ?>" data-name="Bedroom Athletics"> <a href="https://uk.trustpilot.com/review/bedroomathletics.com" target="_blank">Trustpilot</a> </div> <!-- End TrustBox widget -->

So this is dynamically grabbing the SKU of the product page. Issue here is that product reviews are only grabbed at a simple product level. Therefore, showing the parent SKU (say 123-456) is not grabbing the reviews for SKU "123-456-ABC" etc. 

 

To workaround this, I appended all our simple SKU codes to the code like so;

 

<?php echo $_product->getSku(); ?>-054-BOX,<?php echo $_product->getSku(); ?>-054-CLP

This works fine. BUT, when working with configurable products with 2 variations, like Size + Colour, this is where my issues occur. 

 

So a SKU follows the format; "ABC-123-*COLOUR*-*SIZE*"

Using the code above adding "-051, -052 etc." is easy because we only have 4 sizes. But for the colour codes, we have hundreds and this would be time consuming.

 

Is there something like a wildcard code which could turn this;

 

<?php echo $_product->getSku(); ?>-054-BOX,<?php echo $_product->getSku(); ?>-054-CLP

 into;

 

<?php echo $_product->getSku(); ?>-054-BOX,<?php echo $_product->getSku(); ?>*-054-CLP

Would appreciate anyone's advice for this Smiley Happy  

1 REPLY

Re: Grab Simple Product SKUs for a congifurable product (Integrate with Trustpilot).

This is down to what Trustpilot supports rather than Magento. Looking at the documentation here https://support.trustpilot.com/hc/en-us/articles/203962358-Server-side-SEO-TrustBox, it doesn't look like something they support. 

 

So I think your only option is to create a full list if reviews are attached to each product variant SKU rather than the parent SKU. 

 

You could do this by $product->getChildrenIds() and then do a product collection load with these IDs to find their SKUs. Even just using $product->getUsedProductCollection($product) may be a way forward. 

----
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution" as appropriate. Thanks!