Skip to content

Commit

Permalink
Merge pull request #2 from trustpilot/Extract-brand-from-product
Browse files Browse the repository at this point in the history
Extract brand from product
  • Loading branch information
Algirdas Jonas Kancleris committed Dec 18, 2017
2 parents 42c517f + 29d0a7b commit dab8990
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Block/Head.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
namespace Trustpilot\Invitation\Block;
namespace Trustpilot\Reviews\Block;

use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\View\Element\Template;
use Trustpilot\Invitation\Helper\Data;
use Trustpilot\Reviews\Helper\Data;

class Head extends Template
{
Expand All @@ -23,7 +23,7 @@ public function __construct(

public function renderScript()
{
$key = str_replace(' ', '', $this->_helper->getConfigValue('key'));
$key = trim($this->_helper->getConfigValue('key'));
return '
<script type="text/javascript">
(function(w,d,s,r,n){w.TrustpilotObject=n;w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)};
Expand Down
7 changes: 4 additions & 3 deletions Block/Success.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Trustpilot\Invitation\Block;
namespace Trustpilot\Reviews\Block;

use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Model\Order;
Expand Down Expand Up @@ -33,7 +33,7 @@ public function __construct(
$this->_checkoutSession = $checkoutSession;
$this->_product = $product;
$this->_productMetadata = $productMetadata;
$this->_version = '1.0.8';
$this->_version = '1.0.14';
parent::__construct($context, $data);
}

Expand All @@ -57,12 +57,13 @@ private function getOrder()

foreach ($items as $i) {
$product = $this->_product->load($i->getProductId());
$brand = $product->getAttributeText('manufacturer');
array_push(
$products,
array(
'productUrl' => $product->getProductUrl(),
'name' => $product->getName(),
//'brand' => $brand
'brand' => $brand ? $brand : '',
'sku' => $product->getSku(),
//'gtin' => $gtin,
//'mpn' => $mpn,
Expand Down
6 changes: 3 additions & 3 deletions Helper/Data.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace Trustpilot\Invitation\Helper;
namespace Trustpilot\Reviews\Helper;

use Magento\Framework\App\Helper\AbstractHelper;

class Data extends AbstractHelper
{
const XML_PATH_INVITATION_GENERAL = 'invitation/general/';
const XML_PATH_TRUSTPILOT_GENERAL = 'trustpilot/general/';

public function getConfigValue($value)
{
return $this->scopeConfig->getValue(self::XML_PATH_INVITATION_GENERAL . $value, \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
return $this->scopeConfig->getValue(self::XML_PATH_TRUSTPILOT_GENERAL . $value, \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE);
}
}
7 changes: 5 additions & 2 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
"name": "trustpilot/module-reviews",
"description": "Invite customers to review your e-shop.",
"type": "magento2-module",
"version": "1.0.1",
"version": "1.0.2",
"license": [
"OSL-3.0"
],
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Trustpilot\\Invitation\\": ""
"Trustpilot\\Reviews\\": ""
}
}
}
8 changes: 4 additions & 4 deletions etc/adminhtml/system.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<tab id="trustpilot" translate="label" sortOrder="10">
<label>Trustpilot</label>
</tab>
<section id="invitation" translate="label" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="1">
<section id="trustpilot" translate="label" sortOrder="130" showInDefault="0" showInWebsite="1" showInStore="0">
<class>separator-top</class>
<label>General</label>
<tab>trustpilot</tab>
<resource>Trustpilot_Reviews::invitation_configuration</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="0">
<resource>Trustpilot_Reviews::configuration</resource>
<group id="general" translate="label" type="text" sortOrder="10" showInDefault="0" showInWebsite="1" showInStore="0">
<label>General Configuration</label>
<field id="key" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0">
<field id="key" translate="label" type="text" sortOrder="1" showInDefault="0" showInWebsite="1" showInStore="0">
<label>Key</label>
<comment>Key which is generated during integration setup in Trustpilot business site</comment>
</field>
Expand Down
4 changes: 2 additions & 2 deletions etc/config.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<invitation>
<trustpilot>
<general>
<key></key>
</general>
</invitation>
</trustpilot>
</default>
</config>
Empty file modified etc/module.xml
100644 → 100755
Empty file.
Empty file modified registration.php
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion view/frontend/layout/checkout_onepage_success.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Trustpilot\Invitation\Block\Success" name="trustpilot.order.success" template="Trustpilot_Reviews::order/success.phtml" after="-"/>
<block class="Trustpilot\Reviews\Block\Success" name="trustpilot.order.success" template="Trustpilot_Reviews::order/success.phtml" after="-"/>
</referenceContainer>
</body>
</page>
2 changes: 1 addition & 1 deletion view/frontend/layout/default.xml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="header.container">
<block class="Trustpilot\Invitation\Block\Head" name="trustpilot.header.head" as="trustpilot.header.head" template="Trustpilot_Reviews::header/head.phtml"/>
<block class="Trustpilot\Reviews\Block\Head" name="trustpilot.header.head" as="trustpilot.header.head" template="Trustpilot_Reviews::header/head.phtml"/>
</referenceContainer>
</page>
2 changes: 1 addition & 1 deletion view/frontend/templates/header/head.phtml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php /* @var $block \Trustpilot\Invitation\Block\Head */?>
<?php /* @var $block \Trustpilot\Reviews\Block\Head */?>
<?php echo $block->renderScript(); ?>
2 changes: 1 addition & 1 deletion view/frontend/templates/order/success.phtml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php /* @var $block \Trustpilot\Invitation\Block\Success */?>
<?php /* @var $block \Trustpilot\Reviews\Block\Success */?>
<?php echo $block->renderScript(); ?>

0 comments on commit dab8990

Please sign in to comment.