Grails - 2 domains and 1 form create/update/edit issues - grails-orm

Having some mega frustration set in.Maybe Im trying grails too much like rails and active record.
I have 2 domains.The parent is called 'report' and the child 'category'.
The user creates a new report and if they like they can add a category. The report can only have one category. However I would like to allow reports to be sorted by category or listed by category or even counted by category. Yes this column could go into the reports domain but I would like separation for future cases. so below I have my domains;
Domain 1 = Report
class Report
string reportname
string reportype
Domain 2 = category
class Category
Report report
string categoryname
I have 2 controllers, 1 for report 1 for category both with crud methods and no scaffold.
How do I set the view to create/edit/update the category domain while in the report _form?
I have read through the gorm docs, grails docs, others but still am stumbling on this.
Do I need to edit my report controller to handle the category domain? i.e import category and supply category def with each method for /edit/update/create.
Do I need to edit the report form to get the report params and pass this into a hidden field for the category name field so that when a save action is called the category domain commits the cat name and reportId.
Is my model all wrong? I have tried hasone, hasmany belongsto however I need to keep the category separate from the reports because I want to be able to show a page of reports separated by categories and allow only unique category names for a bunch of reports to reduce spelling mistakes in category names. i.e. I want to set a category name and associate it to a report.
New to grails so forgive me. Maybe I need to sit and have a beer and read more.
cheers

There are many ways to handle your scenario. One way to do this is to use redirect in your ReportController and pass in the params to CategoryController.

Related

Add sub categories under categories in shop page

I want to know if that possible to have :
1 section with main categories + 1 section with sub categories under
That mean : I click on 1 category > the sub-category section show all sub-categories of the category.
Natively you can setup the native Category Tree Links module to always show the full
category tree in a single block (with expandable sub-categories of course) despite the context category you are visiting, like follows :
If you want to create two separate blocks, you'll need to heavily modify the module logic.

CSV Imported categories not listed in PrestaShop Catolog->Categories

I am using PrestaShop Version 1.6.1.4.
I have created a CSV for Categories and uploaded it successfully but the catogories and the sub-categories are not shown in Catolog->Categories. When I configure a Module "Top Horizontal Menu" in that under Available items Categories can be seen and added to UI as well. When I click on the category in UI 404 error pages comes.
Any idea how to fix this?
Thanks in advance.
The below image is from Top Horizontal Menu Module where JEWELLERY is category and the other below them are sub category.
Thw below image shows that the categories CSV is uploaded successfdully
But it is not listed under Catolog->Categories refer the below image for this
First when I added categories from CSV, the categories is not getting displayed in Catalog->Categories but when I add one category manually then it is displayed in Catalog->Categories but cannot add subcategories to it.
I think there should be some issues in Presta Shop.
For example : I manually added "Testing" as one category. It was added as main category by default. Then both "Home" and "Testing" categories can be seen in Catalog ->Categories.
After this I tried to add the subcategories to "Home" categories through CSV, it worked out.
PrestaShop is expecting the category to be listed in Catalog->Categories to add the subcategories to it even if that particular category is in DB.
Now I can add the sub categories to what ever Main Categories needed and also the products are also getting listed under the subcategories through CSV.
But I dont know why it is not getting added to Catalog->Categories initially when I add from CSV.
Now in DB ps_category table the records are as expected as you have listed.
This is the default Prestashop categories (table ps_category). Please check if you have only one row with is_root_category = 1. This must be a category ID 2 (id_category = 2), your site Home category.
And please check if all three categories ID 1, 2, 3 in your table looks the same in columns id_parent, id_shop_default, level_depth, is_root_category.

How to show category name of classified listing in social engine

