Hey guys I got an issue in magento when listing products.
$_productCollection = array();
$key = 'product_collection_'.Mage::app()->getRequest()->getRequestUri();
$_productCollection = Mage::helper('cache')->getDataInCache($key);
if (empty($_productCollection)) {
$_productCollection=$this->getLoadedProductCollection();
Mage::helper('cache')->setDataInCache($key,$_productCollection,'front_end_collection');
}
That's my code, i'm loading the collection and saved in cache, the problem is that I added new products from the admin panel but they are not showing up in the listing.
I have refreshed cache, reindex all the data and checke that the products were in stock. Also check the visibility because i understand that the collection gets just the visible products, am i correct?
I'm using magento enterprise 1.9
I'm new in magento and i'm having troubles understanding how the Collections works, i hope somebody can help me. Thanks
I'm working on a simple JOIN of two tables (urls and companies). I am using this query call:
print $this->_db->select()->from(array('u' => 'urls'),
array('id', 'url', 'company_id'))
->join(array('c' => 'companies'),
'u.company_id = c.id');
which is out putting this query:
SELECT `u`.`id`, `u`.`url`, `u`.`company_id`, `c`.* FROM `urls` AS `u` INNER JOIN `companies` AS `c` ON u.company_id = c.id
Now, I'd prefer the c.* to not actually appear, but either way it doesn't matter. ZF dies with this error:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1"
but I can run that query perfectly fine in my MySQL CLI. Any ideas how to fix up this query?
We make use of views and panels quite often in Drupal and a lot of people are utilizing CTools in development. I can't find a lot of documentation on what it is and why you'd use it and the drupal.org forum isn't providing much either.
What is CTools, and is it worth using? What is the best use-case for utilizing it?
Any time there is an update within my music community (song comment, artist update, new song added, yadda yadda yadda), a new row is inserted in my "updates" table. The row houses the artist id involved along with other information (what type of change, time and date, etc).
My users have a "favorite artists" section where they can do just that -- mark artists as their favorites. As such, I'd like to create a new feature that shows the user the changes made to their various favorite artists.
How should I be doing this efficiently?
SELECT *
FROM table_updates
WHERE artist_id = 1
and artist_id = 500
and artist_id = 60032
Keep in mind, a user could have 43,000 of our artists marked as a favorite.
Thoughts?
OK so I have two tables, MEDIA and BUSINESS. I want it set up so the forms to input into them are on the same page. MEDIA has a row that is biz_id that is the id of BUSINESS. So MEDIA is really a part of BUSINESS. HOW do I insert/add these into their tables without a common ID because I haven't yet made the record for business?
I'm sorry I didn't really word this very much... You might need more clarification to answer properly and I'll be glad to give any more info. Any help would be greatly appreciated, thanks!
I'm using the following widget to allow a user to input a date
$this->widgetSchema['first_registration'] = new sfWidgetFormDate(array(
'format' => '%month%/%year%',
'years' => range(date('Y', time()) - 15, date('Y', time()) + 15)
));
The default format for a date using this widget is %month%/%day%/%year% and so that's what the default validator for this widget checks for. However, I've attempted to alter the validator...
$this->validatorSchema['first_registration'] = new sfValidatorDate(array(
'date_format' => '%month%/%year%',
'with_time' => false
));
This isn't working and I'm still getting an invalid error. Does anybody know why?
I have created a shopping cart site, and i have got two complains for the same issue, but i am not able to track the main problem...
They whenever they complete the process and reach at the last page they get the error message as "operation aboarded, Internet explorer can't open the page"
Could someone helo me out? what could be the reason behind this..
i tried to get the error in IE-6,7,8 but I didnt get any error...
?
Hi
In my mode I am selecting a field as
$query1 = $this->db->query("SELECT dPassword
FROM tbl_login
WHERE dEmailID='[email protected]'");
How to return dpassword as a variable to my controller
I tried this way return dpassword;
Hi all:
I am working on The ausdcf.org to try adding several banner ads in swf format to the top.
Everything starts to work, but I've got several questions that need your help:
The client chose not to go with Google AdManager, but prefer a "minimal approach" to do this task.
What I am trying to do is sort of "mimicking" the way Google AdManager does for banners, that is, to split the chance of each particular swf to be shown to the visitor evenly among the banner collection.
Definitely I can add some jQuery code to do this from client-side, a random number generator and if-else statement would work - just $.load() it!
However, what if I'd like to make sure those disabled Javascript (is there any now btw?) still be able to see different swfs in each visit.
Any suggestion on how to approach this?
Many thanks in advance.
I'm using Symfony 1.2 in a standard Propel form class.
public function configure()
{
$this->setWidgets(array(
'graduate_job_title' => new sfWidgetFormInput( array(), array( 'maxlength' => 80, 'size' => 30, 'value' => '' ) )
));
//etc
}
However, I want the value of this field to come from the user information, which I'd normally access using $this->getUser()->getAttribute( '...' ). However, this doesn't seem to work in the form.
What should I be using?
I am currently trying to write some unit test against my zend framework controller. When I run the following code I receive this error:
public function testListActionShouldContainListTable()
{
$this->loginToSystem();
$uri = $this->_uriBase . 'campaign/list';
$_SERVER["REQUEST_URI"] = $uri;
$this->dispatch('/campaign/list');
$this->assertController('campaign');
$this->assertAction('list');
$this->assertQueryCount('#list',1);
}
CampaignControllerTests::testListActionShouldContainListTable
DOMDocument::loadHTML(): ID alrt already defined in Entity, line: 36
This occurs using any of the assertQuery and assertQueryContains methods. I have searched around but am not really finding a good answer to why it won't allow me to find this html node or how to get around this error.
Thanks in advance for any help!
Does Doctrine 1.2 support importing indexes with Doctrine_Core::generateModelsFromDb() function?
I need to make a migration between 2 database connections, one of them having unique index on 2 fields and one doesn't. And my migration is empty. It looks like Doctrine doesn't support indexes when importing from databae, other than those tied to relationship foreign keys.
$changes = Doctrine_Core::generateMigrationsFromDiff($migrationsPath,
array('doctrineOld'),
array('doctrine'));
To be specified:
function getLength($str)
{
//function i need
}
$str1 = 'aabbcccc';
$str2 = 'aabbccccaaaaa';
echo getLength($str1); //will get 4
echo getLength($str2); //will get 5
Any good ideas?Thanks in advance!
often i want to email some code without attaching a file, are there any gmail/google wave/gdocs plugins for code sharing?
gmail would obviously be most useful!
I am a Yii beginner and am running into a bit of a wall and hope someone will be able to help me get back onto track. I think this might be a fairly straight forward question to the seasoned Yii user. So here goes...
In the controller, let's say I run the following call to the model-
$variable = Post::model()->findAll();
All works fine and I pass the variable into the view. Here's where I get pretty stuck. The array that is returned in the above query is far more complex than I anticipated and I'm struggling to make sense of it. Here's a sample-
print_r($variable);
gives-
Array ( [0] => Post Object ( [_md:CActiveRecord:private] => CActiveRecordMetaData Object ( [tableSchema] => CMysqlTableSchema Object ( [schemaName] => [name] => tbl_post [rawName] => `tbl_post` [primaryKey] => id [sequenceName] => [foreignKeys] => Array ( ) [columns] => Array ( [id] => CMysqlColumnSchema Object ( [name] => id [rawName] => `id` [allowNull] => [dbType] => int(11) [type] => integer [defaultValue] => [size] => 11 [precision] => 11 [scale] => [isPrimaryKey] => 1 [isForeignKey] => [autoIncrement] => 1 [_e:CComponent:private] => [_m:CComponent:private] => ) [post] => CMysqlColumnSchema Object ( [name] => post [rawName] => `post` [allowNull] => [dbType] => text [type] => string [defaultValue] => [size] => [precision] => [scale] => [isPrimaryKey] => [isForeignKey] => [autoIncrement] => [_e:CComponent:private] => [_m:CComponent:private] => ) ) [_e:CComponent:private] => [_m:CComponent:private] => ) [columns] => Array ( [id] => CMysqlColumnSchema Object ( [name] => id [rawName] => `id` [allowNull] => [dbType] => int(11) [type] => integer [defaultValue] => [size] => 11 [precision] => 11 [scale] => [isPrimaryKey] => 1 [isForeignKey] => [autoIncrement] => 1 [_e:CComponent:private] => [_m:CComponent:private] => ) [post] => CMysqlColumnSchema Object ( [name] => post [rawName] => `post` [allowNull] => [dbType] => text [type] => string [defaultValue] => [size] => [precision] => [scale] => [isPrimaryKey] => [isForeignKey] => [autoIncrement] => [_e:CComponent:private] => [_m:CComponent:private] => ) ) [relations] => Array ( [responses] => CHasManyRelation Object ( [limit] => -1 [offset] => -1 [index] => [through] => [joinType] => LEFT OUTER JOIN [on] => [alias] => [with] => Array ( ) [together] => [scopes] => [name] => responses [className] => Response [foreignKey] => post_id [select] => * [condition] => [params] => Array ( ) [group] => [join] => [having] => [order] => [_e:CComponent:private] => [_m:CComponent:private] => ) ) [attributeDefaults] => Array ( ) [_model:CActiveRecordMetaData:private] => Post Object ( [_md:CActiveRecord:private] => CActiveRecordMetaData Object *RECURSION* [_new:CActiveRecord:private] => [_attributes:CActiveRecord:private] => Array ( ) [_related:CActiveRecord:private] => Array ( ) [_c:CActiveRecord:private] => [_pk:CActiveRecord:private] => [_alias:CActiveRecord:private] => t [_errors:CModel:private] => Array ( ) [_validators:CModel:private] => [_scenario:CModel:private] => [_e:CComponent:private] => [_m:CComponent:private] => ) ) [_new:CActiveRecord:private] => [_attributes:CActiveRecord:private] => Array ( [id] => 1 [post] => User Post ) [_related:CActiveRecord:private] => Array ( ) [_c:CActiveRecord:private] => [_pk:CActiveRecord:private] => 1 [_alias:CActiveRecord:private] => t [_errors:CModel:private] => Array ( ) [_validators:CModel:private] => [_scenario:CModel:private] => update [_e:CComponent:private] => [_m:CComponent:private] => ) )
[sorry if there's an easier way to show this array, I'm not aware of it]
Can anyone explain to me why the model returns such a complex array? It doesn't seem to matter what tables or columns or relations are used in your application, they all seem to me to return this format.
Also, can someone explain the structure to me so that I can isolate the variables that I want to recover?
Many thanks in advance,
Nick
I am preparing a chart which will display the number of orders placed for a particular day in the current month and year. I wanted the count of orders placed for each day.
I am showing the count of orders on the y-axis and the day on the x-axis.
In my database, there is table called "order" in which order data is placed: order date, user_id, order_price, etc. For example, if on 4 July, 10 orders are placed, on 5 july, 20 orders are placed, and so on.
How can I get the count of orders placed for day of the current month?
Hello guys,
What I have in mind is this... We are going to have people come from a particular site during a acquisition campaign and was wondering how I could conditionalize a certain section of my site to display a thank you message instead of the sign up form as they would have had the opportunity to fill this out before coming to my landing page.
I have seen solutions like: $referal = mysql_real_escape_string($_SERVER['HTTP_REFERER']);
I would like to know if this is the best way to get this to work???
- okay this is what i think might work. The third party website that is referring people to our landing page once the form on that site has been filled out can push into the record a hidden input value of "www.sample.com" or whatever... then I can have something check the for that particular value and fire off the conidtional.
Does that even sound right?
Im working on a script to tear into a csv file and ive got the rows separated, but im not sure how to assign variables to the fields within the row, so that i can perform functions with them.
my code:
<?
ini_set('auto_detect_line_endings', true);
$csvraw = file_get_contents("file.csv");
$csv = explode("\n", $csvraw);
$i=0;
foreach($csv AS $key=>$value){
$rowsplit = explode(",", $value);
// This is where i get my headers
if($i == 0){
$col0 = $rowsplit[0];
$col1 = $rowsplit[1];
$col2 = $rowsplit[2];
$col3 = $rowsplit[3];
$col4 = $rowsplit[4];
$col5 = $rowsplit[5];
$col6 = $rowsplit[6];
$col7 = $rowsplit[7];
}
$i++;
//This is where i loop through each row's fields
foreach($rowsplit AS $key2=>$value2){
if(empty($value2)){
echo "";
}else{
echo "$value2 <br>";
}
// This is where i need to assign $variable0 through $variable7 so i can perform a function with the field values.
}
echo "<br><br><br>";
}
?>
I run a small, niche personal ads site. People post ads and then other people reply to them, which sends an email to the original creator of the ad telling them that someone is interested and giving them contact information for that interested person.
Lately there's been some weird spam. People are receiving nonsense replies to their ads. Here is an example of one:
Name: xkauwvyr
Reply: vRYmbI <a href="http://rypmoxdkfblf.com/">rypmoxdkfblf</a>, url=http://pnjlwvhizwbq.com/]pnjlwvhizwbq[/url], [link=http://hmenwoujxrfv.com/]hmenwoujxrfv[/link], http://ogsekuhoyeud.com/
They vary in length and composition but they all look roughly like that. The first idea I had was to simply throw out any reply that contained the string "
Also, is this spam just some ass playing a trick on my website, or is it something more malicious?
Hey guys quick question, I thought I was doing the right thing but I keep getting the wrong result. I am trying to simply find the id of the entry with the min time, but I am not getting that entry.
$qryuserscount1="SELECT id,min(entry_time) FROM scrusersonline WHERE topic_id='$topic_id'";
$userscount1=mysql_query($qryuserscount1);
while ($row2 = mysql_fetch_assoc($userscount1)) {
echo $onlineuser= $row2['id'];
}
That is my query, and it does not work. This however does work which does not make sense to me
SELECT id FROM scrusersonline WHERE topic_id='$topic_id' ORDER by entry_time LIMIT 1, can anyone quickly point out what I am doing wrong?
I have a piece of code that generates soccer/football fixtures.
The idea is that for every round of fixtures, the date will be 4 days further than the last round.
So round one will be 3rd may, round two will be 7th may, round three 11th may, etc.
I am not sure how to do this?
The code that currently makes the fixtures are as follows:
$totalRounds = $teams - 1;
$matchesPerRound = $teams / 2;
$rounds = array();
for ($i = 0; $i < $totalRounds; $i++) {
$rounds[$i] = array();
}
for ($round = 0; $round < $totalRounds; $round++) {
for ($match = 0; $match < $matchesPerRound; $match++) {
$home = ($round + $match) % ($teams - 1);
$away = ($teams - 1 - $match + $round) % ($teams - 1);
// Last team stays in the same place while the others
// rotate around it.
if ($match == 0) {
$away = $teams - 1;
}
$rounds[$round][$match] = "$user[$home]~$team[$home]@$user[$away]~$team[$away]";
}
}
The teams would be the total users in the league.
So if there are 8 teams, there will be 7 rounds.
And i will want each round 4 days apart.
And that date will be within each fixture within each round.
Any further information needed just ask!
Thanks, really stuck on this
Hello,
What's your favourite programming page you often land at? For example, mine is:
http://code.google.com
Because it provides wealth of resources and tools.
how do i have to nest multicheckboxes so that they are named like this 'foo[]['bar']' .
i've used subforms but they give me naming like this 'foo[bar][]'.
my code:
$sub = new Zend_Form_SubForm('sub');
$wish = new Zend_Form_Element_MultiCheckbox('bar');
$wish
->setMultiOptions($education_direction->getAll())
->setLabel('Wish')
->setRequired(true);
$sub-addElements(array(
$wish
));
$this-addSubForm($sub, 'foo');