PHP Controllers - 2 (addons)

An addon is just another controller.

From our previous discussion, a controller is instantiated via a dispatch URL like:

for the ‘pages’ controller. If you had an addon called ‘movies’ and you wanted it to behave the same as pages, then it would be invoked as:

YourStore | Search Engine Optimization For eCommerce Brands

Which would invoke the ‘view’ mode of the movies controller with the identifier for the movie of 123

Or for some admin activity:

Which would let you manage the pages you have on your system.

As distributed, cs-cart provides an empty addon called my_changes. It is located in the addons/my_changes directory. If you tried to do anything with it as a controller it will fail because there are no modes associated with it.

So rather than mess with my_changes, we’re going to create a new addon called ‘movies’. We are going to add a field to the products tabled called ‘is_movie’ that will have a single character value that will be ‘Y’ or ‘N’ indicating whether the product is a movie or not. We will also create a block that will display only movies that are in stock and available. The movies will also be able to be ‘bulk managed’ in that the ‘is_movie’ field will be selectable in the product details page and the edit multiple product details page.

None of this will modify any standard code or software that is installed by cs-cart.

The first step in all of this is (like any good software project) developing a set of requirements. Our requirements will be:

  • Ability to identify a product as a movie
  • Ability to mark the movie as available or not
  • show the customer all the movies that are in stock (to a maximum number) in a standard “block”

    I will create zip files that can be downloaded as we move through the process of developing our addon. It will incrementally add functionality and features and the final one should be our movie addon.

    This is what we’re going to do so stay tuned and when I have some more time, we’ll get started.

Where this topic continues?

I found PHP Controllers 4 but where is the 3rd one??

Thank you very much for all this help!