public function uninstall()

in Setup/Uninstall.php [51:97]


    public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->getConnection()->dropTable('facebook_business_extension_config');
        $setup->getConnection()->delete('core_config_data', "path LIKE 'facebook/%'");

        $eavSetup = $this->eavSetupFactory->create();
        $productTypeId = $eavSetup->getEntityTypeId(Product::ENTITY);
        $categoryTypeId = $eavSetup->getEntityTypeId(Category::ENTITY);

        // delete "google_product_category" product attribute if installed by this extension
        if ($eavSetup->getAttributeId(Product::ENTITY, 'google_product_category')) {
            /** @var Attribute $attribute */
            $attribute = $eavSetup->getAttribute($productTypeId, 'google_product_category');
            if (isset($attribute['source_model']) && $attribute['source_model'] === GoogleProductCategory::class) {
                $eavSetup->removeAttribute($productTypeId, 'google_product_category');
            }
        }

        // delete product attributes based on configuration
        $attributesConfig = $this->productAttributes->getAttributesConfig();
        foreach ($attributesConfig as $attrCode => $config) {
            if ($eavSetup->getAttributeId(Product::ENTITY, $attrCode)) {
                $eavSetup->removeAttribute($productTypeId, $attrCode);
            }
        }

        // delete unit price attributes if exist
        if (method_exists($this->productAttributes, 'getUnitPriceAttributesConfig')) {
            $attributesConfig = $this->productAttributes->getUnitPriceAttributesConfig();
            foreach ($attributesConfig as $attrCode => $config) {
                if ($eavSetup->getAttributeId(Product::ENTITY, $attrCode)) {
                    $eavSetup->removeAttribute($productTypeId, $attrCode);
                }
            }
        }

        // delete "Facebook Attribute Group" from all product attribute sets
        $setup->getConnection()->delete(
            'eav_attribute_group',
            ['attribute_group_name = ?' => $this->productAttributes->getAttributeGroupName()]
        );

        // delete "sync_to_facebook_catalog category" attribute
        if ($eavSetup->getAttributeId(Category::ENTITY, 'sync_to_facebook_catalog')) {
            $eavSetup->removeAttribute($categoryTypeId, 'sync_to_facebook_catalog');
        }
    }