OpenCart PHP unexpected T_DOUBLE_ARROW - opencart

I'm getting this error when I try to go to my site. The last thing I did was uninstall one blog extension and installed a new one.
Error:
Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/mcflipp/public_html/vqmod/vqcache/vq2-catalog_controller_common_header.php on line 341
The code on that line is:
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
'id' => $category['category_id']. '_' . $child['category_id'],
And the code that matches in the catalog/controller/common/header.php is:
$children_data[] = array(
'name' => $child['name'],
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
'id' => $category['category_id']. '_' . $child['category_id'],
'children_level_2' => $children_data_level_2,
);
The syntax looks correct to me, so I'm not sure what needs to be changed. I appreciate any help!

Well, looking at your code, I can see a problem in this part of the file:
// Level 1
$this->data['categories'][] = array(
'name' => $category['name'],
'children' => $children_data,
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
}
}
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
'id' => $category['category_id']. '_' . $child['category_id'],
'children_level_2' => $children_data_level_2,
);
}
This one looks like incorrect vQmod replacement/addition to a file... Either you have applied a version of extension that does not support your version of OC or you have made some manual changes to the file that vQmod is trying to inject. It could be also possible that the extensions itself is malfunctioning. Check the vQmod XML file for this extension and identify the piece that is responsible for this concrete injection.
Hint: using an advanced PHP IDE can help to point to basic PHP syntax errors (e.g. like this above) by highlighting and marking the erroneous place in red (I am using NetBeans for example).

Related

WP_Query meta_query REGEXP

I am pretty much below beginner level for REGEX/REGEXP and have hit a blocking point in a project I am working in, where I am trying to get the ids for posts that match the search criteria , but I want to restrict the search between 2 sub-strings. I am trying to figure out is how to write the REGEXP in the meta_query:
$args = array(
'post_type'=> 'custom',
'order' => 'DESC',
'posts_per_page' => 10,
'paged' => $page,
'meta_query' => array(
array(
'key' => 'key',
'value' => "title*".$search."*_title",
'compare' => 'REGEXP',
)
),
);
And an example of the field in the DB :
a:302:{s:5:"title";s:10:"Test title";s:6:"_title";s:19:"
Unfortunately none of the combinations I tried based on documentation of SQL REGEXP won't return any values and I am trying to understand how I can pull this off and would appreciate any input.
Also would rather stick to WP_Query for now even though an SQL LIKE "%title%{$search}%_title%" works perfectly , so an alternative solution would be how to set the compare to 'LIKE' and parse it '%' since that is not possible out of the box as the % get escaped I believe.

Opencart full category ul li tree

Right now in opencart the system is limited to only showing 2 levels of categories. Does anyone know of a class to get all sub-categories and a full ul li tree?
For example: If you have ever used oscommerce it will show the full tree of sub-cats in the side category menu where as opencart is limited to only two levels.
The default code is like
$categories = $this->model_catalog_category->getCategories(0);
foreach ($categories as $category) {
$children_data = array();
if ($category['category_id'] == $data['category_id']) {
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach($children as $child) {
$filter_data = array('filter_category_id' => $child['category_id'], 'filter_sub_category' => true);
$children_data[] = array(
'category_id' => $child['category_id'],
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
}
However it only goes two levels, I am looking for all levels to build out an accordion menu.
Further I am not looking for someone to do this, (unless you want), but maybe you can point me in the right direction or to an existing class that will achieve this.
You'll need to add each sub-level manually for a 3rd, for a 4th etc. There is no way to just get all of them in one shot.
There was an older stackoverflow thread with a solution on how to add a 3rd level. Perhaps it will work with your version of OC:
get third level category in opencart 2
You basically will need to edit the controller and tpl files for category. If that's too much for you, they sell an extension on their marketplace for it, too.

Opencart 1.5.5.1 how change link in admin order

opencart 1.5.5.1 how change on normal link? See on picture http://i.imgur.com/H9krDbT.jpg
link in administration order to edit items (admin/index.php?route=catalog/product/update&token=4d93b21563db6a6c5fe44b7c365c210b&product_id=54), this is bad, how change on normal link (index.php?route=product/product&product_id=54)
$action = array();
$action = array(
'text' => [[Pass_text_value]],
'href' => $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . [[Pass_product_id_here]] . $url, 'SSL')
);
See this is the only way you should pass actions like EDIT from the controller to template. The whole link will not be displayed but only the passed text.
If you are passing more than one instances to template then put these whole code inside your foreach loop and change $action = array( to $action[] = array(.

doctrine 2 returns errror 'proxy directory must be writable'

i am using doctrine 2 with Zendframework 2
i am trying to return an object but keep getting this error:
Your proxy directory must be writable
this is my query:
$this->getEntityManager()
->getRepository('Messages\Entity\Messages')
->findOneBy(array('id' => 6,
'receiverId' => 16
));
However, the same query return an array without any problems re:
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select(array('u'))
->from('Messages\Entity\Messages','u')
->where('u.id = :id')
->andWhere('u.receiverUserId = :receiverId')
->setParameter('receiverId',16)
->setParameter('id',(int)6);
$query = $qb->getQuery();
return $data = $query->getArrayResult();
If you are using Setup::createAnnotationMetadataConfiguration you can simply fix it by
Create the following directory in your project root. data/DoctrineORMModule/Proxy
chmod -R 755 data/DoctrineORMModule/Proxy
In your bootstrap include the path to the data directory as in:
Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/src/models"), $this->isDevMode, "data/DoctrineORMModule/Proxy")
That fixed it for me.
Proxies are simple classes which extends your actual entities and used internally by doctrine to hydrate associations of your entities by lazy-loading them. Doctrine decides to use or not to use a proxy instances on runtime for different situations and it really depends on your queries and associations in your entities. You may want to read about this subject in-depth at official documentation.
In your case, doctrine trying to generate a proxy class for your Messages entity but your proxy directory is simply not writable as error output's said.
This seems like misconfiguration of DoctineModule. (Assuming that you are using DoctrineORMModule to integrate doctrine with ZF2) Doctrine needs a writeable directory to put that generated proxy classes. For ZF2's view, data directory on application root perfectly fits for this requirement.
Make sure existence of the line below in your public/index.php:
chdir(dirname(__DIR__));
and try to use a configuration like this:
<?php
/**
* module/Application/config/module.config.php
*/
return array(
'router' => array(
// ...
),
// ...
'doctrine' => array(
'driver' => array(
//...
),
/**
* Generating proxies on runtime and using array cache instead of apc(u)
* greatly reduces the performance. So, you may want to override
* this settings on production environment.
*/
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'hydration_cache' => 'array',
'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy',
'proxy_namespace' => 'DoctrineORMModule\Proxy',
),
),
)
);
If you are using Fedora 24, enter the following commands:
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/YOUR_SITE/data';
restorecon -v '/var/www/html/YOUR_SITE/data'
With this, you are changing the label of the /var/www/html and giving write permission to httpd.

Can Netbeans use regex to make my own 'format code' functions?

I was searching for a function, or a 'format code' function in NetBeans to format my arrays in PHP in a proper way.
E.g.:
$arr1 = array('allow',' => array('index', 'admin', 'view', 'create', 'update', 'delete'),' => array('#'),), array('deny', 'users' => array('*'),);
^^ Is quite hard to read. So if there would be a function to search for:
everytime there is a array( followed by ' replace it with an array(\n'.
or
everytime there is ,\s'\w+' followed by => replace ,\s' with ,\s\n'
Does anyone know if there is a plugin for that? (Btw, I'm not a star in regex so I'm just looking for the array() format problem.)