Skip to content

Commit

Permalink
Merge pull request #51 from YotpoLtd/return-widget-when-install-manual
Browse files Browse the repository at this point in the history
fix(manualInstallation):return widget
  • Loading branch information
danadavid authored Feb 18, 2019
2 parents 1c33d67 + 192902b commit 7b10f69
Showing 1 changed file with 15 additions and 32 deletions.
47 changes: 15 additions & 32 deletions app/code/community/Yotpo/Yotpo/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,27 @@ public function __construct() {
$this->_config = Mage::getStoreConfig('yotpo');
}

public function showWidget($thisObj, $product = null, $print = true) {
$res = $this->renderYotpoProductBlock($thisObj, 'yotpo-reviews', $product, $print);
if ($print == false) {
return $res;
}
public function showWidget($thisObj, $product = null) {
$res = $this->renderYotpoProductBlock($thisObj, 'yotpo-reviews', $product);
return $res;
}

public function showBottomline($thisObj, $product = null, $print = true) {

public function showBottomline($thisObj, $product = null) {
$res = $this->renderYotpoProductBlock($thisObj, 'yotpo-bottomline', $product);
if ($print == false) {
return $res;
}
return $res;
}

public function showQABottomline($thisObj, $product = null, $print = true) {

public function showQABottomline($thisObj, $product = null) {
$res = $this->renderYotpoProductBlock($thisObj, 'yotpo-qa-bottomline', $product);
if ($print == false) {
return $res;
}
return $res;
}

public function showQuestions($thisObj, $product = null, $print = true) {
$res = $this->renderYotpoProductBlock($thisObj, 'yotpo-questions', $product, $print);
if ($print == false) {
return $res;
}
public function showQuestions($thisObj, $product = null) {
$res = $this->renderYotpoProductBlock($thisObj, 'yotpo-questions', $product);
return $res;
}

private function renderYotpoProductBlock($thisObj, $blockName, $product = null, $print = true) {
private function renderYotpoProductBlock($thisObj, $blockName, $product = null) {
$block = $thisObj->getLayout()->getBlock('content')->getChild('yotpo');
if ($block == null) {
Mage::log("can't find yotpo block");
Expand All @@ -49,18 +39,11 @@ private function renderYotpoProductBlock($thisObj, $blockName, $product = null,
if ($block == null) {
Mage::log("can't find yotpo child named: " . $blockName);
return;
}

if ($product != null) {
$block->setAttribute('product', $product);
}
if ($block != null) {
if ($print == true) {
$block->toHtml();
} else {
return $block->toHtml();
} else {
if ($product != null) {
$block->setAttribute('product', $product);
}
return $block->toHtml();
}
}

}

0 comments on commit 7b10f69

Please sign in to comment.