Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nordcomputer committed Jul 13, 2020
0 parents commit 7585f39
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace Nordcomputer\Showoutofstockprice\Model\ConfigurableProduct\ResourceModel\Product;

use Magento\Framework\DB\Select;

class StockStatusBaseSelectProcessor extends \Magento\ConfigurableProduct\Model\ResourceModel\Product\StockStatusBaseSelectProcessor
{
public function process(Select $select)
{
return $select;
}
}
?>
27 changes: 27 additions & 0 deletions Model/ResourceModel/Product/CompositeBaseSelectProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace Nordcomputer\Showoutofstockprice\Model\ResourceModel\Product;

use Magento\CatalogInventory\Model\ResourceModel\Product\StockStatusBaseSelectProcessor;

class CompositeBaseSelectProcessor extends \Magento\Catalog\Model\ResourceModel\Product\CompositeBaseSelectProcessor
{
public function __construct(
array $baseSelectProcessors
) {


// REMOVE THE STOCK STATUS PROCESSOR
//...................................
$finalProcessors = array();
foreach ($baseSelectProcessors as $baseSelectProcessor) {
if(!is_a($baseSelectProcessor, StockStatusBaseSelectProcessor::class)) {
$finalProcessors[] = $baseSelectProcessor;
}
}

parent::__construct($finalProcessors);
}

}

?>
27 changes: 27 additions & 0 deletions Pricing/Render/FinalPriceBox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace Nordcomputer\Showoutofstockprice\Pricing\Render;

use Magento\Framework\Pricing\Render\PriceBox as BasePriceBox;

class FinalPriceBox extends \Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox
{
protected function _toHtml()
{
$result = BasePriceBox::_toHtml();
//Renders MSRP in case it is enabled
if ($this->isMsrpPriceApplicable()) {
/** @var BasePriceBox $msrpBlock */
$msrpBlock = $this->rendererPool->createPriceRender(
MsrpPrice::PRICE_CODE,
$this->getSaleableItem(),
[
'real_price_html' => $result,
'zone' => $this->getZone(),
]
);
$result = $msrpBlock->toHtml();
}

return $this->wrapResult($result);
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# nordcomputer-showoutofstockprice
Show prices of out-of-stock products
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "nordcomputer/showoutofstockprice",
"description": "Adds price to out-of-stock products",
"require": {
"php": "^7.1"
},
"type": "magento2-module",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Nordcomputer\\Showoutofstockprice\\": ""
}
}
}
9 changes: 9 additions & 0 deletions etc/frontend/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox" type="Nordcomputer\Showoutofstockprice\Pricing\Render\FinalPriceBox" />
<type name="Magento\ConfigurableProduct\Model\ResourceModel\Product\LinkedProductSelectBuilder">
<arguments>
<argument name="baseSelectProcessor" xsi:type="object">Nordcomputer\Showoutofstockprice\Model\ConfigurableProduct\ResourceModel\Product\StockStatusBaseSelectProcessor</argument>
</arguments>
</type>
</config>
5 changes: 5 additions & 0 deletions etc/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Nordcomputer_Showoutofstockprice" setup_version="0.0.1">
</module>
</config>
6 changes: 6 additions & 0 deletions registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Nordcomputer_Showoutofstockprice',
__DIR__
);

0 comments on commit 7585f39

Please sign in to comment.