[SalesForce] Error: Entity is not api accessible at line 1 column 1

trigger Stage on Opportunity (After insert, After update) {

    for (opportunity opp : trigger.new) {
        if (opp.StageName = 'Closed won') {
            for ( product pro: trigger.new) {
                pro.Available_for_lease__c = FALSE;
            }


        }
    }


}

I'm new to apex and i need to update the value of a checkbox in the object "room" if the stage is set to closed won which is in the opportunity object.

Best Answer

You are trying to access the Product object which isn't available - Product2 is the type you need.

There is a problem with trying to access the Product(2) items by using the trigger.new collection - it will be a collection of Opportunities not Products...