how to remove advertisement in opencart admin panel - opencart

How to remove opencart Advertisement in admin panel.
Here you see the Adverisement:

In your OpenCart installation go to file
/admin/controller/extension/extension/promotion.php
and add replace this code on line 18
return $response;
with this
return '';
This will remove any promotion you see in your OpenCart admin panel.
Enjoy!

Dmitriy Zhuk's answer is the easiest to apply.
An alternative if you want the change as a mod is to use something like this:
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Hide promotions in admin panel</name>
<code>skippromotion</code>
<version>3.0x</version>
<author>TH</author>
<link>https://stackoverflow.com/questions/55702884</link>
<file path="admin/controller/extension/extension/*.php">
<!-- Remove the 'promotions' feature -->
<operation error="log">
<search><![CDATA[$data['promotion'] = $this->load->controller('extension/extension/promotion');]]></search>
<add position="replace"><![CDATA[
$data['promotion'] = '';
]]></add>
</operation>
</file>
</modification>
Save it as 'install.xml', zip it up as 'skippromotion.ocmod.zip' and upload it using the 'Installer' in the admin panel - then go to 'Modifications', enable the mod and refresh your mod cache. The ads should disappear from the admin panel.
Note that this mod works in a different way to Dmitriy Zhuk's answer, it's replacing every call to admin/controller/extension/extension/promotion.php rather than the value that script returns.
Obviously you'll need to disable the mod and change OPENCART_SERVER in your config if you ever start your own farm of OpenCart installations and want to advertise to your users.

Perhaps better yet if your're going the edit route like I did:
<?php
class ControllerExtensionExtensionPromotion extends Controller {
public function index() {
// MOD Eliminate Admin promotions - just return nothing.
// we don't need to curl anything and might make site a touch faster
return '';
}
}

Related

Opencart meta title in every page

I have a script for vqmod opencart made in this way:
<modification>
<file name="catalog/view/theme/*/template/common/header.tpl">
<operation>
<search position="replace"><![CDATA[<title><?php echo $title; ?></title>]]></search>
<add><![CDATA[<title><?php
$separator=" | ";
$store_name=$this->config->get('config_name');
if(trim($store_name)!=trim($title))
echo $title.$separator.$store_name;
else
echo $title;
?></title>]]></add>
</operation>
</file>
</modification>
I would like to show in every page not the website name (config_name), but the homepage title that is different and more complete. Moreover it is different for every language of my site. Can you help me in some way?
Thank you
thanks for the answer. I would like to add at the end of the meta title of every page (all of them, products, categories, informations etc) a string of words of my choice. For example if the title is " #productname, #category, #brand " , I want it to be " #productname, #category, #brand - #mysitename #mysitedescription". The problem is that #mysitename #mysitedescription have to be different for every language automatically.
I hope to have well explained the problem

opencart asks me to login again when i use the image manager

