When we used autocomplete in opencart admin then it shows a drop down list of product names (just Like a featured products modules). I want to show model number instead of product name. if anyone know how i can do it ?
Thanks in advance.
I think you need to show instead on product name show model name or some other thing.
go to admin-->controller-->module-->featured modules(any other)
goto to code
if ($product_info) {
$this->data['products'][] = array(
'product_id' => $product_info['product_id'],
'name' => $product_info['product_name']
);
}
replace it into your needs
if ($product_info) {
$this->data['products'][] = array(
'product_id' => $product_info['product_id'],
'name' => $product_info['model']
);
}
now you just need to refresh it. Product name will replace into model name in admin panel.
'name' => strip_tags(html_entity_decode(
$result['model'] . ' - ' . $result['name'],
ENT_QUOTES,
'UTF-8'
)),
gives model and name.
Related
here my comma separated column is shops(eg. 1,2,3,4), and with the call back i am already displaying the multiple shops names. with call back i am showing the related shop-names(values shows eg. Shop1,Shop2,Shop3,Shop4).
is there a way i can filter it with the values i am displaying.
$this->fields_list = array(
'id_push' => array('title' => $this->l('ID')),
'shops' => array('title' => $this->l('Shop(s)'),'callback' => 'getShopName','type'=>'editable')
);
You should include a concatenated shop name field in your controller SELECT. Then you should specify filter_key parameter in your shops fieldlist field. Something like this:
$this->_select = ' a.`correct_field_name` AS `shopnames_custom_field`';
$this->fields_list = array(
'id_push' => array('title' => $this->l('ID')),
'shops' => array('title' => $this->l('Shop(s)'),'callback' => 'getShopName','type'=>'editable', 'filter_key' => 'shopnames_custom_field')
);
If this solution does not work you should modify getList function to custom filter results.
Good luck
I need to show one certain product on front page. I didn't find a module for this. What do I need to do? I need to show product with countdown timer but I can do this, I only do not know how to get product from database by ID or SKU. I guess the code should be like this:
echo $product_option_data[] = array(
'product_option_id' => $product_option['product_option_id'],
'option_id' => $product_option['option_id'],
'name' => $product_option['name'],
'type' => $product_option['type'],
'option_value' => $product_option['option_value'],
'required' => $product_option['required']
);
In OpenCart controller you can call
$this->load->model('catalog/product'); // only if not yet 'loaded' within the controller
$product = $this->model_catalog_product->getProduct($productId);
print_r($product);
which will return you the product by it's ID. Do with it whatever you need afterwards.
I've got the following code:
$filters = array('sku' => array('like'=>'%'));
$items = $magConn->call($sessionID, 'product.list', array($filters));
This will return an array of all the products and their sku, description, and qty.
However, I also need to get the price? Is there a way to get that as well?
I've also got this working,
$properties = ($magConn->call($sessionID, 'product.info', $item['sku']));
which will return all the attributes for one product. I've got over 2,000 products, and this is definitely not feasible if I want it to end tonight. ;)
No way without magento source code modification. You should go to \app\code\core\Mage\Catalog\Model\Product\Api.php, find next lines inside items() method:
$result[] = array( // Basic product data
'product_id' => $product->getId(),
'sku' => $product->getSku(),
'name' => $product->getName(),
'set' => $product->getAttributeSetId(),
'type' => $product->getTypeId(),
'category_ids' => $product->getCategoryIds()
);
and add price here.
Load the collection :
$product = Mage::getModel('catalog/product')->load($productId);
Get actual price :
$product->getPrice();
Get special price :
$product->getFinalPrice();
I'm trying to get bundle options data. using this : $product->getBundleOptionsData I need to use this, as I'm trying to change data programmatically and I would like to do it in a way that's as close as used in admin .
However, when I var_dump the result of the above function I get NULL while in admin side in bundle model product type I get correctly the data.
When I var_dump $product in my own file I get much shorter data than when I var_dump in bundle model product type save function.
what do I need to do to load all data of the product, so I can use getBundleOptionsData. I looked in several files and googled, but can't find an answer.
Finally I made it work to get bundle options data so I can manipulate it. I found the main code in magento's model bundle observer class duplicateProduct function: I needed however to add option_id (careful not to forget that)
here is the code in it's final stage.
$product->getTypeInstance(true)->setStoreFilter($product->getStoreId(), $product);
$optionCollection = $product->getTypeInstance(true)->getOptionsCollection($product);
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
$product->getTypeInstance(true)->getOptionsIds($product),
$product
);
$optionCollection->appendSelections($selectionCollection);
$optionRawData = array();
$selectionRawData = array();
$i = 0;
foreach ($optionCollection as $option) {
$optionRawData[$i] = array(
'option_id' => $option->getOptionId(), //my addition. important otherwise, options going to be duplicated
'required' => $option->getData('required'),
'position' => $option->getData('position'),
'type' => $option->getData('type'),
'title' => $option->getData('title')?$option->getData('title'):$option->getData('default_title'),
'delete' => ''
);
foreach ($option->getSelections() as $selection) {
$selectionRawData[$i][] = array(
'product_id' => $selection->getProductId(),
'position' => $selection->getPosition(),
'is_default' => $selection->getIsDefault(),
'selection_price_type' => $selection->getSelectionPriceType(),
'selection_price_value' => $selection->getSelectionPriceValue(),
'selection_qty' => $selection->getSelectionQty(),
'selection_can_change_qty' => $selection->getSelectionCanChangeQty(),
'delete' => ''
);
}
$i++;
}
$product->setBundleOptionsData($optionRawData); //changed it to $product
$product->setBundleSelectionsData($selectionRawData); //changed it to $product
you can either now change on the raw data in optionsrawdata. or getBundleOptionsData. and same for the other one.
Alright, so I'm working on my own script that reads specific xml files, and imports products. Now, each of these products may have a set of attributes, (i.e. color for example).
So, what I'm doing is importing each custom attribute, and generating a specific string, "Yellow, black finish wood" for example, and that would be a radio button you could select from when you go to order the product. Now, when I come to a product that has the same "parentid" but a different unique id, I need to generate a new row for the custom option radio button, so if there is another product where the color is red, I would have the following to select from:
Red, black finish wood
Yellow, black finish wood
This is working great for the first product with the same parent id, in other words, if I'm creating a brand new product, and not just adding custom options to the same product.
My question is, how do I generate a new custom option value, for the specific option? In other words, how do I add a new row to a certain option that is already created?
Here is basically what I'm doing to generate the first option on a new product.
$options = array();
$options[$ParentID] = array(
'title' => 'Option Title',
'type' => 'radio',
'is_require' => 1,
'values' => array()
);
$options[$ParentID]['values'][] = array(
'title' => 'Option Value Title',
'price' => 0.00,
'price_type' => 'fixed',
'sku' => $UniqueID,
);
foreach($options as $ParentID => $option) {
$id = Mage::getModel('catalog/product')->getIdBySku($ParentID);
$product = Mage::getModel('catalog/product')->load($id);
if(!$product->getOptionsReadonly()) {
$product->setProductOptions(array($option));
$product->setCanSaveCustomOptions(true);
$product->save();
}
}
this works out great, because magento generates an sku when they order a certain product in the format of $ParentID_$UniqueID, and then I can send the $UniqueID off to the vendor for the order.
So again, I'm open to suggestions as to how to add a Option Value to an already created Custom Option
load all options in and create array map with unique and already existing options to get their id -s in place