i am working on social engine create a form in admin panel to post ad its display in frontend but when i add category all fields are dispaly but category not show how to show category name on my ad listing..
This is my listing frontend...
This is my form to crete ad..in frontend
This is my category which is add from backend and dispaly in frontend form when you create ad then choose category ...
So please suggest me how to show my category in my ad listing..
Hope the below answer will helps you.
$categoryObject = Engine_Api::_()->getDbtable('categories', 'classified')->find($classified->category_id)->current();
$categoryName = $categoryObject->category_name;
** In above code $classified is the object of Classified_Model_Classified class. You can also optimize the above code if you want to use the category name only (you need to fetch the category name only).
** I am assuming that your are using the SocialEngine - Classified module and you did not do any modification in given structure by SocialEngine, because in this case the below answer may leads to error.

Kentico Ecommerce: getting top selling categories

I am using Kentico 7.0, ecommerce version.
I would like to create a sidebar menu that shows the eshop's top selling product categories. I am a kentico newbie so I am looking around for the correct terminology/guidance so that I can dig deeper.
The ideal approach in my opinion would be to be able to add a field on categories, which is used to filter categories for the menu. This way I can either have some kind of job that updates the fields automatically based on sales, OR provide a manual override for an admin to specify whether a category will show up on the menu. Of course some kind of weight would also be needed to specify menu item ordering.
Which way should I look?
HAve you tried using the "Top N products by sales" web part that is available? you can configure from which part of the content tree (products) it should pull the data - in the Path property you can use also a path expression or macro that is resolved dynamically so the web part can display different products in different sections.
There are many ways to code for Kentico. I personally find the API is a bit clunky and on quite a few occasions I was surprised that a method didn't exist requiring extra calls to get the required results. I do use the Kentico API more when putting data in to Kentico. Pulling it out I use the following.
STORED PROC
Write a SQL stored procedure to get the top X categories - GetTop5Categories.
Look at the COM_* tables, specifically COM_OrderItem, linking OrderItemSKUID back to COM_SKU (or View_COM_SKU_Joined if you need to get to the IA).
This will get you the top selling products with a group by, a count, a top X and an order by.
Then you can link to other tables such as CMS_Category or CMS_Document (depending on how you setup your categories). The bonus of this is that procs are compiled, you do all your data manipulation there (it's what MSSQL specialises in!) and you only send back what you need to in the result set.
DOMAIN (leveraging EF)
I usually create a separate class library project myproject.domain and put an Entity Framework edmx in there mapped back to the Kentico DB. Add the proc to the EDMX, then create a Function Import MyProject_GetTop5Categories from your newly imported proc.
WEB
add a reference to the domain project from your web project, and a 'using at the top of the codebehind of the control.
using myproject.domain;
then in Page_Load for the control:
...
if(!IsPostBack)
{
var entities = new MyProjectModelContainer();
var list = entities.MyProject_GetTop5Categories().ToList();
StringBuilder sb = new StringBuilder("<ul>");
foreach(var category in list)
{
sb.Append("<li><a href='"+category.Link+"'>" + category.Name + "</a></li>");
}
sb.Append("<ul>");
listPlaceHolder = sb.ToString();
}
handwritten so probably a typo or two in there :)
HTH

Expression Engine Related Categories

I've been trying to get a sub navigation going for quite some time, and can't seem to find a solution to my problem.
First things first, here is the closest example of what I'm trying to get my sub nav to do. (the TVs sub nav) http://www.bestbuy.com/site/TV-Home-Theater/Televisions/abcat0101000.c?id=abcat0101000
For example, if I have 3 category Parents (Central, Portable, and Brands), If click on "Central" I would like all of the categories associated with "Centrals & Brands" to appear, leaving out anything to do with "Portable".
Another example, if I click on "Brands" I would like to be able to shop by brand, and have only the "Central & Portable" products related to that brand.
I am currently using GWcode Categories & GWcode CatMenu, to try and get this working.
Thanks in advance!
You may have more luck by replacing the native categories with a Channel Entries + P&T Playa approach.
Create a 'Categories' channel
Add a Playa field to it with related categories (entries) from the categories channel
In your product channel, add a Playa field with categories (entries) from the categories channel.
The TV subnav on the Best Buy site would be recreated by displaying the related categories (mentioned in step 2) to the current viewed category.
{exp:playa:children entry_id="{current_page_category_id}"}
...
{/exp:playa:children}
Your mileage may vary.