1

first of all, I am absolutely new to Magento. I want to put a Magento installation in catalog mode.

Is it possible to disable all add to cart buttons, the cart, and the checkout?

I bought a theme and I don't know where to start.

Read about disabling Mage_Checkout but I don't have a configuration button under "System"

Please anybody help...

Thank you in Advance.

1 Answer 1

0

To disable add to cart you just need to return false in isSalable method in the Magento\Catalog\Model\Product class. So, You can write an after plugin for this method. Please follow these steps below to create a small module.

app/code/MilanDev/DisableCart/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'MilanDev_DisableCart',
    __DIR__
);

app/code/MilanDev/DisableCart/etc/module.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="MilanDev_DisableCart" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Catalog"/>
        </sequence>
    </module>
</config>

app/code/MilanDev/DisableCart/etc/di.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Model\Product">
        <plugin disabled="false" name="MilanDev_DisableCart_Plugin_Magento_Catalog_Model_Product" sortOrder="10" type="MilanDev\DisableCart\Plugin\Magento\Catalog\Model\Product"/>
    </type>
</config>

app/code/MilanDev/DisableCart/Plugin/Magento/Catalog/Model/Product.php

<?php
namespace MilanDev\DisableCart\Plugin\Magento\Catalog\Model;

class Product
{

    public function afterIsSalable(
        \Magento\Catalog\Model\Product $subject,
        $result
    ) {
        return false;
    }
}
3
  • Thank you, i created all the Files and folders. How do i activate the Module? Sorry for the lack of knowledge. Do i have to do this via ssh? Thank you for your help.
    – KNN
    Commented Jan 16, 2019 at 8:21
  • go to magento root folder using comand line and run the following command: php bin/magento module:enable MilanDev_DisableCart -c && php bin/magento setup:upgrade && php bin/magento setup:di:compile && php bin/magento cache:flush Commented Jan 16, 2019 at 8:27
  • getting: Deprecated Functionality: The each() function is deprecated. This message will b e suppressed on further calls in /www/htdocs/w018f7f2/rossbach/vendor/colinmolle nhour/cache-backend-file/File.php on line 81
    – KNN
    Commented Jan 16, 2019 at 8:45

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.