Skip to content

Commit

Permalink
Merge pull request #12 from FACT-Finder-Web-Components/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
toarm authored Mar 21, 2018
2 parents 51f3f28 + 1c91726 commit 439216c
Show file tree
Hide file tree
Showing 37 changed files with 752 additions and 2,208 deletions.
2 changes: 1 addition & 1 deletion Omikron/Factfinder/Block/FF/Communication.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(Template\Context $context, $data = [], Data $helper,
'defaultValue' => null
],
'sid' => [
'value' => $tracking->getSessionId(),
'value' => $this->_helper->getCorrectSessionId($tracking->getSessionId()),
'type' => 'string',
'defaultValue' => null
],
Expand Down
121 changes: 121 additions & 0 deletions Omikron/Factfinder/Block/FF/Recommendation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php
/**
* Created by PhpStorm.
* User: soroush
* Date: 13/12/17
* Time: 15:00
*/

namespace Omikron\Factfinder\Block\FF;

use Magento\Catalog\Model\Product;
use \Magento\Framework\View\Element\Template;

class Recommendation extends Template
{
/**
* @var Product
*/
protected $_product = null;

/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry = null;

/** @var \Magento\Catalog\Helper\Image */
protected $_imageHelper;

/** @var \Omikron\Factfinder\Helper\Data */
protected $_helper;

/** @var \Magento\Directory\Model\Currency */
protected $_currency;

/**
* Recommendation constructor.
* @param Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param array $data
*/
public function __construct(
Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Directory\Model\Currency $currency,
\Magento\Catalog\Helper\Image $imageHelper,
\Omikron\Factfinder\Helper\Data $helper,
array $data = []
)
{
$this->_coreRegistry = $registry;
$this->_currency = $currency;
$this->_imageHelper = $imageHelper;
$this->_helper = $helper;
parent::__construct($context, $data);
}

/**
* @return Product
*/
public function getProduct()
{
if (!$this->_product) {
$this->_product = $this->_coreRegistry->registry('product');
}
return $this->_product;
}

/**
* Get the placeholder image url for products
*
* @return string
*/
public function getProductImagePlaceholder()
{
return $this->_imageHelper->getDefaultPlaceholderUrl('image');
}

/**
* Get the url for submitting the addToCart form
*
* @return string
*/
public function getAddToCartUrl()
{
return $this->getUrl('checkout/cart/add');
}

/**
* Test if the addToCart is enabled in the factfinder options
*
* @return mixed
*/
public function isAddToCartEnabled()
{
return $this->_helper->getShowAddToCartButton();
}

/**
* Get current store currency code
*
* @return string
*/
public function getCurrentCurrencyCode()
{

return $this->_storeManager->getStore()->getCurrentCurrencyCode();
}

/**
* Get currency symbol for current locale and currency code
*
* @return string
*/
public function getCurrentCurrencySymbol()
{
return $this->_currency->getCurrencySymbol();
}

}
2 changes: 1 addition & 1 deletion Omikron/Factfinder/Block/FF/RecordList.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class RecordList extends Template
*
* @param Template\Context $context
* @param \Magento\Directory\Model\Currency $currency
* @param array $data
* @param \Magento\Catalog\Helper\Image $imageHelper
* @param \Omikron\Factfinder\Helper\Data $helper
* @param array $data
*/
public function __construct(
Template\Context $context,
Expand Down
121 changes: 121 additions & 0 deletions Omikron/Factfinder/Block/FF/Similar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php
/**
* Created by PhpStorm.
* User: soroush
* Date: 13/12/17
* Time: 15:00
*/

namespace Omikron\Factfinder\Block\FF;

use Magento\Catalog\Model\Product;
use \Magento\Framework\View\Element\Template;

class Similar extends Template
{
/**
* @var Product
*/
protected $_product = null;

/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $_coreRegistry = null;

/** @var \Magento\Catalog\Helper\Image */
protected $_imageHelper;

/** @var \Omikron\Factfinder\Helper\Data */
protected $_helper;

/** @var \Magento\Directory\Model\Currency */
protected $_currency;

/**
* Recommendation constructor.
* @param Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param array $data
*/
public function __construct(
Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Directory\Model\Currency $currency,
\Magento\Catalog\Helper\Image $imageHelper,
\Omikron\Factfinder\Helper\Data $helper,
array $data = []
)
{
$this->_coreRegistry = $registry;
$this->_currency = $currency;
$this->_imageHelper = $imageHelper;
$this->_helper = $helper;
parent::__construct($context, $data);
}

/**
* @return Product
*/
public function getProduct()
{
if (!$this->_product) {
$this->_product = $this->_coreRegistry->registry('product');
}
return $this->_product;
}

/**
* Get the placeholder image url for products
*
* @return string
*/
public function getProductImagePlaceholder()
{
return $this->_imageHelper->getDefaultPlaceholderUrl('image');
}

/**
* Get the url for submitting the addToCart form
*
* @return string
*/
public function getAddToCartUrl()
{
return $this->getUrl('checkout/cart/add');
}

/**
* Test if the addToCart is enabled in the factfinder options
*
* @return mixed
*/
public function isAddToCartEnabled()
{
return $this->_helper->getShowAddToCartButton();
}

/**
* Get current store currency code
*
* @return string
*/
public function getCurrentCurrencyCode()
{

return $this->_storeManager->getStore()->getCurrentCurrencyCode();
}

/**
* Get currency symbol for current locale and currency code
*
* @return string
*/
public function getCurrentCurrencySymbol()
{
return $this->_currency->getCurrencySymbol();
}

}
21 changes: 20 additions & 1 deletion Omikron/Factfinder/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Data extends AbstractHelper
{
const FRONT_NAME = "FACT-Finder";
const CUSTOM_RESULT_PAGE = "result";
const SESSION_ID_LENGTH = 30;

const PATH_TRACKING_PRODUCT_NUMBER_FIELD_ROLE = 'factfinder/general/tracking_product_number_field_role';
const PATH_IS_ENABLED = 'factfinder/general/is_enabled';
Expand Down Expand Up @@ -425,4 +426,22 @@ public function setFieldRoles($value, $store)
{
return $this->_resourceConfig->saveConfig(self::PATH_TRACKING_PRODUCT_NUMBER_FIELD_ROLE, $value, 'stores', $store->getId());
}
}

/**
* Get correct sessionId
* @param string $sessionId
* @return string
*/
public function getCorrectSessionId($sessionId)
{
while (strlen($sessionId) !== self::SESSION_ID_LENGTH) {
if (strlen($sessionId) < self::SESSION_ID_LENGTH) {
$sessionId = $sessionId . substr($sessionId, 0, (self::SESSION_ID_LENGTH - strlen($sessionId)));
} else if (strlen($sessionId) > self::SESSION_ID_LENGTH) {
$sessionId = substr($sessionId, 0, self::SESSION_ID_LENGTH);
}
}

return $sessionId;
}
}
10 changes: 10 additions & 0 deletions Omikron/Factfinder/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>TODO Description Pushed Products</comment>
</field>
<field id="ff_recommendation" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Recommendation</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>TODO Description Pushed Products</comment>
</field>
<field id="ff_similar" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Similar</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>TODO Description Pushed Products</comment>
</field>
</group>
<group id="data_transfer" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Data export</label>
Expand Down
2 changes: 2 additions & 0 deletions Omikron/Factfinder/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<ff_productspp>0</ff_productspp>
<ff_campaign>0</ff_campaign>
<ff_pushedproductscampaign>0</ff_pushedproductscampaign>
<ff_recommendation>0</ff_recommendation>
<ff_similar>0</ff_similar>
</components>
<data_transfer>
<ff_cron_enabled>0</ff_cron_enabled>
Expand Down
4 changes: 3 additions & 1 deletion Omikron/Factfinder/i18n/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@
"Automatic Import of productdata","Automatischer Import der Produktdaten"

