Post by xinxilas » Wed May 02, 2018 9:16 am

Hello friends

How can i get data from another, preventing using twice same scripts?

For example, im making a simple module which needs to get some datas from category
In this case: Category Description, and total products...

I already made it, named category2:

Code: Select all

		$this->load->language('extension/module/category2');
		
		if (isset($this->request->get['path'])) {
			$path = '';
			$parts = explode('_', (string)$this->request->get['path']);

			$category_id = (int)array_pop($parts);
			foreach ($parts as $path_id) {
				if (!$path) {
					$path = (int)$path_id;
				} else {
					$path .= '_' . (int)$path_id;
				}
				$category_info = $this->model_catalog_category->getCategory($path_id);
			}
		} else {
			$category_id = 0;
		}
		
		$category_info = $this->model_catalog_category->getCategory($category_id);
		if ($category_info) {
			$data['heading_title'] = $category_info['name'];
			$this->document->setDescription($category_info['meta_description']);
			$data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8');
			
	
			$filter_data = array(
				'filter_category_id' => $category_id,
			);
			
			$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
			$data['product_total'] = $product_total;
			
		}

		return $this->load->view('extension/module/category2', $data);
	}
But the whole script is already made on (catalog/controller/common/category.php), how can i get product_total and description directly from category.php to use on my category2.twig file?

Pleease any help?

New member

Posts

Joined
Mon Apr 27, 2015 7:46 am

Post by OSWorX » Mon May 07, 2018 3:59 am

xinxilas wrote:
Wed May 02, 2018 9:16 am
Pleease any help?
Not here, because how many time syou want to post the same question??

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Administrator

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: No registered users and 6 guests