template for category page OpenCart 2.2.0.0 - opencart2.x

I would ask for a little help
I would like to create another template for my three categories (category ID 119 / ID 125 / ID 140).
I found one solution for version 2.2.0.0.
find $this->response->setOutput($this->load->view('product/category', $data));
in catalog/controller/product/category.php
and replace it with above codes, here is:
$config_theme = $this->config->get('config_theme') == 'theme_default' ? 'default' : $this->config->get('config_theme'); if (file_exists(DIR_TEMPLATE . $config_theme . '/template/product/category_' . $category_id . '.tpl')) {
$view = 'product/category_' . $category_id;
} else {
$view = 'product/category';
}
$this->response->setOutput($this->load->view($view, $data));
I created category_119 however, it does not work. I tried to complete this code but nothing works
perhaps I have to complete code by:
* entering the name of my new template (category_bezkoszyka or category_119) = but I do not know exactly where to sign
* enter the category ID (119/125/140) = = but I do not know exactly where to sign
* probably enter the name of my template - although I have default - (Default (Default Store Theme)
Link to the solution:
<https://stackoverflow.com/questions/40755573/specific-template-for-category-and-product-page-in-opencart-2-2-0-0/53498989#53498989>
Information:
* opencart 2.2.0.0.
* my new temple category = category_bezkoszyka
* Id category to change = 119 / 125 / 140
* I have a standard theme: Default (Default Store Theme)
How to enter correctly, because I try but it fails.
Thank you for your help
Best Regards. Adam.

Related

Display Dedicated IP into clientareainvoices.tpl list in WHMCS?

I'm using WHMCS 8.x and Smarty PHP is already enabled.
I hope to use some code or hook function to let the dedicated ip or hostname to display on the page clientareainvoices.tpl (/clientarea.php?action=invoices) list .
I hope anyone can help me with this .
Thanks alot .
I have search a lot of plan , but all not working . I don't know whether this can be done with hook .
Hope someone of genius can help me about this .
the function like this in the picture .
enter image description here
thanks thanks thanks.
I tried to use a hook file to do this . and tried to connect the database tables use left join . like :
the file is like :
select * from tblinvoices t1
left join tblinvoiceitems t2 on t1.id=t2.invoiceid
left join tblhosting t3 on t2.relid=t3.id
WHERE t3.dedicatedIP = value
And I add this into the hook file .
<?php
if (!defined("WHMCS")) {
die("This file cannot be accessed directly");
}
use WHMCS\Database\Capsule as DB;
add_hook('ClientAreaPageInvoices', 1, function($vars) {
$invoices = DB::table('tblinvoices')->where('invoicenum', $vars['invoicenum'])->get();
$fieldId = 'invoicenum';
$csVals = [];
foreach ($invoices as $invoice) {
$fieldVal = '';
$data = DB::table('tblinvoices AS t1')
->leftJoin('tblinvoiceitems AS t2', 't1.invoicenum', '=', 't2.invoiceid')
->leftJoin('tblhosting AS t3', 't2.relid', '=', 't3.id')
->select('t3.domain')
->where('t1.invoicenum', $fieldId)->where('t3.domain', $invoice['invoicenum'])
->first();
if (!is_null($data)) {
$fieldVal = $data->value;
}
$csVals[$invoice['invoicenum']] = $fieldVal;
}
return ['domain' => $csVals];
});
But all not working for this . it shows a result "Array" , hope anybody can hlep me . thanks in advance .
First you don't need to query invoices again, since the invoices are available in $vars['invoices'] variable.
$invoices = $vars['invoices'];
The code should work, you just need to edit the file clientareainvoices.tpl in your active template and replace:
<td>{$invoice.invoicenum}</td> with
<td>{$invoice.invoicenum} - {$domain[$invoice.invoicenum]}</td>

how to get number of user in a group from active directory

I am trying to get number of user from a particular group?so how can i achieve?
Use the same approach, you did with groups ... Please find an example below.Add any properties like givenname, sn etc...
foreach(var group in froups){
DirectorySearcher ds = new DirectorySearcher(de, "(objectClass=person)");
ds.Filter = "(memberOf=CN=" + group + ",OU=Distribution Groups,DC=" + domain + ",DC=com)";
}

Magento 2 pagination is not working in join with product collection and custom table

$page=($this->getRequest()->getParam('p'))? $this->getRequest()->getParam('p') : 1;
$pageSize=($this->getRequest()->getParam('limit'))? $this->getRequest()->getParam('limit') : 4;
$collection = $this->productcollection->create()->addAttributeToSelect(array('group_name','name','status'));
$collection->addAttributeToFilter('status',1);
$collection->getSelect()
->join(['firmware_product' => $collection->getTable('firmware_product')],'firmware_product.product_id = e.entity_id',[]);
$collection->getSelect()
->join(['firmware' => $collection->getTable('firmware')],'firmware.entity_id = firmware_product.firmware_id',[])
->columns(array("firmware.version_no","firmware.build_date","firmware.is_active"));
$collection->getSelect()->where("firmware.is_active = ?",1);
$collection->getSelect()->order('firmware.entity_id', 'DESC');
$collection->setPageSize($pageSize);$collection->setCurPage($page);
The code above gives me the same entity_id as already exists. I reset the column and fetch only the firmware records and it still gives me the same error in the firmware entity_id. If I use this code
$collection->getSelect()->group('e.entity_id');
then the pagination does not work. Can anyone tell me what the solution for this is?

Extends Shopware Models

I need to extend Shopware variants models in order to add some custom attributes such as the type of metal,the type of stone a jewel, which is the base article.
These attributes will be used both in backend and frontend.
How can I do that? Thanks
Extending the Shopware core model itself is not possible at all. Depending on what specific model you are trying to extend there would be two different ways for some workaround:
If its the article itself that you want to extend you could use the custom attribute fields as described here: http://community.shopware.com/Anlegen,-Anpassen-und-Ausgabe-von-Artikel-Attributen_detail_1208.html
Another way would be to write a plugin where you create attribute fields by code on plugin install(). This is only possible on entities that do have an attribute table which belongs to the entity itself. For example s_order and s_order_attributes
For the second way create a method in your plugin's Bootstrap.php like the following and call the method in the plugin's install() method:
public function installOrderAttributes()
{
Shopware()->Models()->addAttribute(
's_order_attributes',
'ordermod',
'Random1',
'DECIMAL(12,4)',
false,
0.0000);
Shopware()->Models()->addAttribute(
's_order_attributes',
'ordermod',
'Random2',
'DECIMAL(12,4)',
false,
0.0000);
$metaDataCacheDoctrine = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
$metaDataCacheDoctrine->deleteAll();
Shopware()->Models()->generateAttributeModels(array('s_order_attributes'));
}
The addAttribute() function in /engine/Shopware/Components/Model/ModelManager.php has the following signature:
/**
* Shopware helper function to extend an attribute table.
*
* #param string $table Full table name. Example: "s_user_attributes"
* #param string $prefix Column prefix. The prefix and column parameter will be the column name. Example: "swag".
* #param string $column The column name
* #param string $type Full type declaration. Example: "VARCHAR( 5 )" / "DECIMAL( 10, 2 )"
* #param bool $nullable Allow null property
* #param null $default Default value of the column
* #throws \InvalidArgumentException
*/
public function addAttribute($table, $prefix, $column, $type, $nullable = true, $default = null);
Hope this will help.
Kind regards!

Opencart: how to change item price when adding it into the cart

I am trying to implement a functionality in opencart where it will be possible to enter a custom price at the product page via text area and when item is added to the cart if custom price entered it will apply the price specified in the custom price field.
Similar question was asked here someone kindly provided a good solution which applies to OpenCart 1.5.x. However I have tried to follow this approach on OpenCart 2 without any success. I have checked everything over and over for the last few days but I don't seem to be able to get this working as I am a newbie in programming world
I wondering if anyone is able to point me to right direction to what I may be missing.
I have search the web but unable to find any relevant information
I have checked and noticed that AJAX request is changed to #product div in 2.x, so I have enter my price input within this div underneath the quantity
<input name="custom_price" id="custom_price" value="" title="custom_price" class="input-text custom_price" type="textarea">
I have than moved on to the controller checkout/cart/add within the Add() method I have added this code
if(isset($this->request->post['custom_price'])) {
$custom_price = $this->request->post['custom_price'];
} else {
$custom_price = false;
}
Further down, I have changed this line
$this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $option, $recurring_id);
to:
$this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $option, $custom_price, $recurring_id);
Next, in the system/library/cart.php I have change the definition of the Add() method to the following
public function add($product_id, $qty = 1, $option = array(), $recurring_id = 0, $custom_price = false) {
Before the end of the Add()method I have added the following
if($custom_price) {
if(!isset($this->session->data['cart']['custom_price'])) {
$this->session->data['cart']['custom_price'] = array();
}
$this->session->data['cart']['custom_price'][$key] = $custom_price;
}
Within the GetProduct() I have added these lines
if(isset($this->session->data['cart']['custom_price'][$key])) {
$price = $this->session->data['cart']['custom_price'][$key];
}
right after this line:
$price = $product_query->row['price'];
Finally at after the array where product price is set to price + option price
'price' => ($price + $option_price),
I have added the following
if(isset($this->session->data['custom_price'][$key])) {
$this->data[$key]['price'] = $this->session->data['custom_price'][$key];
}

Resources