Unhandled Error!

Argument 1 passed to ShopPrimaryCategory::getPrimaryBreadcrumbs() must be an instance of Shop_Product, null given, called in /var/www/vhosts/nationaltoolhireshops.co.uk/httpdocs/modules/cms/classes/cms_controller.php(383) : eval()'d code on line 7 and defined

Document /modules/shopprimarycategory/classes/shopprimarycategory.php
Document type PHP document
Line 4
Exception class Phpr_PhpException

Code Highlight

<?php
class ShopPrimaryCategory
{
    public static function getPrimaryBreadcrumbs(Shop_Product $product)
    {
        if (!$product->category_list) {
           return false;
        }
 
        $primaryBreadcrumbs = array();
 
        $productCategory = $product->category_list[0];
        if ($primaryCategory = $product->primary_category) {
# Call Stack Code Document Line
13 ShopPrimaryCategory::getPrimaryBreadcrumbs(null) /modules/cms/classes/cms_controller.php(383) : eval()'d code 7
12 eval(()) /modules/cms/classes/cms_controller.php 383
11 Cms_Controller->evalWithException('?><div class="row"> <div class="twelve columns"> <div class="cat-breadcrumbs pt4" itemscope itemtype="https://schema.org/BreadcrumbList"> <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"><a href="/" itemprop="item"><span itemprop="name">Home</span></a><meta itemprop="position" content="1" /></span> <?php $pos = 2; if ($primaryBreadcrumbs = ShopPrimaryCategory::getPrimaryBreadcrumbs($product)) : ?> <? $i=1; foreach ($primaryBreadcrumbs as $breadcrumb): ?> <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem"> &gt; <a href="<?= rtrim($breadcrumb->page_url('/category'), '/') ?>/" data-gtm="Breadcrumb (P)" itemprop="item"><span itemprop="name"><?= $breadcrumb->name ?></span></a><meta itemprop="position" content="<?php echo $pos; ?>" /> <?php if ($i < count($primaryBreadcrumbs)): ?> <span class="breadcrumb-hover"> <span> <?php if ($breadcrumb->list_children('front_end_sort_order')->count): ?> <div class="breadcrumb-category"> <?php foreach ($breadcrumb->list_children('front_end_sort_order') as $subcategory): ?> <? if(!empty($subcategory->x_catfalse)): ?> <a href="<?= $subcategory->x_catfalse ?>" title="<?= h($subcategory->name) ?>" data-gtm="Breadcrumb Pop (P)"><?= h($subcategory->name) ?></a> <? else: ?> <a href="<?= $subcategory->page_url('category') ?>/" title="<?= h($subcategory->name) ?>" data-gtm="Breadcrumb Pop (P)"><?= h($subcategory->name) ?></a> <? endif ?> <?php endforeach; ?> </div> <?php endif; ?> </span> </span> <?php else: ?> <?php if ($breadcrumb->eval_num_of_products()): ?> <span class="breadcrumb-hover"> <span> <div class="breadcrumb-category"> <p style="margin-bottom: 9px;"><strong>Top Products</strong></p> <?php $products = $breadcrumb->list_products(array('sorting'=>array('price desc')))->limit(3)->find_all(); ?> <?php foreach ($products as $breadcrumbProduct): ?> <a href="<?php echo $breadcrumbProduct->page_url('product'); ?>/" data-gtm="Breadcrumb Pop (P)"><?php echo $breadcrumbProduct->name; ?></a> <?php endforeach; ?> <a href="<?= $breadcrumb->page_url('category') ?>/">View All</a> </div> </span> </span> <?php endif; ?> <?php endif; ?> </span> <? $i++; $pos++; endforeach ?> <?php endif; ?> <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">&nbsp;>&nbsp;<span itemprop="name"><?php echo $product->name; ?></span><meta itemprop="position" content="<?php echo $pos; ?>" /></span> </div> </div> </div> <section class="content"> <? if( $product->x_bookpay == 200): ?> <section id="product" class="product top block" style="margin:15px;"> <?php $this->render_partial('shop:product3', array( 'product' => $product ), array( 'cache'=>true, 'cache_vary_by'=>array('url'), 'cache_versions'=>array('catalog'), 'cache_ttl'=>86400 )); ?> </section> <? elseif( $product->x_bookpay == 201): ?> <section id="product" class="product top block" style="margin:15px;"> <?php $this->render_partial('shop:product4', array( 'product' => $product ), array( 'cache'=>true, 'cache_vary_by'=>array('url'), 'cache_versions'=>array('catalog'), 'cache_ttl'=>86400 )); ?> </section> <? elseif( $product->x_bookpay == 202): ?> <section id="product" class="product top block" style="margin:15px;"> <?php $this->render_partial('shop:product5_2021', array( 'product' => $product ), array( 'cache'=>true, 'cache_vary_by'=>array('url'), 'cache_versions'=>array('catalog'), 'cache_ttl'=>86400 )); ?> </section> <? elseif( $product->x_bookpay == 123): ?> <section id="product" class="product top block" style="margin:15px;"> <?php $this->render_partial('shop:product_training', array( 'product' => $product ), array( 'cache'=>true, 'cache_vary_by'=>array('url'), 'cache_versions'=>array('catalog'), 'cache_ttl'=>86400 )); ?> </section> <? else: ?> <section id="product" class="product top block" style="margin:15px;"> <?php $this->render_partial('shop:product2', array( 'product' => $product ), array( 'cache'=>true, 'cache_vary_by'=>array('url'), 'cache_versions'=>array('catalog'), 'cache_ttl'=>86400 )); ?> </section> <?php endif; ?> </section> </div> </section> <?= $this->render_partial('white_diesel_modal') ?> <?= $this->render_partial('insurance_modal') ?> <?= $this->render_partial('deposit_modal') ?> <?= $this->render_partial('id_modal') ?> <?= $this->render_partial('paypal_modal') ?> <script> window.booking.form.on('booking:basket-add', function(e, items) { dataLayer.push({ 'event' : 'add_to_cart', 'ecommerce' : { 'items': items } }); }); //dataLayer = []; dataLayer.push({ 'event' : 'view_item', 'ecommerce' : { 'items': [{ 'item_id': '<?php echo $product->sku; ?>', 'item_name': '<?php echo $product->name ?>', 'price': '<?php if($product->om('is_on_sale')): ?><?php echo $product->om('sale_price'); ?><?php else: ?><?php echo $product->om('price') ?><?php endif; ?>' }] } }); </script>', 'CMS page', 'Product 2021') /modules/cms/classes/cms_controller.php 608
10 Cms_Controller->eval_page_content(()) /modules/cms/classes/cms_controller.php 198
9 Cms_Controller->open(object(Cms_Page), array(1) [0 => 'dumpy-level-for-hire']) /controllers/application.php 72
8 Application->On404(())
7 call_user_func_array(array(2) [0 => object(Application), 1 => 'On404'], array(0)) /phproad/modules/phpr/classes/phpr_controller.php 170
6 Phpr_Controller->executeAction('On404', array(0)) /phproad/modules/phpr/classes/phpr_controller.php 84
5 Phpr_Controller->_run('On404', array(0)) /phproad/modules/phpr/classes/phpr_response.php 64
4 Phpr_Response->open404(()) /phproad/modules/phpr/classes/phpr_response.php 37
3 Phpr_Response->open('/product/dumpy-level-for-hire') /phproad/system/phproad.php 31
2 include('/var/www/vhosts/nationaltoolhireshops.co.uk/httpdocs/phproad/system/phproad.php') /boot.php 114
1 require_once('/var/www/vhosts/nationaltoolhireshops.co.uk/httpdocs/boot.php') /index.php 3