I freshly started working on Magento 2 using Cloudways hosting services.
I wanted to add my first product today but after adding it, I faced HTTP ERROR 500.
You can see it at : https://www.supplyarmy.com/us-t-shirt.html
Here is my Apache Error Log:
*[Wed Nov 06 14:12:04.004860 2019] [proxy_fcgi:error] [pid 11166] [client 127.0.0.1:54952] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function getData() on null in /home/321257.cloudwaysapps.com/amukgacefe/public_html/app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view/details.phtml:18\nStack trace:\n#0 /home/321257.cloudwaysapps.com/amukgacefe/public_html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include()\n#1 /home/321257.cloudwaysapps.com/amukgacefe/public_html/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Catalog\Block\Product\View\Details), '/home/321257.cl...', Array)\n#2 /home/321257.cloudwaysapps.com/amukgacefe/public_html/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template->fetchView('/home/321257.cl...')\n#3 /home/321257.cloudwaysapps.com/amukgacefe/public_html/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template->_toHtml()\n#4 /home/321257.cloudwaysapps.com/amukga...\n',
referer: https://www.supplyarmy.com/vetements.html
I am a bit lost and tried couple things but it did not work.
Any assistance would be much appreciated.
PS: I use Magento ver. 2.3.1
Edit: Here is my details files as requested.
I changed some of the code based on this thread:
Uncaught Error: Call to a member function getData() on null
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php if ($detailedInfoGroup = $block->getGroupChildNames('detailed_info', 'getChildHtml')):?>
<?php
$porto_helper = $this->helper('Smartwave\Porto\Helper\Data');
$_helper = $this->helper('Smartwave\Porto\Helper\Customtabs');
$product_config = $porto_helper->getConfig('porto_settings/product');
$static_block_tab = $product_config['custom_block_next_tab'];
$custom_block = $this->getLayout()->createBlock('Magento\Cms\Block\Block');
$_product = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Registry::class)->registry('product');
$page_type = $_product->getData('product_page_type');
if(!$page_type)
$page_type = isset($_config['product_page_type'])?$_config['product_page_type']:'';
if($custom_block) {
$custom_block->setBlockId($static_block_tab);
}
$tab_style = "";
if(isset($product_config['tab_style']) && $product_config['tab_style'])
$tab_style = $product_config['tab_style'];
if($page_type == 'wide_grid')
$tab_style = 'vertical';
?>
<?php if($product_config['tab_full_background']):?>
<div class="move-product-tab">
<div class="row">
<div class="<?php if(!$page_type && $custom_block && $static_block_tab):?>col-md-9<?php else:?>col-md-12<?php endif;?>">
<?php endif;?>
<div class="product info detailed <?php echo $tab_style; ?> <?php if($page_type == 'sticky_right'): ?>fullwidth-row<?php endif; ?>">
<?php $layout = $block->getLayout(); ?>
<?php if(!$tab_style || $tab_style != "sticky"): ?>
<div class="product data items <?php if($page_type == 'sticky_right'): ?>container<?php endif; ?>" data-mage-init='{"tabs":{"openedState":"active"}}'>
<?php foreach ($detailedInfoGroup as $name):?>
<?php
$html = $layout->renderElement($name);
if (!trim($html)) {
continue;
}
$alias = $layout->getElementAlias($name);
$label = $block->getChildData($alias, 'title');
?>
<div class="data item title"
aria-labeledby="tab-label-<?php /* @escapeNotVerified */ echo $alias;?>-title"
data-role="collapsible" id="tab-label-<?php /* @escapeNotVerified */ echo $alias;?>">
<a class="data switch"
tabindex="-1"
data-toggle="switch"
href="#<?php /* @escapeNotVerified */ echo $alias; ?>"
id="tab-label-<?php /* @escapeNotVerified */ echo $alias;?>-title">
<span><?php /* @escapeNotVerified */ echo $label; ?></span>
</a>
</div>
<div class="data item content" id="<?php /* @escapeNotVerified */ echo $alias; ?>" data-role="content">
<?php /* @escapeNotVerified */ echo $html; ?>
</div>
<?php endforeach;?>
<?php
if($custom_cms_tabs = $_helper->getCustomTabs($_product())) {
$i = 1;
foreach($custom_cms_tabs as $_item) {
?>
<div class="data item title"
aria-labeledby="tab-label-<?php /* @escapeNotVerified */ echo "custom-".$i;?>-title"
data-role="collapsible" id="tab-label-<?php /* @escapeNotVerified */ echo "custom-".$i;?>">
<a class="data switch"
tabindex="-1"
data-toggle="switch"
href="#<?php /* @escapeNotVerified */ echo "custom-".$i; ?>"
id="tab-label-<?php /* @escapeNotVerified */ echo "custom-".$i;?>-title">
<span><?php /* @escapeNotVerified */ echo $_item['tab_title']; ?></span>
</a>
</div>
<div class="data item content" id="<?php /* @escapeNotVerified */ echo "custom-".$i; ?>" data-role="content">
<?php /* @escapeNotVerified */ echo $_item['tab_content']; ?>
</div>
<?php
$i++;
}
}
?>
</div>
<?php elseif($tab_style && $tab_style == "sticky"): ?>
<div class="product data items">
<?php foreach ($detailedInfoGroup as $name):?>
<?php
$html = $layout->renderElement($name);
if (!trim($html)) {
continue;
}
$alias = $layout->getElementAlias($name);
$label = $block->getChildData($alias, 'title');
$alias = str_replace(".","_",$alias);
?>
<div class="data item title">
<a class="data switch" href="#<?php /* @escapeNotVerified */ echo $alias; ?>">
<?php /* @escapeNotVerified */ echo $label; ?>
</a>
</div>
<?php endforeach;?>
<?php
if($custom_cms_tabs = $_helper->getCustomTabs($_product())) {
$i = 1;
foreach($custom_cms_tabs as $_item) {
?>
<div class="data item title">
<a class="data switch" href="#<?php /* @escapeNotVerified */ echo "custom-".$i; ?>">
<?php /* @escapeNotVerified */ echo $_item['tab_title']; ?>
</a>
</div>
<?php
$i++;
}
}
?>
<?php foreach ($detailedInfoGroup as $name):?>
<?php
$html = $layout->renderElement($name);
if (!trim($html)) {
continue;
}
$alias = $layout->getElementAlias($name);
$label = $block->getChildData($alias, 'title');
$alias = str_replace(".","_",$alias);
?>
<div class="data item content" id="<?php /* @escapeNotVerified */ echo $alias; ?>">
<?php /* @escapeNotVerified */ echo $html; ?>
</div>
<?php endforeach;?>
<?php
if($custom_cms_tabs = $_helper->getCustomTabs($_product())) {
$i = 1;
foreach($custom_cms_tabs as $_item) {
?>
<div class="data item content" id="<?php /* @escapeNotVerified */ echo "custom-".$i; ?>">
<?php /* @escapeNotVerified */ echo $_item['tab_content']; ?>
</div>
<?php
$i++;
}
}
?>
</div>
<?php endif; ?>
<script type="text/javascript">
require([
'jquery'
], function ($) {
$(document).ready(function(){
<?php if($tab_style && $tab_style == "vertical"): ?>
$(".product.info.detailed.vertical .product.data.items .data.item.title").off("classadded").on("classadded",function(){
$(this).parent().css("min-height",$(this).next().outerHeight()+"px");
});
<?php elseif($tab_style && $tab_style == "sticky"): ?>
var sticky_tabs;
var is_sticky = false;
$(window).scroll(function(){
if($(window).scrollTop() >= $(".product.info.detailed").offset().top-50){
if(!is_sticky){
$(".product.info.detailed.sticky").before('<div class="product-tabs-container"><div class="container"></div></div>');
$(".product.info.detailed.sticky .product.data.items > .item.title").each(function(){
$(".product-tabs-container > .container").append($(this).clone().detach());
});
$(".product-tabs-container .item.title > a").off("click").on("click", function(){
$($(this).attr("href")).scrollToMe();
return false;
});
<?php if ($porto_helper->getConfig('porto_settings/header/sticky_header')): ?>
$(".product-tabs-container").addClass("has-sticky-header");
<?php endif; ?>
<?php if ($porto_helper->getConfig('porto_settings/header/mobile_sticky_header')): ?>
$(".product-tabs-container").addClass("has-mobile-sticky-header");
<?php endif; ?>
is_sticky = true;
}
} else {
$(".product-tabs-container").remove();
is_sticky = false;
}
});
$(".product.info.detailed.sticky .product.data.items > .item.title > a").off("click").on("click", function(){
$($(this).attr("href")).scrollToMe();
return false;
});
$(".product-reviews-summary .reviews-actions a.action.view").off("click").on("click", function(){
$("#reviews").scrollToMe();
return false;
});
$(".product-reviews-summary .reviews-actions a.action.add").off("click").on("click", function(){
$("#review-form").scrollToMe();
return false;
});
<?php endif; ?>
});
});
</script>
</div>
<?php if($product_config['tab_full_background']):?>
</div>
<?php if(!$page_type && $custom_block && $static_block_tab):?>
<div class="col-md-3">
<div class="custom-block-tab">
<?php echo $custom_block->toHtml(); ?>
</div>
</div>
<?php endif;?>
</div>
</div>
<?php endif;?>
<?php endif; ?>
After applying the fixes, I do not have an HTTP 500 ERROR anymore. However, the product page fails to display its content properly.
Edit 2: Here is the new error from my apache error log file:
[Thu Nov 07 07:46:19.254058 2019] [proxy_fcgi:error] [pid 2258] [client 127.0.0.1:37799] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Function name must be a string in /home/321257.cloudwaysapps.com/amukgacefe/public_html/app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view/details.phtml:65\nStack trace:\n#0 /home/321257.cloudwaysapps.com/amukgacefe/public_html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include()\n#1 /home/321257.cloudwaysapps.com/amukgacefe/public_html/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Catalog\Block\Product\View\Details), '/home/321257.cl...', Array)\n#2 /home/321257.cloudwaysapps.com/amukgacefe/public_html/vendor/magento/framework/View/Element/Template.php(301): Magento\Framework\View\Element\Template->fetchView('/home/321257.cl...')\n#3 /home/321257.cloudwaysapps.com/amukgacefe/public_html/vendor/magento/framework/View/Element/AbstractBlock.php(668): Magento\Framework\View\Element\Template->_toHtml()\n#4 /home/321257.cloudwaysapps.com/amukgacefe/public_h...\n'
Sincerely, Toomas Goutt