Skip to content
Code-Schnipsel Gruppen Projekte
Commit 5c7b907e erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

feat: setting -> display stock in products

feat: show stock field if quiqqer/stock-management is installed
Übergeordneter adb5e6f5
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -263,6 +263,10 @@
</locale>
<!-- template settings -->
<locale name="settings.shop.showStock">
<de><![CDATA[Lagerbestand bei Produkt-Details anzeigen]]></de>
<en><![CDATA[Show stock in product details]]></en>
</locale>
<locale name="settings.menu.title">
<de><![CDATA[Template Cologne Einstellungen]]></de>
<en><![CDATA[Template Cologne Settings]]></en>
......
......@@ -60,6 +60,11 @@
{if $ShippingTimeFrontendView}
{$ShippingTimeFrontendView->create()}
{/if}
{assign var=StockFrontendView value=\QUI\TemplateCologne\Utils::getStockFrontendView($Product->getId())}
{if $StockFrontendView}
{$StockFrontendView->create()}
{/if}
</div>
<div class="product-data-actionButtons">
......
......@@ -25,6 +25,10 @@
<type><![CDATA[bool]]></type>
<defaultvalue>0</defaultvalue>
</conf>
<conf name="showStock">
<type><![CDATA[bool]]></type>
<defaultvalue>1</defaultvalue>
</conf>
<!-- header -->
<conf name="headerStartPage">
......@@ -270,6 +274,14 @@
/>
</text>
</input>
<input conf="templateCologne.settings.showStock" type="checkbox">
<text>
<locale group="quiqqer/template-cologne"
var="settings.shop.showStock"
/>
</text>
</input>
</settings>
<!-- header -->
......
......@@ -8,6 +8,7 @@
use QUI;
use QUI\ERP\Shipping\Shipping;
use QUI\ERP\StockManagement\StockManager;
/**
* Class Utils
......@@ -414,12 +415,22 @@ private static function getPredefinedFooter($Project)
*/
public static function getShippingTimeFrontendView(int $productId)
{
try {
$Product = QUI\ERP\Products\Handler\Products::getProduct($productId);
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return false;
}
if (QUI::getPackageManager()->isInstalled('quiqqer/stock-management')) {
return StockManager::getShippingTimeFrontendViewByProduct($Product);
}
if (!QUI::getPackageManager()->isInstalled('quiqqer/shipping')) {
return false;
}
try {
$Product = QUI\ERP\Products\Handler\Products::getProduct($productId);
$ShippingField = $Product->getField(Shipping::PRODUCT_FIELD_SHIPPING_TIME);
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
......@@ -428,4 +439,45 @@ public static function getShippingTimeFrontendView(int $productId)
return $ShippingField->getFrontendView();
}
/**
* Get FrontendView of DeliveryTime field
*
* requires quiqqer/stock-management to be installed
*
* @param int $productId
* @return false|QUI\ERP\Products\Field\View
*/
public static function getStockFrontendView(int $productId)
{
try {
$Project = QUI::getRewrite()->getProject();
$showStock = $Project->getConfig('templateCologne.settings.showStock');
if (empty($showStock)) {
return false;
}
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return false;
}
if (!QUI::getPackageManager()->isInstalled('quiqqer/stock-management')) {
return false;
}
try {
$Product = QUI\ERP\Products\Handler\Products::getProduct($productId);
$StockField = $Product->getField(StockManager::PRODUCT_FIELD_STOCK);
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return false;
}
/** @var QUI\ERP\StockManagement\Products\Fields\StockView $StockView */
$StockView = $StockField->getFrontendView();
$StockView->setProduct($Product);
return $StockView;
}
}
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren