I am trying to get the collection based on product and quote Id using,
$quotecollection = Mage::getModel('sales/quote_item')->getCollection()->addFieldToFilter('quote_id',$quoteId)->addFieldToFilter('product_id',$product_id);
$quotecollectionaArr = $quotecollection->getData();
echo $quotecollection->getQty();
which gives the following error
Fatal error: Call to undefined method
Mage_Sales_Model_Resource_Quote_Item_Collection::getQty() in
C:\xampp\htdocs....
Please help.
You should use getFirstItem()
$quotecollection = Mage::getModel('sales/quote_item')->getCollection()->addFieldToFilter('quote_id',$quoteId)->addFieldToFilter('product_id',$product_id)->getFirstItem();
echo $quotecollection->getQty();
Related
I'm trying to Query Data from my Database to put the result into the value form an input.
but when I want to fetch the Data, following error is showing up:
Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Error parsing ObjectId string: 5f4286324becb3f60cbb866e
I really don't know how to solve it, i searched like 2 hours in the WWW.. I hope someone can help me..
Here's my Code:
$id = $_POST['id'];
echo $id;
$client = new MongoDB\Client;
$db = $client->thesis;
$personen = $db->Personen;
$document = $personen->findOne(['_id' => new MongoDB\BSON\ObjectId($id)]);
I'm getting the ID with the echo but the findOne Method isn't working.
Thanks for your answers :)
Cheeres
I am using indieteq-php-my-sql-pdo-database-class I found on GitHub
I have created a little page to try and display some database information as seen below, however I receive the error below my test page script below;
My Test Page
<?php
require("Db.class.php");
$db = new Db();
$db->query("SELECT * FROM faction_territories");
if ($db->execute()) {
while ($row = $db->fetch(PDO::FETCH_ASSOC)) {
echo '<tr>
<td>'.$row['territory_id'].'</td>
<td>'.$row['name'].'</td>
<td>'.$row['density'].'</td>
<td>'.$row['sector'].'</td>
<td>'.$row['size'].'</td>
<td>'.$row['respect'].'</td>
<td>'.$row['faction_name'].'</td>
</tr>';
}
echo '</table>';
}
?>
Error
Fatal error: Uncaught Error: Call to undefined method DB::execute() in
/var/www/.../index.php:7 Stack trace: #0 {main} thrown in
/var/www/.../index.php on line 7
Questions
As you'll be able to tell, I'm somewhat new to PHP & PDO. Some nice pointers to where I am going wrong would be nice with any example code please.
The $db->query already execute the query. You just need to iterate over the result.
See here: https://github.com/wickyaswal/indieteq-php-my-sql-pdo-database-class/blob/master/Db.class.php#L189
Not sure if this is an Wordnik API issue or just a php error on my part. Here is my current code:
require('./wordnik/Swagger.php');
require('./wordnik/WordsApi.php');
$myAPIKey = '00144cdc1140c4192780f08c3f608399234240dcb560d3e4b';
$client = new APIClient($myAPIKey, 'http://api.wordnik.com/v4');
$wordApi = new WordApi($client);
$input = new WordObject();
$input->includePartOfSpeech='noun';
$input->excludePartOfSpeech='affix,article,connjunction,preposition,abbreviation,suffix';
$input->hasDictionaryDef='true';
$input->minCorpusCount='10000';
$input->maxCorpusCount='null';
$input->minDictionaryCount='20';
$input->maxDictionaryCount=null;
$input->minLength='4';
$input->maxLength='20';
$random_word = $wordApi->getRandomWord($input); //THIS IS THE ERROR LINE
print $random_word->text;
and here is the error I get:
Fatal error: Call to undefined method WordApi::getRandomWord()
Any help is greatly appreciated. The error is happening on that line towards the bottom, just not sure why. Thank you.
getRandomWord() is defined in WordsApi (plural words).
You have: WordApi
You need: WordsApi
trying to get every post and comment from a facebook page, I made this function that should go through the pagination:
$req = $facebook->api("/" . $pagename . "/?fields=posts.fields(message,link,created_time,shares,likes,comments)");
function parcours_arbre($ab)
{
GLOBAL $facebook;
GLOBAL $pagename;
$next = create_request($ab['posts']['paging']['next']);
$next_req = $facebook->api($pagename.$next);
$ab_next = $next_req['data'];
$prev = create_request($ab['posts']['paging']['previous']);
$prev_req = $facebook->api($prev);
$ab_prev = $prev_req['data'];
if (empty($ab)) {
display_results($ab['posts']['data']);
} else {
parcours_arbre($ab_next);
parcours_arbre($ab_prev);
}
}
I unfortunately get the following error:
Notice: Undefined index: posts in /form.php on line 36
Notice: Undefined offset: 3 in /utils.php on line 20
Notice: Undefined offset: 4 in /utils.php on line 20
Fatal error: Uncaught GraphMethodException: Unsupported get request. thrown in /sdk/src/base_facebook.php on line 1271
Any idea how i could avoid it or what is going on? Would this go away if i use the "until" statement in my api request?
Thanks a lot,
To explain each error
the variable $ab which is an argument to the function, does not have a "posts" index. You should try to var_dump this variable so you can see what it actually looks like.
same as above
same as above
the api function takes 3. The path which should just be #pagename. The method ("GET" or "POST") most likely POST because GET is causing an error. The parameters, which should be array("fields" => "posts.fields(message,link,created_time,shares,likes,comments)")
I noticed that for next you have the code
$next_req = $facebook->api($pagename.$next);
but for previous you have
$prev_req = $facebook->api($prev);
Might want to look into this.
I am currently getting this error on one of my files:
/var/www/vhosts/httpdocs/generator/index.php on line 6
Line 6 would be resulting in:
echo $results->GetBookCodesResult->BookCodes->BookInfo->ServiceCode;
My code:
<?php
$config['soap_url'] = "http://myservice.com?WSDL";
if(isset($_REQUEST['codes'])) {
$results = request_Data(explode("\n",$_REQUEST['codes']));
echo $results->GetBookCodesResult->BookCodes->BookInfo->ServiceCode;
}
....
What is the best method to have this fixed? Some advice would be appreciated.
your "->BookCodes" sub-property is empty as you can see in your var_dump-output...
this property "BookInfo" just not exist.. maybe no books are found? ;)