The story
Probably from a practice attributed to door-to-door salesmen of placing a foot in the opening of a prospective customer's door, thereby preventing the person from closing the door until the conclusion of the sales pitch.
Etymology from Wiktionary, CC BY-SA 4.0.