I've been running open cart on my server for a client, but it's acting rather strange. when we try to access the images to attach to a product, we get this this login image inside the 'image manager' pop up window. and the buttons to Rename, new folder and so on change color.
I can't seem to find anything on google, have you seen this before or have any idea if i got hacked or something happened?
I'm running version 1.5.6.3
After i click to add ANY image it adds that login segment. and I can try to log in, but I haven't tried.
This is the way it pops up first, THEN it turns into the image above.
This is the correct way it should stay.
Same problem here. It used to work properly for more than a year and it stopped working days ago, without changes or updates to my website. What hosting company are you on? I'm on Bluehost, trying to understand if they changed something...
EDIT: ok I've found a solution here: http://forum.opencart.com/viewtopic.php?f=161&t=93875&start=40
I've created a vqmod file called fix-image-manager.xml and put it in /vqmod/xml, as suggested in that post. This is the content of the file:
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>IMAGE MANAGER FIX</id>
<version>1.5.6.1</version>
<vqmver required="true">2.5.0</vqmver>
<author>OpenCart</author>
<file name="admin/view/template/common/filemanager.tpl">
<operation>
<search position="replace"><![CDATA[&token=<?php echo $token; ?>&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value'))]]></search>
<add><![CDATA[&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value'))+'&token=<?php echo $token; ?>']]></add>
</operation>
</file>
<file name="admin/view/template/catalog/*">
<operation>
<search position="replace"><![CDATA[&token=<?php echo $token; ?>&image=' + encodeURIComponent($('#' + field).attr('value'))]]></search>
<add><![CDATA[&image=' + encodeURIComponent($('#' + field).attr('value')) + '&token=<?php echo $token; ?>']]></add>
</operation>
</file>
</modification>
If you don't use vqmod, you should just edit admin/view/template/common/filemanager.tpl and change this line:
'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value')),
to this:
'index.php?route=common/filemanager/image&image=' + encodeURIComponent('data/' + $(element).find('input[name=\'image\']').attr('value'))+'&token=<?php echo $token; ?>',
and do the same thing in all the files in admin/view/template/catalog/ where the same line is present.
Apparently the &token should be the last parameter. I still can't get why it has worked properly so far and suddenly it stopped working.
I would suggest checking your tokens that are in the address bar of the iframe for the image adding screen, when the tokens are incorrect this problem happens. It is because the system looks at you as a non logged in user.
Go to the file manager page directly from your browser when you logged in to the backend to see if it exists and navigates to correctly.
index.php?route=common/filemanager
Remember to leave the token part in your address bar and just change the above
If it navigates to this page correctly then you will have to find the link to the image iframe and compare the tokens to the ones you are logged in with (see browser address). If it doesn't navigate to this page correctly then you will have to look at the coding for that specific page.

Add enclosing tag for only UnOrdered list from Rich Text Editor in UL

I need to style UL's coming from Rich Text Editor in Sitecore. I am trying to find out if there is a class that I can add to all UL's coming from Sitecore's Rich Text Editor.
Thanks in Advance
Ashok
The easiest solution is just to wrap your FieldRenderer with an HTML element with appropriate class applied in code:
<div class="rich-text">
<sc:FieldRenderer ID="frRichTextField" runat="server" FieldName="MyFieldName" />
</div>
And then add in some CSS styles to handle your UL's within this:
.rich-text ul {
/* add in your styling */
}
You can also use the before and after properties of the FieldRenderer to pass in your tag:
<sc:FieldRenderer ID="frRichTextField" runat="server" FieldName="MyFieldName"
Before="<div class='rich-text'>" After="</div>" />
EDIT:
If you wanted to be more drastic then you could add in your own renderField pipeline processor to ensure your control is always wrapped with the required tag or you could make use of the enclosingTag property and patch the AddBeforeAndAfterValues pipeline instead:
namespace MyCustom.Pipelines.RenderField
{
public class AddBeforeAndAfterValues
{
public void Process(RenderFieldArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
if (args.Before.Length > 0)
args.Result.FirstPart = args.Before + args.Result.FirstPart;
if (args.After.Length > 0)
{
RenderFieldResult result = args.Result;
string str = result.LastPart + args.After;
result.LastPart = str;
}
if (args.EnclosingTag.Length == 0 || args.Result.FirstPart.Length <= 0 && args.Result.LastPart.Length <= 0)
return;
// check if a css class paramter has been passed in
string cssClass = args.Parameters.ContainsKey("class") ? args.Parameters["class"] : String.Empty;
// add the class to the enclosing tag property
args.Result.FirstPart = StringExtensions.FormatWith("<{0} class='{1}'>{2}", (object)args.EnclosingTag, cssClass, (object)args.Result.FirstPart);
args.Result.LastPart = StringExtensions.FormatWith("{0}</{1}>", (object)args.Result.LastPart, (object)args.EnclosingTag);
}
}
}
Patch the Sitecore config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<pipelines>
<renderField>
<processor type="Sitecore.Pipelines.RenderField.GetLinkFieldValue, Sitecore.Kernel"
set:type="MyCustom.Pipelines.RenderField.AddBeforeAndAfterValues, MyCustom.Pipelines" />
</renderField>
</pipelines>
</sitecore>
</configuration>
And then call the FieldRenderer with the EnclosingTag set and pass in your class parameter:
<sc:FieldRenderer ID="frRichTextField" runat="server" FieldName="MyFieldName"
EnclosingTag="div" Parameters="class=rich-text" />
This really doesn't add much over using the before/after properties though and I would generally try to stay away from overwriting default Sitecore processors to save heartache when upgrading.
You could either tap into relevant pipelines or update your sublayouts so that you always have a fixed class around every instance of the rich text field rendering:
<div class="rtf">
<sc:Text ID="scContent" runat="server" FieldName="Content" />
</div>
You will have to make sure as a developer that all current and future instances of rich text field renderings are enclosed by a tag with this class.
You could then include in the global CSS, a common style for this class.
.rtf ul {
...
....
}
If you don't want to have to add this wrapper for every single rtf rendering, you could tap into a relevant pipeline. (Note - this might be a better approach with regard to code maintainability)
You could choose to use one of the two:
renderField pipeline
or the
saveRichTextContent pipeline
So you would add a new processor for either of these pipelines, in which you could access the text within rich text fields only and process that as you please (easier to manipulate the html using the html agility pack)
If you use renderField pipeline - the text within the rich text field in sitecore will not change, the code you write will execure only while rendering the field - in preview / page editor or normal mode.
Using saveRichTextContent pipeline on the other hand, will update the in the rich text field when the content author clicks on save (after entering the text) in content editor mode.
You can see the following examples for these:
renderField - http://techmusingz.wordpress.com/2014/05/25/unsupported-iframe-urls-in-sitecore-page-editor-mode/ (Sample of HtmlUtility is also present here - instead of selecting all tags, you could select all and add your desired class attribute.)
saveRichTextContent - http://techmusingz.wordpress.com/2014/06/14/wrapping-rich-text-value-in-paragraph-tag-in-sitecore/
Hope this helps.
Best practice would be to just add the Class to the Rich Text Editor for use in the Editor.
There are lots of good articles on doing this. Here are a couple:
http://sitecoreblog.blogspot.com/2013/11/add-css-class-to-richtext-editor.html
http://markstiles.net/Blog/2011/08/13/add-css-classes-to-sitecore-rich-text-editor.aspx
These are minimal changes that provide you with the ability to put the styling ability in the hands of the Content Author, but still controlling what styles and classes they can use inline.

Opencart how to add php code to product/category description

Does anyone know how to, without purchasing an addon/extension, add php code to the product and category descriptions? If you try to add it automatically gets commented out when you save, e.g. <!-- <?php echo "test" ?> -->
Workaround: For anyone else.. I used borderless iframe to include an external .php file which contained the php code I needed ....

Magento Product_List_Crosssell

The Crosssells do not seem to be working on my Magento EE install, for the product view page.
Ive debugged the product list crosssells block, but seems to crash out somewhere on its way through the various code, whilst collecting the collection. Cant work out why (whitescreens when debug to a certain level...and item collection thus not being set. Hard to figure out. No exceptions being logged).
I have no errors on the install...and sure i should not need to edit any logic, as the functionality is provided by default.
Ive followed this example:
http://www.magentocommerce.com/boards/viewthread/51529/
My crossells show on the cart page, as they usually do...but i cant get them to display on my product view page.
Heres my bits of code:
Catalog.xml:
<block type="catalog/product_list_crosssell" name="product.info.crosssell" as="crosssell_products" template="catalog/product/list/crosssell.phtml"/>
product/list/crosssell.phtml:
if(count($this->getItems())): ?>
<div id="also_bought_productslist" class="inner">
<?php $i=0;
foreach ($this->getItems() as $product):
Anyone know what i may be missing. And has anyone added crossells to their product view page?
Just to clarify...THIS IS USING THE DEFAULT PRODUCT_LIST_CROSSELL block...and im NOT trying to utilise the checkout/cart/crossell code (i know this relies on cart functionality/data to work correctly. I did attempt this though, and still get no crossell items....but they DO show in the cart page.)
many thanks
Syntax within the catalog xml file. Namely, an AFTER="blahblah" declaration...and use of same block code twice
Old code:
<block type="catalog/product_list_crosssell" name="product.info.crosssell" as="crosssell_products" template="catalog/product/list/crosssell.phtml"/>
<block type="catalog/product_list_related" name="alsoboughttabs" after="forgettoaddproducts" template="pagetabs/alsobought_pagetabs.phtml" />
<block type="catalog/product_list_related" name="forgettoaddproducts" after="product.info" template="catalog/product/list/dontforgettoadd.phtml" />
New code:
<block type="catalog/product_list_crosssell" name="product.info.crosssell" as="crosssell_products" template="catalog/product/list/crosssell.phtml"/>
<block type="catalog/product_list_upsell" name="alsoboughttabs" template="pagetabs/alsobought_pagetabs.phtml" />
<block type="catalog/product_list_related" name="forgettoaddproducts" after="product.info" template="catalog/product/list/dontforgettoadd.phtml" />