T
T
touchilka2020-04-28 13:09:05
MySQL
touchilka, 2020-04-28 13:09:05

How to display data in a product card from a new mysql table?

People, help)))
In short, I'm making new fields for the product card, namely two multilingual fields (Question, answer)

I created a new table with the product ID, language ID and 2 columns for the question and answer.

In the admin panel in the model, controller, view everything was registered.
As a result, everything is updated, added, displayed, but it is in the admin panel (Everything is super)

Next, I need to display this in a template. And then I'm in a panic.

I copied the query from the admin model and pasted it into the catalog model

public function getProductFaq($product_id) {
    $faq_description_data = array();

    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_faq WHERE product_id = '" . (int)$product_id . "'");

    foreach ($query->rows as $result) {
      $faq_description_data[$result['language_id']] = array(
        'text'  => $result['text'],
        'ask'  => $result['ask'],
      );
    }

    return $faq_description_data;
  }


Further, I cannot formulate a query in the controller and the catalog view.

Tell me what to do? I’ve been sitting for 2 days (

And is it true that I copied the request from the admin panel model to the catalog model?) Judging by the logic, this is normal, right?)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question