As for Star Wars, again if I'm not mistaken, it was originally pitched to 20th Century Fox by Lucas in a way where the toy sales would help to increase profits so the marketing existed in the franchise before the first movie was released. Plus, all movies are items meant to be marketed. Though I would guess that marketing was less important to Lucas than art in those days. Maybe.
As for Star Wars, again if I'm not mistaken, it was originally pitched to 20th Century Fox by Lucas in a way where the toy sales would help to increase profits so the marketing existed in the franchise before the first movie was released. Plus, all movies are items meant to be marketed. Though I would guess that marketing was less important to Lucas than art in those days. Maybe.