0

I am currently re-writing our Magento 1 theme to work with Magento 2.1, it has been a steep learning but I am finally getting somewhere. I am trying to use the New Product Grid block on the homepage of my site, for the moment there only is one product in the database (this does cause the new product block code to run). I haven't changed the block at all and I am currently using the one that is located in the vendor/magento/theme-catalog/block/Product/newProduct.php. When I try to run the code on the home page (see below for cms_index_index.xml layout), I just get Class not found.

`<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="main">
            <container name="content.top" label="Main Content Top"/>
            <container name="content" label="Main Content Area">
                <block class="Magento\Catalog\Block\Product\NewProduct" template="Magento_Catalog::product/widget/new/content/new_grid.phtml" />
                <block class="Magento\Framework\View\Element\Template" name="info_boxes" template="Magento_Theme::info_boxes.phtml" /> 
                <block class="Magento\Framework\View\Element\Template" name="promo_boxes" template="Magento_Theme::promo_boxes.phtml" />
                <block class="Speedcrete\Manufacturers\Block\ManufacturerList" name="manufacturer.list" template="Speedcrete_Manufacturers::manufacturerList.phtml" />
            </container>
            <container name="content.aside" label="Main Content Aside"/>
            <container name="content.bottom" label="Main Content Bottom"/>
        </referenceContainer>
    </body>
</page>`

This my home page layout so far (i have overwritten this layout - this currently resides in the Magento_Theme/layouts folder in my theme dir).

The code that causes the issue is below (this bit of code is in the theme_catalog in the vendor directory):

$items = $block->getProductCollection()->getItems();

The error is as follows:
1 exception(s):
Exception #0 (ReflectionException): Class  does not exist
Exception #0 (ReflectionException): Class  does not exist
#0 /home/www/Desktop/Virtual-Hosts/Magento-2/vendor/magento/framework/Code/Reader/ClassReader.php(23): ReflectionClass->__construct(''

)

` Thanks for looking, any help would be appreciated.

1 Answer 1

0

As per as, your code

Magento\Catalog\Block\Product\NewProduct Class location should be vendor\magento\module-catalog\Block\Product\NewProduct

1
  • The NewProduct class is located in the above directory i.e. vendor\magento\module-catalog\Block\Product\NewProduct Aug 31, 2017 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.