Creating a new editable region in opencart - opencart

Ive created/hard coded an extra section of information to the product page template in opencart, but this isn't ideal, so I need to link this section to the admin so that the information contained can be edited on a per product basis from within the admin interface.
What would I need to go about doing to achieve this?

There's a fair bit to do but not that onerous, in short (assuming it is an additional description):
Add a new field to the database (probably on the product_description table);
Add the new language variables to the language file:
../admin/language/english/catalog/product.php
Add the new description/field to the template:
../admin/view/template/catalog/product_form.tpl
Add the variable definitions/post code etc to the controller file:
../admin/controller/catalog/product.php
Edit the database queries to include the new field (at least Add, edit and delete functions:
../admin/model/catalog/product.php
If it is a description based field then if you search those files for 'description' and then replicate the code, substituting for your new field name, that should do it.

Related

Django/Wagtail - Dynamically generate choices based on uploaded document

I am trying to implement a Chart Block in Wagtail where a user can upload a spreadsheet via the DocumentChooserPanel and then a chart is generated based on the data in that spreadsheet.
I currently have it functioning, but the user must explicitly specify the variable they want the chart to be based off of:
class ChartBlock(blocks.StructBlock):
data_file = DocumentChooserBlock()
primary_variable = blocks.CharBlock(required=True,max_length=255)
class Meta:
template = 'dataviz/blocks/Chart.html'
icon = 'cogs'
label = 'Chart'
I was wondering if there is any way to have the primary_variable field dynamically populated with the column headers from the spreadsheet uploaded and stored in Documents - so that the user would be able to choose from a list of available variables instead of having to remember what a variable was called.
Thank you so much!
This wouldn't be easy to achieve with a vanilla implementation of Wagtail.
The page edit form is generated on page load, including the population of choice lists. I'm pretty sure that the same is true of choice lists in StreamField blocks, that they are populated as the block is added.
The code for this hangs between wagtailadmin.edit_handlers, wagtailadmin.views.pages and wagtailcore.blocks. It would be a pretty complex customisation.
Another possible route for investigation would be using the insert_editor_js hook to update the primary_variable field once a document was uploaded. However, I'm not sure you'll find a dependable ID to hang an event listener off of.
However, you will soon be able to custom validate the submitted page. A PR has just been submitted to allow this custom validation. That should reduce the amount of user error when adding the primary_variable.
This feature should be available in Wagtail 1.4, which I believe is due for release pretty soon.
I hope that helps.

Item to be bucketed according to a date field when created

I have created a content item at /sitecore/Home/FootballFever/Articles and have given insert option so that we can add only items of templates "Article".As of now,these article items are bucketable according to a field created date.
Now, i have insert option "Add Article" and "Insert from Template" buttons in the Home ribbon "Insert" block. When i create an item through "Insert from Template", the item automatically gets added in respective bucket with path as created date. for example if the item has created date is "7/21/2014" then path will be "/Articles/2014/7/21/ ".
But when i click on "Add Article", the item gets added in /Articles and i have to Sync everytime to get it to correct path.
How can I have the same behavior as that of "Insert from Template" but with path having Release date which is a field of template "Article"?
Please make sure that Article template has Bucketable field checked in its Standard values (for Article template).
If not, when you add a new item into buckets folder, newly added item itself is not bucketable, unlike the rest already existing items from the same bucket folder.
I have just made a proof of concept on my sandbox environment and can confirm that in case you add a new item with Bucketable checked by Standard values - it comes into a bucket straight away and you do not need to perform Sync.
Hope this helps.
UPDATE: I have written a blog post specially to cover your question,with comprehensive description.
http://blog.martinmiles.net/post/understanding-buckets-adding-new-items-to-buckets-correctly
By default, items will be structured in bucket folders, five levels deep based on the date and time the item was created. There are a couple of other built in rules you can use like using part of the Guid or part of the name. The thing to note here is that these are all things that are available on item creation. If you want to structure your articles based on a custom 'Release Date' then you will need to write a custom rule and you will also have to implement an OnItemSaved event handler. Here is a article on how to write the custom rule.
Generally you don't have to worry about how the items are structured in your bucket. Editors should be using the search tab to find the items they need.
Having said that, this SO post discusses how to structure your bucket items based on a custom field. Some things to note here is that this is generally a global change. There are ways around it that enables you to have different strategies for different buckets but you'll then have to do additional work to override the LinkProvider and potentially other things.

How to add default field names in Portia scrapy drop down list?

I have downloaded Portia from (https://github.com/scrapinghub/portia) and installed Portia in my windows machine, while start Portia I can able to annotate the page.
I can able to select the fields and add name as I needed using create new option.
My question is how can we add default Fields names, so that instead of typing the name I shall be able select it from drop down box, and also it would be generic.
for example,
In the drop down i need list of field names like,
JobTitle,
JobDescription,
JobLocation
Can anyone help me, how to add the filed names by default instead of create new option.
Thanks in advance.
When you create a new field it will be available within the dropdown the next time you want to use it. You will only need to type it once.
If you would like to define your item, add fields and specify if they are required or if they vary, you can do so by opening the 'Extracted Item' tab and clicking on 'Edit Item'. This will allow you to add many fields at once without having to use create new while annotating.
To move an item between projects you can copy the items.json file from one project to another which will make all of the items from that project available in the new project.

Displaying options and add to cart on category page - opencart

I am using Opencart v1.5.1.3.1
I want to be able to create a template which certain categories use. Cat1 would use the normal category.tpl file where cat2 would use category-cart.tpl
The category-cart.tpl would have extra functionality of displaying price options and an add to cart button which would normally only work on the products.tpl page.
I know that in order to make this happen I have to modify the category.php controller for category.tpl file.
The question is what do I change in the category.php controller to make this happen?
Add product with options to cart from category page http://www.opencart.com/index.php?route=extension/extension/info&extension_id=8649
You will need to make more changes than can be listed here, so you will need to familiarize yourself with the opencart framework to do what you want. As a starter if you look at the bottom of the category controller you will see what template is loaded. Do a search for template. You could put a if statement here that loads templates based on the value of the selected category.
You will then need to add more code to the controller which loads variables for price options and add to cart.
http://opencart-help.com/modifications/39-add-product-options-to-category-listing-in-opencart.html
Check the above link and you will find out how to show the options
It should then look like this
http://i38.tinypic.com/j7b60k.jpg

osCommerce - How to add dynamic text in the bottom of the category page?

I'm using CRE Loaded v6.2 B2B. It is a modified script of osCommerce.
In category page i see all the products with pagination. I want to add some dynamic text under each category. Text is unique for each category.
I should able to define the text from admin and it should display bottom of the category.
How to do this?
I mean which file i should edit? Is there any documentation available?
Thanks
There are many ways to achieve this. Probably the easiest is to add an extra text field in the category_description table. Then simply follow the trail of the category creation/editing/deleting process and add that field in the admin next to the other ones. Then you will be able to output the text dynamically on the front end of the store.
I have not used CRE Loaded in a long time, but this solution should still work.
I take it you mean to add the text in the categories listing?
There are two ways to do this, one is by editing the index.php and pulling in the category description as a blurb.
There other is to use CDS (content director system) in B2B to create custom page category listings which support blurbs and images and use the URL override to point to your product categories.