alt text

I can not figure out how he does it. Conducted the following experiment:

  1. Took a snapshot of the db
  2. Added some images to product card
  3. Compare the state of the database before and after.

Only 1 table has changed - #__virtuemart_medias. It is logical to assume that it contains all the information necessary to determine whether images belong to a particular product. However, I do not see in it a single field suitable for this purpose, that is, nothing that could identify a product. Here are her fields:

virtuemart_media_id int(11) virtuemart_vendor_id smallint(11) file_title char(126) file_description char(254) file_meta char(254) file_mimetype char(64) file_type char(32) file_url varchar(1800) file_url_thumb char(254) file_is_product_image tinyint(1) file_is_downloadable tinyint(1) file_is_forSale tinyint(1) file_params varchar(19000) shared tinyint(1) published tinyint(1) created_on datetime created_by int(11) modified_on datetime modified_by int(11) locked_on datetime locked_by int(11) 

Does anyone know - HOW?

    2 answers 2

    Judging from the tayo structure $ db = JFactory :: getDBO (); $ query = "SELECT file_url_thumb FROM virtuemart_medias where virtuemart_media_id = (SELECT virtuemart_media_id FROM virtuemart_product_medias WHERE virtuemart_product_id = '". $ id. "' LIMIT 1) LIMIT 1"; $ db-> setQuery ($ query); $ result = $ db-> query (); $ row = $ db-> loadAssoc (); echo $ row ['file_url_thumb'];

    I can assume that you are not looking at all the fields in the table, as there is just a need for the field virtuemart_product_id, I can also assume that you are looking at the list of fields in some phpmyadmin and there is just a page there.

    • See the picture attached to the description. I have Virtuemart 2.08. - srgg67
    • I have virtuemart 2.08. If you, too, go to the table and look at its structure (there is hardly any need to THINK - just check it). - srgg67
    • CREATE TABLE IF NOT EXISTS #__virtuemart_product_medias ( id INT (11) UNSIGNED NOT NULL AUTO_INCREMENT, virtuemart_product_id int (1) UNSIGNED NOT NULL DEFAULT '0', virtuemart_media_id int (1) UNSIGNED NOT NULL DEFA ' NULL DEFAULT '0', PRIMARY KEY ( id ), UNIQUE KEY i_virtuemart_category_id ( virtuemart_product_id , virtuemart_media_id )) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 1; There is a lot of a lot to do, through the label __virtuemart_product_medias - binliz
    • (not% 20provided)! [alt text] is this your snapshot? - binliz

    Well, how-how - a new line is created in the _virtuemart_medias table, where the file name is written, the line gets a new virtuemart_media_id. Further, in the _virtuemart_product_medias table, a new row is also created, where virtuemart_media_id and virtuemart_product_id fit in - so clear? And so for each picture. Those. Matching is aids. And one more nuance that can disrupt the work of this request: I noticed that if the file_url field is always and definitely filled in, then the file_url_thumb field is filled depending on the user’s settings in the admin area of ​​the store, i.e. not uniquely. This is often the case when this field file_url_thumb is NULL!