private function to_category(\Classes\Opencart\Product $product) { $category = new Category(); if ($this->post_to_last_category) { $product->category = array_slice($product->category, -1, 1, true); } foreach ($product->category as $id => $name) { $category->add_product($product->{$this->id_field}, $id); } }