E
E
Eugene Simon2019-08-16 15:09:07
opencart
Eugene Simon, 2019-08-16 15:09:07

How to get and display all existing tags in product_form?

Hello. Just don't throw rocks at me for a stupid question. I learn php while working with opencart and now I faced the task of displaying all existing product tags in the admin panel under the tag input field. I believe that this should be done through foreach, but I don’t know how. In this way, I get tags that are in the product where I am $product_description[$language['language_id']]['tag'] , but I don’t understand how to get everything. Please guide me on the right path...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2019-08-16
@Eridani

foreach($product_description[$language['language_id']]['tag'] as $tag) {
echo $tag;
}

Z
zoozag, 2019-08-19
@zoozag

Something like this method can be used:

public function getTags() {
  $tags = array();

  $query = $this->db->query("SELECT tag FROM " . DB_PREFIX . "producte_description WHERE tag != ''");

  foreach ($query->rows as $row) {
    $row_tags = explode(',', $row['tag']);
    foreach ($row_tags as $tag) {
      $tags[] = trim($tag);
    }
  }
  $tags = array_unique($tags);
  return $tags;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question