My current scenario:
I am given a spreadsheet similar to what we used to import products to Amazon. In this spreadsheet are multiple columns for Amazon's "bullet points" area. These are then combined into one cell on my Magmi import spreadsheet, separated by line breaks to form our short description
area.
What I'd like to accomplish:
Instead of combining these columns manually, I plan to setup new custom text/text-area attributes named bullet_1
, bullet_2
, etc.. and import each column's information into each attribute individually. I will not add calls to these attributes into the view.phtml
for product pages - but instead want to reference them in a .phtml
file between line-items in an unordered list.
The new bullet
attributes will always have content starting from the lowest number to the highest, so there would be no gaps until there is no more bullet point information to add. Adding to the custom array can stop when an empty bullet
attribute is found.
bullet
attributes will always be text strings. There will be no code imported into these attribute text fields.
In the short description
area on the product import spreadsheet, I'll have the call to this (hopefully) universal .phtml
file.
The .phtml
file would work something like this:
<?php
$bullet1 = $product->getData('bullet_a');
$bullet2 = $product->getData('bullet_b');
$bullet3 = $product->getData('bullet_c');
$bullet4 = $product->getData('bullet_d');
$bullet5 = $product->getData('bullet_e');
$bullet6 = $product->getData('bullet_f');
$bullet7 = $product->getData('bullet_g');
$bullet8 = $product->getData('bullet_h');
$bullet9 = $product->getData('bullet_i');
$bullet10 = $product->getData('bullet_j');
$bullets = array("$bullet1","$bullet2","$bullet3","$bullet4","$bullet5","$bullet6","$bullet7","$bullet8","$bullet9","$bullet10");
echo "<ul>\n";
foreach($bullets as $bullet){
if (!empty($bullet)){
echo "<li>". $bullet . "</li>\n";
}
}
echo "<ul>\n";
?>
I'll end up minifying this .phtml
file as our current theme/template/coding is auto adding line breaks when a new line is used in the short description
area. This does not happen in our description
area.
Please feel free to ask questions if I didn't explain this well enough. I'm also open to other methods of making this happen - and can even pay if this needs to be super custom coded.
Thank you!
UPDATE: later that same day
I've had some help with writing the phtml file but am getting errors when trying to call the attribute and use it as a variable. What do I have wrong?
<ul><li>-{{preg_replace("/[\n\r]/","</li><li>",{item.attributename})}}-</li></ul>
<ul><li>-{item.attributename1}</li><li>{item.attributename2}</li><li>{item.attributename3}-</li></ul>
$product
your this case?