I created a custom page in Open Cart and I'm kind of pulling my hair out here. What I want to do is simple: Fetch the currently selected language(possibly from the header?). I am using Opencart version 2.0.x. I am new to php and it's not my system so I'm having a really hard time figuring this out. I have tried the following code:
$lang = $this->language->get('code');
and it returns nothing. Would really appreciate the help!
Both these codes returns my language code, en:
echo $this->language->get('code');
echo $this->session->data['language'];
Related
i'm currently working on a little extension to make it possible to adopt related products of a group product on its associated products.
It work really fine, with the exception, that only the last of the 19 related product is saves and written to the database.
I've checked my source code over and over, even with my team collegue - the code seems to be correct.
In the following i've posted the snippet with the essential parts and i hope that anyone can give me a hint or an advice to solve this problem.
Best regards
Markus
$supplyList =$product->getRelatedProductIds();
$associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
$params = array();
$_associatedProduct = Mage::getModel('catalog/product');
$prodCount=0;
foreach($supplyList as $sup)
{
$params[$sup] = array('position'=>$prodCount);
$prodCount++;
}
foreach($associatedProducts as $prod)
{
$_associatedProduct
->load($prod->getId())
->setRelatedLinkData($params)
->save();
}
following an update for the problem mentioned in the first post.
Today it worked as it should, without changes made by myself or my collegue.
I'm not sure what the cause of the problem was (caches are disabled since last Monday) and the source was already correct implemented.
It works now and this post is solved, sadly without a solution.
best regards
I am using onestepcheckout.
I have added another webshop.
Now both webshops are using /app/design/frontend/base/default/template/onestepcheckout/checkout.phtml
Problems:
We have modified in the past this file but I cant fix this problem:
->. We show the question: New at hatstore? Hatstore is our shopname.
How can I make this question display dynamically?
so "New at clothesstore" is displayed when they visit our other clothingstore.
->. We have forced also in this file a url to register:
hxxp://haststore.com/webshop/customer/account/create/
How can I change this, so this will be dynamically too:
hxxp://%shopurl%/%shopstorename%/customer/account/create/
I've searched a lot but couldnt find it. Can you help me?
You can use a simple if else condition in your template file
First get the store(webshop) ID / code from magento backend from Configuration > Manage Stores.
$code = Mage::app()->getStore()->getCode();
if($code == 'hat') // suppose your store code for HATSHOP is hat.
{
echo 'question: New at hatstore?';
//anything else
}
else
{
echo 'question: New at clothstore?';
//anything else
}
Follow anz's answer. To get current store base URL
$this->getUrl('');
If need to get customer/account, then try like this
$this->getUrl('customer/account');
Good day all.
I'm developing a simple module for prestashop, the idea is to be able to setup the hreflang thing in the backoffice, and inject the code in the header of all the pages. I'm actually struck at this point:
let say I'm on a page which URL is:
http://www.server.com/en/content/8-quality
from here, I want to retrieve the URL of the same page, let's say in italian:
http://www.server.com/it/content/8-qualita
is there a way to do it without try to search this on the database? I mean, this should be work for cms pages, products, categories and so on, I would like a way to ask Prestashop:
which is the URL of the current page in a given langage?
thanks in advance.
Assuming the page you want is a cms one, in the Link.php class, you have the following function :
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null)
Juste call it with the good lang id and it's done. You can call it from smarty with
{$link->getCMSLink('quality', null, false, $id_lang)}
I am trying to add a custom link to a custom page using the vtiger_link table, with 2 parameters; 1 is the trouble ticket id which works fine:
This is in the URL field in the database:
modules/Helpdesk%20Info/index.php?ticketid=$RECORD$"target='helpdeskinfo'
and 2 is the id of the logged in user ($current_user) but it doesn't work:
modules/Helpdesk%20Info/index.php?ticketid=$RECORD$&$user=$current_user"target='helpdeskinfo'
It shows the page just as it should, but the variable $user gets the value '$current_user':
http://localhost:8888/modules/Helpdesk%20Info/index.php?ticketid=135409&$user=$current_user
I wanted to post a picture of the table, but I don't have enough reputation for that.
I have tried many things, but I am clearly doing something wrong.
Any help would be much appreciated.
I did not need to put the variable in the URL,
the reason I could not use the $current_user variable is because it didn't exist in "detailview.php" which is where the link ends up.
I used:
echo "<pre>";
print_r($GLOBALS);
echo "</pre>";
to view all globals, there I found the authenticated_user_id
Knowing I could use this I was able to access the global from my file without the URL:
$current_user = $_SESSION["authenticated_user_id"];
I would like to thank STT LCU for his advice, as he was the only one who helped me through this problem, which took me a full week in total.
For a client of mine I refactored some code that didn't work anymore. The script imports (variable) products from a CSV. That all works fine, the products and the attributes get imported and show up all complete in the backend.
The weird thing is, the products don't show up on the front-end of the website. That is, untill we save it just once from the backend (really, just pressing the save button for that product without doing anything else).
During the refactoring we found this code;
$test = new WC_Product($id);
$test->variable_product_sync();
$test = null;
This doesn't work anymore with the new WooCommerce, everything is static now. How can we implement this function now? And we are not sure this solves is though.
Ah, found it. You can dro the variable_product_sync. Make sure you set the meta _visible to 'visible' trough update_post_meta.
include_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins/woocommerce/woocommerce.php' );
$product_variable = new WC_Product_Variable($product_id);
$product_variable->sync($product_id);
wc_delete_product_transients($product_id);