"Yes","Ja"
"No","Nein
"No","Nein

"Recommendations","Empfehlungen"
20 changes: 20 additions & 0 deletions Omikron/Factfinder/view/frontend/layout/catalog_product_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Omikron_Factfinder/::css/ff/recommendation.css"/>
<css src="Omikron_Factfinder/::css/ff/record-list.css"/>
<css src="Omikron_Factfinder/::css/ff/similar.css"/>
</head>
<body>
<referenceContainer name="content">
<block class="Omikron\Factfinder\Block\FF\Recommendation" ifconfig="factfinder/components/ff_recommendation" template="Omikron_Factfinder::ff/recommendation.phtml" />
<block class="Omikron\Factfinder\Block\FF\Similar" ifconfig="factfinder/components/ff_similar" template="Omikron_Factfinder::ff/similar.phtml" />
</referenceContainer>
</body>
</page>
4 changes: 2 additions & 2 deletions Omikron/Factfinder/view/frontend/layout/default.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<link src="Omikron_Factfinder/webcomponentsjs/webcomponents.min.js" async="true"/>
<link src="Omikron_Factfinder/js/search-redirect.js" async="true"/>
<link src="Omikron_Factfinder/webcomponentsjs/webcomponents-lite.min.js"/>
<link src="Omikron_Factfinder/js/search-redirect.js"/>
<link rel="import" src="Omikron_Factfinder/ff-web-components/dist/elements.build_with_dependencies.html"/>
<css src="Omikron_Factfinder/::css/ff/searchbox.css"/>
<css src="Omikron_Factfinder/::css/ff/suggest.css"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<css src="Omikron_Factfinder/::css/ff/template.css"/>
<css src="Omikron_Factfinder/::css/ff/asn.css"/>
<css src="Omikron_Factfinder/::css/ff/record-list.css"/>
<css src="Omikron_Factfinder/::css/ff/recommendation.css"/>
<css src="Omikron_Factfinder/::css/ff/similar.css"/>
<css src="Omikron_Factfinder/::css/ff/breadcrumb.css"/>
<css src="Omikron_Factfinder/::css/ff/sortbox.css"/>
<css src="Omikron_Factfinder/::css/ff/paging.css"/>
Expand Down
Loading

0 comments on commit 439216c

Please sign in to comment.