@ihavetheair

Как вывести свой массив в товаре opencart?

Добрый день! Нужно вывести поле в админку опенкарт(в товар), с возможностью добавлять бесконечное кол. таких полей (то бишь сделать массив). Вопрос в том, как это сделать с точки зрения php?
Вывожу поля таким образом:

<file path="catalog/controller/product/product.php">
        <operation error="log">
			<search>
				<![CDATA[
					$data['points'] = $product_info['points'];
				]]>
			</search>
			<add position="after"><![CDATA[
					$data['features'] = html_entity_decode($product_info['features'], ENT_QUOTES, 'UTF-8');
					$data['specifications'] = html_entity_decode($product_info['specifications'], ENT_QUOTES, 'UTF-8');
					$data['documentations'] = html_entity_decode($product_info['documentations'], ENT_QUOTES, 'UTF-8');
					$data['href_product'] = $product_info['href_product'];
					$data['instructions'] = html_entity_decode($product_info['instructions'], ENT_QUOTES, 'UTF-8');
				]]>
			</add>
		</operation>
</file>

<file path="catalog/model/catalog/product.php">
        <operation error="log">
			<search>
				<![CDATA[
					'name'             => $query->row['name'],
				]]>
			</search>
			<add position="after"><![CDATA[
					'features'             => $query->row['features'],
					'specifications'             => $query->row['specifications'],
					'documentations'             => $query->row['documentations'],
					'href_product'             => $query->row['href_product'],
					'instructions'                 => $query->row['instructions'],
				]]>
			</add>
		</operation>
	</file>
<file path="admin/model/catalog/product.php">
        <operation error="log">
			<search>
				<![CDATA[
					model = '" . $this->db->escape($data['model']) . "',
				]]>
			</search>
			<add position="replace"><![CDATA[
					model = '" . $this->db->escape($data['model']) . "', specifications = '" . $this->db->escape($data['specifications']) . "', features = '" . $this->db->escape($data['features']) . "', documentations = '" . $this->db->escape($data['documentations']) . "', href_product = '" . $this->db->escape($data['href_product']) . "', instructions = '" . $this->db->escape($data['instructions']) . "',
				]]>
			</add>
		</operation>
		<operation>
			<search index="0" error="skip"><![CDATA[
				public function getProducts($data = array()) {
			]]></search>
			<add position="after" ><![CDATA[
				$exist = $this->db->query("SHOW COLUMNS FROM `" . DB_PREFIX . "product` WHERE Field = 'features'");
				if (count($exist->row) == 0) {
					$this->db->query("ALTER TABLE `" . DB_PREFIX . "product` 
					ADD COLUMN `features` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
					ADD COLUMN `specifications` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
					ADD COLUMN `documentations` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
					ADD COLUMN `href_product` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
					ADD COLUMN `instructions` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
				");
				}
			]]></add>
		</operation>
	</file>
<file path="admin/controller/catalog/product.php">
        <operation error="log">
			<search>
				<![CDATA[
					if (isset($this->request->post['model'])) {
				]]>
			</search>
			<add position="before"><![CDATA[
					if (isset($this->request->post['features'])) {
						$data['features'] = $this->request->post['features'];
					} elseif (!empty($product_info)) {
						$data['features'] = $product_info['features'];
					} else {
						$data['features'] = '';
					}
					if (isset($this->request->post['specifications'])) {
						$data['specifications'] = $this->request->post['specifications'];
					} elseif (!empty($product_info)) {
						$data['specifications'] = $product_info['specifications'];
					} else {
						$data['specifications'] = '';
					}
					if (isset($this->request->post['documentations'])) {
						$data['documentations'] = $this->request->post['documentations'];
					} elseif (!empty($product_info)) {
						$data['documentations'] = $product_info['documentations'];
					} else {
						$data['documentations'] = '';
					}
					if (isset($this->request->post['instructions'])) {
						$data['instructions'] = $this->request->post['instructions'];
					} elseif (!empty($product_info)) {
						$data['instructions'] = $product_info['instructions'];
					} else {
						$data['instructions'] = '';
					}
					if (isset($this->request->post['href_product'])) {
						$data['href_product'] = $this->request->post['href_product'];
					} elseif (!empty($product_info)) {
						$data['href_product'] = $product_info['href_product'];
					} else {
						$data['href_product'] = '';
					}
				]]>
			</add>
		</operation>
	</file>


Соответственно, как сделать возможность добавления массива? href_product[0][name], href_product[0][href]
  • Вопрос задан
  • 398 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы