This is driving me crazy. No matter what export I do using profile, the column "assocciated", as mentioned in various magento guides is missing. I have around 7000 products and need to export them with the parent/child relationship intact, however, after export it just shows all the products without any columns mentioning the relationship also link for only 1 image is shown even when there are more than 5 images.
I would like to see the configurable products with all the associated products (seperated by comma) OR simple products with the sku of configurable product.
Is there any option to accomplish this?
Thanks.
U can use this code
(please make filename.php under your web root
<?php
require_once 'app/Mage.php';
Mage::app();
//$parentProduct= Mage::getModel('catalog/product')->load('2862');
$parentCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('type_id','configurable')
->addAttributeToFilter('status','1');
//$pid = array();
$read= Mage::getSingleton('core/resource')->getConnection('core_read');
function getAttributeValue($value){
global $read;
$query = "select value from eav_attribute_option_value where option_id = '$value'";
$customAttributeValue = $read->fetchAll($query);
return $customAttributeValue[0]['value'];
}
?>
<style>
tr td{
border:1px solid black;
}
</style>
<table>
<thead>
<tr>
<td>sku</td>
<td>simple_skus</td>
<td>type</td>
<td>class</td>
<td>silos</td>
</tr>
</thead>
<tbody>
<?php
foreach($parentCollection as $parentID){
$parentProducts = Mage::getModel('catalog/product')->load($parentID->getId());
$childProducts = Mage::getModel('catalog/product_type_configurable')
->getUsedProducts(null,$parentProducts);
?>
<?php
foreach($childProducts as $child){
?>
<tr>
<td>
<?php echo $child->getSku();?>
</td>
<td>
<?php echo " "?>
</td>
<td>
<?php echo $child->getTypeId()?>
</td>
<td>
<?php
$value = $parentProducts->getClass();
echo getAttributeValue($value);
?>
</td>
<td>
<?php
$value = $parentProducts->getSilos();
echo getAttributeValue($value);
?>
</td>
</tr>
<?php }?>
<tr>
<td>
<?php echo $parentProducts->getSku();
?>
</td>
<td>
<?php
$separation = array();
foreach($childProducts as $child){
$separation[] = $child->getSku();
}
echo implode(',',$separation);
?>
</td>
<td>
<?php echo $parentProducts->getTypeId();?>
</td>
<td>
<?php
$value = $parentProducts->getClass();
echo getAttributeValue($value);
?>
</td>
<td>
<?php
$value = $parentProducts->getSilos();
echo getAttributeValue($value);
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
then browser your filename.php from your website
from that list you can convert html to csv
check this
http://www.convertcsv.com/html-table-to-csv.htm
hope this help
Magento provides export and import for configurable products from System > Import/Export > Dataflow - Profiles, please see the attached image how it's exporting configurable products
Main columns to take care about are type and has option as parent product will be assigned with has_option as 1 ,visibility as catalog, seacrh and it's child products which will assigned value for has_option as 0 , visibililty as Not Visible Individually and it's related attributes values like shoe_type , shoe_size and gender
-magmi option to import configurable products which will assign Associated products to parent product.Before this import one need to first import simple and configurable products.
Related
I would like to generate many QR code using
"Simple QrCode"
https://www.simplesoftware.io/docs/simple-qrcode
I can make one QR code like this
{!! QrCode::size(100)->generate('http://www.mywebsite.com') !!}
but how do I make alot.
I'm beginer this code looks not good. sorry.
I can make loop but loop numbers doesn't work.
<table border="1">
<?php
for ($i=1; $i<5; $i++) {
$url = "http://localhost/acex/1.php?g=". $i;
$qr = '{!! QrCode::size(100)->generate(' . $url .') !!}';
echo "link ";
echo"<br>";
?>
<tr>
<td>
<?php
echo "link ";
?>
</td>
<td>
<?php
echo $qr;
?>
</td>
<td>
<?php
echo $url;
?>
</td>
</tr>
<?php
}
?>
</table>
As you already use SimpleSoftwareIO, just write:
use SimpleSoftwareIO\QrCode\BaconQrCodeGenerator;
and put this code in your loop:
$qrcode = new BaconQrCodeGenerator;
$qrcode->size(100)->generate("your text", 'path to save file');
It worked for me.
On our Magento 1.6.2 website we have enabled Google Sitemaps and added some manually with updates through cron.
What happens now is that the page Catalog > Google Sitemap in it's filters tells us that 4 records were found.
But it doesn't show anything below the filters.
Through looking at the source code I've found that the div with class sitemapGrid only has a total height of 33px and the div with class grid that should display the sitemaps only has a total height of 7px, 6 of which are padding.
The sitemapGrid_table is 0px high, with a 1px border.
But no tr nor td.
After some more digging I've found that the file in which it all happens is design > adminhtml > default > default > template > widget > grid.phtml
The page runs till the end of the first foreach after "grid" and then stops.
<div class="grid">
<div class="hor-scroll">
<table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
<?php foreach ($this->getColumns() as $_column): ?>
<col <?php echo $_column->getHtmlProperty() ?> />
<?php endforeach; ?> <!-- Runs to here and then stops executing, but who knows why? -->
<?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
<thead>
<?php if ($this->getHeadersVisibility()): ?>
<tr class="headings">
<?php foreach ($this->getColumns() as $_column): ?>
<th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
<?php endforeach; ?>
</tr>
<?php endif; ?>
<?php if ($this->getFilterVisibility()): ?>
<tr class="filter">
<?php $i=0;foreach ($this->getColumns() as $_column): ?>
<th<?php echo $_column->getHeaderHtmlProperty() ?>><?php echo $_column->getFilterHtml() ?></th>
<?php endforeach; ?>
</tr>
<?php endif ?>
</thead>
If I comment out the first foreach, the code keeps running till it ends the first foreach in "headings". And so on (comment out one, runs till end of next one, ...)
Anyone have any idea on where the problem really lies and/or a solution?
So,
Long story short:
exception.log wasn't being filled so once that was solved I got to see that Magento couldn't find a certain blocktype.
Solved an error in config.xml and it all works just fine.
I previously had a custom form that users could fill out to place work orders, and once they hit submit, it would create a new ticket with all the information and add it to one of the RT queues.
We previously used Mason to do this, but now we've moved to WordPress and would like to redo this in a cleaner way using PHP.
I read through the API documentation and reviewed this thread along with many others posted on Stack Overflow. I know how to connect to RT and create new tickets via command line and cURL, but I can't seem to figure out how to do so using the web interface on submit. I would really appreciate if someone could give me some pointers on where to start.
Thanks
Edit:
Thank you for the response. Below is the form I've made which interacts with a our SQL database to pull some information and I need it to create a new ticket with all the information on submit. Should I create a new php file similar to [this][2] and include it as a form action?
<form action="<?php echo $_SELF; ?>";
method="post"
id="woForm"
name="woForm"
enctype="multipart/form-data"
>
<input type="hidden" name="session_id" value="<?php echo session_id(); ?>">
<input type="hidden" name="Queue" value="<?php echo $queue; ?>">
<input type="hidden" name="id" value="new">
<input type="hidden" name="Status" value="new">
<input type="hidden" name="Owner" value="10">
<table width="450" align="center" border="0" cellpadding="0" cellspacing="5">
<tr><td align="left" colspan="2">
<h2><?php echo $name; ?></h2>
<p>Please note that all fields except for <b>Ext:</b>, <b>CC:</b> and <b>Attachments:</b> are <span class="required">required</span>.
You cannot submit a request for assistance using this form unless all the required
fields have been completed.</p>
<h2 style="color:red;">Please enter information for the INDIVIDUAL needing assistance</h2>
</td>
</tr>
<?php
// Get all of the customFields
$query1 = "select * from CustomFields where disabled='0' and sortOrder != 0 order by sortOrder ASC;";
$result1 = mysql_query($query1) or die ("dead3: ".mysql_error());
// Go through each custom field
while($row1 = mysql_fetch_array($result1)) {
// Get the information about that field
$count = 0;
$fieldId = $row1['id'];
$name = $row1['Name'];
// $postname is in a very specific format, and will become the name of the field in the form
// where the data for this custom field is entered. In order to submit a ticket into rt, the
// name of the field MUST be in this format.
$postName = "Object-RT::Ticket--CustomField-".$fieldId."-Values";
?>
<!-- Create a row in the table for this custom field -->
<tr>
<!-- Create a column with the name of the custom field -->
<td align="right" class="requestformlabel"><label class="required"><?php echo $name; ?>:</label></td>
<!-- Create a column for the input field -->
<td class = "requestformtd">
<?php
// If the custom field is department or building, we need a pull-down menu
if($name=="Department" || $name=="Building") { ?>
<!-- start of the pull-down menu -->
<select name="<?php echo $postName; ?>">
<?php
// Get all of the possible values for the customField from the database
// Added option to exclude sort order 9999. See ticket #40665 for more info.
$query3 = "SELECT * FROM CustomFieldValues WHERE CustomField='$fieldId' AND SortOrder != '9999' ORDER BY SortOrder ASC";
$result3 = mysql_query($query3) or die ("dead4: ".mysql_error());
// Go through each possible value for the custom field
while($row3 = mysql_fetch_array($result3)) {
// Get the information on the custom field value from the database
$tmp = $row3['Name'];
$description = $row3['Description'];
// If the custom field value was already selected
if($tmp == $_POST["$postName"]) {
// Insert the option into the pull-down menu and mark it as selected in the form
echo "<option value='$tmp' selected='selected'>$description</option>";
// otherwise
} else {
// Only insert it as an option in the pull-down menu
echo "<option value='$tmp'>$description</option>";
}
}
?>
</td></tr>
<?php
// If the name of the custom field is operating system, we want radio buttons
} else if ($name == "Operating System") {
// Get all the possible values for this field form the database
$query4 = "select * from CustomFieldValues where CustomField='$fieldId' order by sortorder asc";
$result4 = mysql_query($query4) or die ("dead5: ".mysql_error());
// For each customfield value
while($row4 = mysql_fetch_array($result4)) {
// Get the description of the customfieldvalue from the database
$osName = $row4['Description'];
// If the customfieldvalue has already been selected
if ($osName == $_POST["$postName"]) {
// Put the radio button into the form and mark it as checked
echo "<input type='radio' name='$postName' value='$osName' checked='checked'>$osName";
// Otherwise
} else {
// Put the radio button into the form
echo "<input type='radio' name='$postName' value='$osName'>$osName";
}
} ?>
</td></tr>
<?php
// If the name of the custom field is ip adress, we want a disbaled text box. This is because while we want the user to see their ip adress, we do not want them to be able to change it.
} else if ($name == "IP_Address"){
?>
<input name="<?php echo $postName; ?>" size="40" value='<?php
echo $_SERVER['REMOTE_ADDR']; ?>' readonly></td></tr>
<?php
// If it's the hostname variable
} else if ($name == "Host_Name"){
?>
<input name="<?php echo $postName; ?>" size="40" value='<?php echo gethostbyaddr($_SERVER['REMOTE_ADDR']); ?>' readonly></td></tr>
<?php
// Otherwise, create a text box for the custom field.
} else {
?>
<input name="<?php echo $postName; ?>" size="40" value='<?php echo $_POST["$postName"]; ?>'></td></tr>
<?php } // end else statement
} // end while loop
?>
<tr>
<td class="requestformlabel" align="right"><label class="required">Your E-mail Address:</label></td>
<td align="left" class="requestformtd"><input name="Requestors" size=40 value="<?php echo $_POST['Requestors']; ?>"></td>
</tr>
<tr>
<td class="requestformlabel" align="right"><label class="required">Confirm Your E-mail Address:</label></td>
<td align="left" class="requestformtd"><input name="Requestors_2" size=40 value="<?php echo $_POST['Requestors_2']; ?>"></td>
</tr>
<tr>
<td class="requestformlabel" align="right"><label class="fields">Cc:</label></td>
<td align="left" class="requestformtd"><input name="Cc" size=40 value="<?php echo $_POST['Cc']; ?>"></td>
</tr>
<tr>
<td align="right"><p> <br/> </p></td>
<td align="right"><span class="ccnote">(Separate multiple email addresses with commas.)<br/> </span></td>
</tr>
<tr>
<td class="requestformlabel" align="right"><label class="required">Short Problem Summary:</label></td>
<td align="left" class="requestformtd"><input name="Subject" size=40 maxsize=100 value="<?php echo $_POST['Subject']; ?>"></td></tr>
<tr>
<td class="requestformlabel" align="right"><label class="required">Decribe the issue below:</label></td>
<td align="left" class="requestformtd"><textarea
class="messagebox" cols=35 rows=15 wrap="hard" name="Content"><?php echo $_POST['Content']; ?></textarea>
</td>
</tr>
<?php
//if session has attachments
if($_SESSION['attach'] != '') {
?>
<!-- row for existing attahcments -->
<tr>
<!-- column that states these are the current attachments, and tells the user what to do if
they wish to remove an attachment. -->
<td class="requestformlabel" align="right">Current Attachments:<br/>
<span class="ccnote">(Check box to delete)</span>
</td>
<!-- coulmn that lists the attachments -->
<td class="requestformtd" align="right">
<?php
// Go through each file in $_SESSION['attach']
while (list($key, $val) = each($_SESSION['attach'])) {
// Get the name of the file
$attName = $val['name'];
// Create a checkbox to mark the file as needing to be removed from the list
echo "<input type='checkbox' name='DeleteAttach-$attName' value='1'>$attName<br/>";
} // end while loop
?>
</td>
</tr>
<?php // end if for attachments
}
?>
<tr>
<td class="requestformlabel" align="right"><label class="fields">Attachments:</label></br>
<span class="ccnote">Max. attachment size: 50MB.</span></td>
<td align="right" colspan="2" class="requestformtd">
<input type="file" name="Attach">
<br/>
<input type="submit" name="AddMoreAttach" value="Add More Files">
</td>
</tr>
<tr>
<td align="left"><input type="submit" name="submit" value="Submit Request"></td>
<td> </td>
</tr>
</table>
</form>
Edit 2:
Thanks. Using the documentation and code from this repo I created a new file called new_ticket.php with the following content:
<?php
if($_POST['action'] == 'call_this') {
require_once 'RequestTracker.php';
$url = "www.test.com/rt/REST/1.0/";
$user = "user";
$pass = "password";
$rt = new RequestTracker($url, $user, $pass);
$content = array(
'Queue'=>'9',
'Requestor'=>'test#example.com',
'Subject'=>'Lorem Ipsum',
'Text'=>'dolor sit amet'
);
$response = $rt->createTicket($content);
print_r($response);
}
?>
I also made of copy of RequestTracker.php from the same Github repo.
In the file where the form is located, I added the following script and added create_ticket() as an action to the onclick property of submit button. But this doesn't seem to be working. I tried logging something to the console to see how far the code gets, the create_ticket() function is being called properly but anything that comes after $.ajax({ ... above will not appear to the console. I also tried putting some console logs in my new_ticket.php file but that doesn't log anything either, so what am I doing wrong?
<script>
function create_ticket() {
$.ajax({
url:"new_ticket.php", //the page containing php script
type: "POST", //request type
data:{action:'call_this'},
success:function(result){
alert(result);
}
});
}
</script>
PS: I'm using ajax because I need to run the PHP code onclick and this can't be done directly as it would in Javascript.
Probably the easiest approach is to look at the PHP examples in the REST documentation on the Request Tracker wiki. You don't mention the version of RT you are using, but the REST interface has been stable so this should work with most versions.
I want to pass row fetched from database to view from controller.
foreach ($usertable->result() as $note) {
$note['title'];
$this->load->view('note',$note);
}
but it didn't work.
Strictly, not the right way to send data to view (not inside for loop). This will load the view the numbers of time the loop runs.
Enclosed all the notes data into a variable say via an array data['notes'] and the now in view you can use notes variable for fetching data. Read docs for more info.
In controller:
$data['notes'] = $usertable->result();
$this->load->view('note', $data);
In view:
<table>
<tr>
<td>Note id</td>
<td>title</td>
</tr>
<?php foreach($notes as $n) { ?>
<tr>
<td><?php echo $n->id; ?></td>
<td><?php echo $n->title; ?></td>
</tr>
<?php } ?>
</table>
you can use following.
foreach ($usertable->result() as $note) {
$note[]=$note;
}
$note['title'];
$this->load->view('note',$note);
I have created a new custom template using the New order default template in my Magento admin panel.
There are some default variables available to be inserted into the email. But I want to add some other variables like product description into the email template.
In my email after order creation , I want to send description and other details of all products that are present in my cart.
What I have in template is :
<table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<tr>
<td valign="top">
<img src="xyz.jpg"/>
</td>
</tr>
<tr>
<td>
<?php
$order = Mage::getModel('sales/order')->loadByIncrementId("{{var order.increment_id}}");
$items = $order->getAllVisibleItems();
foreach($items as $i):
echo $i->getProductId();
echo $i->getDescription();
echo $i->getDescription();
endforeach;
?>
</td>
</tr>
I want to achieve something like this. Is it possible adding PHP code into the email template and get the variables working. Or I have to define this php code somewhere else? If yes, can you please specify where to make these changes?
Thanks
I dont think u need to load product object in email template it is already loaded if not u can do that but sure u dont need sales order object that sure.
app\design\frontend\default\imsov2\template\email\order\items\order\default.phtml
<?php echo $this->escapeHtml($_item->getDescription()) ?>
and so on...