cancel
Showing results for 
Search instead for 
Did you mean: 

Using data from the DB in a file

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Using data from the DB in a file

Hi there, 

 

I am trying to put a, depending on product, text, before the price.

I have made an attribute called "soort" via admin

i found the file which displays the price it is called default.phtml (duh) and lives in

magento/module-catalog/view/base/templates/product/price/amount/

 

I can display TEXT before the price via an echo 'text' however i want it to be data from the product.

 

I copied echo $block->getDisplayValue(); and placed it elsewhere in the file and it displayed the price again (Woot!)

so i thought ; lets do the same with soort

echo $block->getsoort();      BEEP X WRONG not displaying anything

okay lets try something it knows; like Sku

echo $block->getSku();       BEEP X WRONG not displaying anything

 

So the file Knows the price, but doesn't know the sku ? argh!

 

Do i need to fetch it from somewhere or do i need to tell something to send it to the file?

 

following is the file default.html

 

<?php /** @var \Magento\Framework\Pricing\Render\Amount $block */ ?>

 

<?php //** SANDBOX PART below **//?>

<?php echo 'Verhuurprijs' //** Shows the tekst verhuur before price **//?>
<?php //** echo $block->getDisplayValue(); ** Shows the price before the price **//?>
<?php //** echo $block->getDisplayCurrencyCode(); ** dShows EUR before the price ?>
<?php echo $block->getAtsoort_verhuur_verkoop(); ?>  
<?php echo $block->getAtsoort(); ?> 
<?php echo $block->getAtPriceDisplayLabel(); ?>
<?php echo $block->getAtDisplayLabel(); ?>
<?php echo $block->getAtSku(); ?>

 <?php //**SANDBOX PART ABOVE **//?>

 

<span class="price-container <?php /* @escapeNotVerified */ echo $block->getAdjustmentCssClasses() ?>"
<?php echo $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
<span class="price-label"><?php /* @escapeNotVerified */ echo $block->getDisplayLabel(); ?></span>
<?php endif; ?>
<span <?php if ($block->getPriceId()): ?> id="<?php /* @escapeNotVerified */ echo $block->getPriceId() ?>"<?php endif;?>
<?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
data-price-amount="<?php /* @escapeNotVerified */ echo $block->getDisplayValue(); ?>"
data-price-type="<?php /* @escapeNotVerified */ echo $block->getPriceType(); ?>"
class="price-wrapper <?php /* @escapeNotVerified */ echo $block->getPriceWrapperCss(); ?>"
<?php echo $block->getSchema() ? ' itemprop="price"' : '' ?>>
<?php /* @escapeNotVerified */ echo $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
<?php echo '<font size=0.2>/ Periode</font>'?>
</span>
<?php if ($block->hasAdjustmentsHtml()): ?>
<?php echo $block->getAdjustmentsHtml() ?>
<?php endif; ?>
<?php if ($block->getSchema()): ?>
<meta itemprop="priceCurrency" content="<?php /* @escapeNotVerified */ echo $block->getDisplayCurrencyCode()?>" />
<?php endif; ?>
</span>

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Using data from the DB in a file

https://mage2.pro/t/topic/202 gave me the answer how to use the data from the database anywhere.

View solution in original post

2 REPLIES 2

Re: Using data from the DB in a file

Ah just did see that this is the sandbox part where i changed getAt , this was GetDisplay and didn't do anything too

Re: Using data from the DB in a file

https://mage2.pro/t/topic/202 gave me the answer how to use the data from the database anywhere.