Skip to content

Commit

Permalink
Solved Issue 'Stickers not showing up in new products widget #5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Fantetti aka WaPoNe committed Dec 14, 2017
1 parent ad6e99b commit 092ae14
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
48 changes: 48 additions & 0 deletions Plugin/Catalog/NewWidget/StickersPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* WaPoNe
*
* @category WaPoNe
* @package WaPoNe_Stickers
* @copyright Copyright (c) 2017 WaPoNe (http://www.fantetti.net)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

namespace WaPoNe\Stickers\Plugin\Catalog\NewWidget;

class StickersPlugin extends \WaPoNe\Stickers\Model\Stickers
{
const DISCOUNT_ACTIVATION = "stickers/stickers_page/discount_activation";

protected $_productFactory;
protected $_scopeConfig;

public function __construct(
\Magento\Catalog\Model\ProductFactory $productFactory,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
) {
$this->_productFactory = $productFactory;
$this->_scopeConfig = $scopeConfig;
}

public function beforeGetProductPriceHtml(
\Magento\Catalog\Block\Product\Widget\NewWidget $list,
\Magento\Catalog\Model\Product $product,
$priceType = null,
$renderZone = \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST,
array $arguments = []
) {
$this->_product = $product;
}

public function afterGetProductPriceHtml(
\Magento\Catalog\Block\Product\Widget\NewWidget $list, $result
) {
if($this->isStickerActive(self::DISCOUNT_ACTIVATION)) {
$result .= $this->_setDiscountStickerHTML();
}

return $result;
}

}
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "wapone/module-stickers",
"description": "Product Discount Stickers for Magento 2",
"require": {
"php": "~5.6.0|~7.0.0|~7.1.0",
"psr/log": "*"
},
"type": "magento2-module",
"version": "0.0.3",
"version": "0.0.4",
"license": [
"proprietary"
"OSL-3.0",
"AFL-3.0"
],
"require": {
"magento/framework": "100.0.*|100.1.*|101.0.*",
"wapone/base": "*"
},
"authors": [
{
"name": "WaPoNe",
Expand Down
4 changes: 4 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<plugin name="WaPoNe_WidgetStickersPlugin"
type="WaPoNe\Stickers\Plugin\Catalog\Widget\StickersPlugin" />
</type>
<type name="Magento\Catalog\Block\Product\Widget\NewWidget">
<plugin name="WaPoNe_NewWidgetStickersPlugin"
type="WaPoNe\Stickers\Plugin\Catalog\NewWidget\StickersPlugin" />
</type>
<!--type name="Magento\Catalog\Block\Product\ListProduct">
<plugin name="WaPoNe_CategoryStickersPlugin" type="WaPoNe\Stickers\Plugin\CategoryStickersPlugin"/>
</type-->
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="WaPoNe_Stickers"
setup_version="0.0.3">
setup_version="0.0.4">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
Expand Down

0 comments on commit 092ae14

Please sign in to comment.