1

I have a product in the database that was created using an extension installed on a previous magento (1.6.2) installation (to the one I am running currently - 1.9.2). The extension is no longer in use, and has not been added to the new system. All relevant data (products, sales, accounts, etc etc etc) was ported over from magento 1.6.2 to my shiny new 1.9.2 installation. Unfortunately, I forgot about the product created with this extension (a booking product). And as that extension is no longer part of my system, any time it crops up, it causes a site error.

This error happens in the admin and on the front end. The error is to do with a missing product type in the database

(Invalid backend model specified: booking/entity_attribute_backend_rangetype).

Which I take to mean there is no reference in the database for a "booking" product type, because the extension isn't installed to add that info to the system.

Looking at the catalog_... tables, I can find the EAV entity ID of the product in question, but wondered if there was an easier way to remove all references to that entity ID from all database tables other than trawling through them all one by one and manually removing the rows?

I created a script to loop through the products in order to try and delete them that way, the following is the meat of that script:

Once I have the collection created, I loop through it (there are 2 products of this type in total), but the system fails to delete the products. Here is the code for the loop through...

foreach ($collection as $product) {
    $thisProductID = $product->getId();

    try {
        $product = Mage::getModel("catalog/product")->load($thisProductID);
        if ($product) {
            $product->delete();
            echo '<p>'.$thisProductID.' - Deleted successfully'.'</p>'; 
        }
    }
    catch (Exception $e) {
        echo '<p>'.$thisProductID.' - Delete failed: ', $e->getMessage(), '</p>'; 
    }

}

And here is my output when I run this:

25712 - Delete failed: Invalid backend model specified: booking/entity_attribute_backend_rangetype

25713 - Delete failed: Invalid backend model specified: booking/entity_attribute_backend_rangetype

I'm really not sure how to get around this, as I do not want to install a module for the sake of these two products being in the database (and crashing the website if they get browsed frontend or admin).

Any suggestions more than welcome :-)

2
  • 1
    You can delete from catalog_product_entity all products that you want delete.
    – osrecio
    May 9, 2016 at 15:39
  • 1
    Doesn't it matter that attributes are left behind in other tables doing it this way? I would have hoped a delete here would cascade, but it seems not to do that?
    – robgt
    May 9, 2016 at 15:59

2 Answers 2

1

Using delete() function,delete an product object's from database is better way.

As per as,your share, whenever you have try to delete product using this function then get error message

Delete failed: Invalid backend model specified: booking/entity_attribute_backend_rangetype

So, if you will resolve this issue then you will again delete the product using delete() that will better idea.

Let resolve invalid backend model specified:

This error occur when your system have an attribute and that attribute backend model is booking/entity_attribute_backend_rangetype and that backend model class has already delete from system.

So if we delete this attribute then $product->delete(),will work properly.

So run this query:

DELETE FROM `eav_attribute` WHERE `backend_model`='booking/entity_attribute_backend_rangetype'

Note: Before do this take a full backup of database

Now run your code $product->delete(); and see what happen

1
  • Thanks Amit, for the great explanation of why it didn't work, and then how to fix the issue! Greatly appreciated!! :-)
    – robgt
    May 11, 2016 at 15:36
0

check this table eav_attribute & search

(booking/entity_attribute_backend_rangetype) in backend model column. if you found then delete this row.

1
  • Please see the above solution...
    – robgt
    Jun 1, 2016 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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