Archives

All posts for the month February, 2015

I was setting up a  Magento store that had multiple products that were actually the same product. Instead of having multiple reviews split up between the products I made a few modifications to trick Yotpo into thinking one product was really a different product.

It all revolves around the product_id so I made a new product attribute, called it yotpo_id. Simply put in the product id of the item you want to use as the review item and the modifications I made to the code will use the yotpo_id as the product_id if there is data entered for that field in the product setup.

Catalog – Attributes – Manage Attributes

+Add New Attribute

Attribute Code = yotpo_id

Assign attribute to Attribute Set as needed

Edit: default_reviews.phtml and bottomline.phtml

Found here: app/design/frontend/base/default/template/yotpo

bottomline.phtml

<?php 
$productId = $this->getProductId();
$_product = Mage::getModel('catalog/product')->load($productId);
if ($_product->getData('yotpo_id')) {
 $yotpo_id = $_product->getData('yotpo_id');
}
else
{
 $yotpo_id = $this->getProductId();
}
?>
<div class="yotpo bottomLine"
 data-product-id="<?php echo $yotpo_id ?>"
 data-url="<?php echo $this->getProductUrl() ?>">
</div>

default_reviews.phtml

<?php if (!Mage::getStoreConfig('yotpo/yotpo_general_group/disable_default_widget_position',Mage::app()->getStore())):?>
<?php 
$productId = $this->getProductId();
$_product = Mage::getModel('catalog/product')->load($productId);
if ($_product->getData('yotpo_id')) {
 $yotpo_id = $_product->getData('yotpo_id');
}
else
{
 $yotpo_id = $this->getProductId();
}
?>
<div class="yotpo yotpo-main-widget"
 data-product-id="<?php echo $yotpo_id ?>"
 data-name="<?php echo $this->getProductName() ?>"
 data-url="<?php echo $this->getProductUrl() ?>"
 data-image-url="<?php echo $this->getProductImageUrl() ?>"
 data-description="<?php echo $this->getProductDescription() ?>">
 </div>
<?php endif ?>