The categories have:
The "top" option marked already
They're assigned to a store
They're assigned to a manufacturer
And they're still not being shown. I don't think this is a code issue as it was working just fine with the default products/categories and I haven't touched the code yet.
I've researched a lot, but people always say that marking the "Top" option should solve the issue.
Please take a look into the below screenshots.
http://postimg.org/image/yv6p186kf/
http://postimg.org/image/wcl00jku7/
postimg.org/image/pbx07rj27
Thanks
Edit:
I'm using OpenCart v1.5.6
Edit 2:
It is a parent category.
For those who are still researching this, please read my answer.
It seems to be an OpenCart bug.
Here is what I've done to fix the issue:
Instead of leaving the "Parent" field as blank, try to type a invalid name in the field so it will show the -- None -- option, select it and click on save. It solved the problem in my case.
Please see the screen shot.
http://i.stack.imgur.com/WWPBY.png
Do the following steps:
Open and edit your category:
In tab Data:
Find and Check:
Top: Display in the top menu bar. Only works for the top parent
categories.
I was not getting the child categories in the form field so I did this.
Create the category without parent
Add this category to the products that you want.
Now edit the category and add the parent to it.
The component is written to return just 5 top results, the issue arises after there is a categories overload
to Fix the issue goto file
/admin/controller/catalog/category.php
function autocomplete()
{
$json = array();
if (isset($this->request->get['filter_name']))
{
$this->load->model('catalog/category');
$filter_data = array(
'filter_name' => $this->request->get['filter_name'],
'sort' => 'name',
'order' => 'ASC',
'start' => 0,
'limit' => 5
);
$results = $this->model_catalog_category->getCategories($filter_data);
foreach($results as $result)
{
$json[] = array(
'category_id' => $result['category_id'],
'name' => strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8'))
);
}
}
$sort_order = array();
foreach($json as $key => $value)
{
$sort_order[$key] = $value['name'];
}
array_multisort($sort_order, SORT_ASC, $json);
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
and change limit from 5 to a higher number, preferably 20 in
$filter_data = array(
'filter_name' => $this->request->get['filter_name'],
'sort' => 'name',
'order' => 'ASC',
'start' => 0,
'limit' => 20
);
Here is the issue I ran into. When you are in the admin area and trying to select the category that your product belongs to... Make sure you fully click. I dont have a mouse, so if you have a mouse or trackball this may not address your issue. My Asus Laptop finger pad allows me to lightly tap or fully click the pad to navigate. I had to make sure I clicked my category choices. If I only tapped the pad lightly it pretended to make a selection and the category would not register. So my issue was probably related to a javascript/hardware quirk.
Wasted an hour with that one.... LOL.
Hope this helps someone else. I am using Opencart version 3.0.3.8
The powers that be at stack exchange may not have the same hardware as me or some of us. Please dont flag this post because you don't understand this post. This will help someone else. These people think they know everything. And probably filter out some good answers.
Related
Problem: I created lists with {CityName} and {Departments of City} two column in Excell. Cities are categories and departments of city are post.
I want to add post to Custom post type {departments} in WordPress
My Question: How can I add post to Custom post type from an array?
I Tried 3 Way
Hard Way
<?php
$departments = array(
array(
"title" => "Adana Kozan Tech Office",
"cityid" => 153 // or city_nicename
),
...
);
foreach($departments as $c) {
$istname = $c['title'];
$cityid = $c['cityid'];
$station_info = array(
'post_title' => wp_strip_all_tags( $istname ),
'post_content' => wp_strip_all_tags( $cityid ),
'post_type' => 'departments',
'post_category' => array($cityid),
'post_status' => 'publish',
);
wp_insert_post($station_info);
}
?>
This was hard way for me. Because little complicated and I saw critical errors. And I couldn't, It didn't worked. So if you could this way, please don't hesitate to say in comments where I made a mistake.
Note: It worked for adding categories (wp_insert_category).
Middle Way
I thought "how the hell we export posts, that way we import". So I added two dummy department with city category. And exported to pc. And I thought of editing that complicated .xml file. But when I was thinking about it, I found a better way.
Easy Way
WP All Import plugin. Yes.
We are preparing in Excell. Then we save it as a .csv extension.
We also open it with notepad ++ and convert it with Encoding> Convert to UTF-8 and save it.
We enter the WP All Import plugin and determine how to drag it from there step by step, category, content, and which part to add. Next next. Finish
I've been tasked with making a Wordpress theme, and there is 1 issue I just can't seem to find good information on. I want to display posts on a page, but only if the post matches 2 categories (not either or, it has to be both or nothing is displayed).
So I tried a few things. This was the best result:
<?php if(is_page("16")) {
query_posts( 'cat=3&&cat=8' );
} ?>
But this is an either or answer so both categories show up. I'm more comfortable in C#, so the syntax I'm looking for the wordpress equivalent for would be:
//Forgive the out of context syntax here
if(postCategory == "3" && postCategory == "8")
//rather than
if(postCategory == "3" || postCategory =="8")
Basically if the post is tagged as both categories, it shows up. Otherwise it does not. I realize this is probably a noob question and maybe it has been answered somewhere, but over 2 hours of Googling and RTM have not produced anything.
Doesn't it figure that once you post a question, you mysteriously come across the answer.
query_posts( array( 'category__and' => array(1,3), 'posts_per_page' => 2, 'orderby' => 'title', 'order' => 'DESC' ) );
it was on this page. Guess I just skimmed over it.
I'm currently working on a gallery system using cakephp. In it, we have paginated each image album so each page contains a set number of images at most. I have attained this by using:
$this->paginate = array(
'conditions' => array(
'Item.album_id' => $id
),
'order' => array(
'Item.added' => 'desc'
),
'limit' => '50'
);
On my view controller. With this, I can show all the items on each page with no problems.
I'm currently, however, facing a single issue: I need to show, after all the items in the current page, a button that leads to the next page. This is not a problem, except that by design the button that says NEXT PAGE should have an item from the next page as its background.
I have looked around, trying to figure out a way to pull an item from the next page of a paginated system in cakephp without luck. Has anyone done this, or does anyone have a clue how to go about it?
You have to query the preview image manually in the current page.
To access the page number you can use $this->params in the action. Then you have to query images with 'limit' and 'page' parameters as mentioned in the documentation.
After that set the image URL like this:
$this->set('preview_image_url', $queried_url);
Then in the view use inline styling to set the background for the next button.
With Alto's help, I ended up doing this (Putting it here just in case anyone wonders exactly how I did it):
$CurrPage = $this->params['paging']['Item']['page'];
$NextParams = array(
'limit' => 1,
//'page' => $CurrPage + 1,
'order' => array(
'Item.added' => 'desc'
),
'offset' => $CurrPage*50
//'order' =>('rand()')
);
$NextImage = $this->Item->find('first', $NextParams);
$this->set('NextImage', $NextImage);
This gives me the first item from the following page, which is good enough for me. Note the commented 'order' =>('rand()') - I tried to grab a random item from the following page but, alas, it seems like Cake first scrambles all items and THEN paginates. There's probably a way around this, but for now this one did it for me.
Also, using 'page' => $CurrPage + 1 didn't seem to work, with the system instead returning a seemingly randomly chosen image. That's why I instead defaulted to using 'offset' => $CurrPage*50, where 50 is the amount of items per page I'm showing.
My bigcommerce code for filtering begins like this:
for($x=1;$x<$count;$x++){
$filter = array('category' => 54, 'limit' => 200, 'page' => $x);
$products = Bigcommerce::getProducts($filter);
This doesn't work quite right, and I'm not sure if it is meant to.
Here is the bigcommerce api in php.
Can anyone tell me the correct way to pull only the results that have a category id of 54 using $filter?
$filter = array("category" => 54, "limit" => 200);
$products = Bigcommerce::getProducts($filter);
foreach ($products as $product) {
//do something with results
}
I am not sure about the page option you used but this is the code that I use to filter products by category id. It should work the same adding in the page as well. You can also use a variable for the category id something like $_POST['catid'] where 'catid' comes from html page or from url: category.html?catid=54. This is how I display products in my store when no subcategories exist for a certain category id it will use that cat id to find all the products in that category. In my for each loop it creates the html for the list of products. You can use $product->name, etc. to access the product resources available and use html that is sent back to your main page using java script. Let me know if you have any other questions I had a hard time finding any help on this when I went through it so I am more than happy to help if I can. I hope this helps.
I am currenty working on a story board, and i upload images there telling a story.
So the problem is i just want to limit the related query.
The story board has a has_manyrelation for images. and on the list where the story boards appear i just only want to show the first image, and when someone clicks it it will show all, the show all is fine, but i can limit just the related images in my view.
And im totally confused with it because i read lot of infos about it in the forum, tried may variations, the limit is just ignored, or i get errors
so here is my code
controller
$stories = Model_Storyboard::find('all', array('related' => array('storyboardimage')));
$this->template->title = "Sotry Board | " . Config::get('site_name');
$this->template->content = View::forge('storyboard/index', array('stories' => $stories));
So how can i limit the storyboardimage to show the first image for each storyboard?
Sorry if im askin to much, but i would be really happy if someone could give me a working example beacuse i tried lots of variations and nothing works...
You can add criteria onto the relations, i.e. where, order_by, limit etc.
For example (note this is untested)
$stories = Model_Storyboard::find('all', array(
'related' => array(
'storyboardimage' => array(
'limit' => 1,
'order_by' => array(
'field_indicative_of_first_image' => 'desc'
),
)
)
));
In the example above I've added in field_indicative_of_first_image which simply means replace this with a column which you can use to get the first image. This might be for example a created_at column or a weight or sort_order column. Without knowing your database schema, I can't tell you which you'd need.