Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(manualInstallation):return widget #51

Merged
merged 1 commit into from
Feb 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}

}