how to remove that from drop-down?
while at the same time if we choose this option the original price will change as well.
Magento – remove extra price from dropdown in configurable product
configurable-productmagento-1.9
Related Solutions
<?php
class Websanity_Cataloginventory_Adminhtml_StockController extends Mage_Adminhtml_Controller_action
{
/*
* initial layout
*/
private function _init(){
return $this->loadLayout();
}
/*
*
*/
public function indexAction() {
$this->_init();
$this->renderLayout();
}
public $productIdsExcel = array();
public $productsExcel = array();
public $updatedSku = array();
public $unUpdatedSku = array();
/*
* Import product with csv file
*/
public function importCatalogInventoryAction(){
try
{
$path = Mage::getBaseDir() . DS . 'var' . DS . 'websanity' . DS . 'tmp' . DS ; //desitnation directory
$fname = $_FILES['stockfile']['name'];
$arrayData = array();
$file_path= $path . $fname;
$arrayData = $this->excelToArray($file_path);
foreach($arrayData as $row)
{
$productSku = $row["sku"];
$attribute = $row["attribute"];
$attributeValue = $row['attribute_value'];
$price = $row['attribute_price'];
$attributeId = $this->getAttributeId($attribute);
$productId = $this->getProductId($productSku);
//Product-id collection from excel
$this->productIdsExcel[] = $productId;
//Price for each product and it attrivbutevalues collection from excel
$this->productsExcel[$productId][$attribute][$attributeValue] = $price;
$optionId = $this->attributeOption($attributeId, $attributeValue);
$superAttrbuteId = $this->getSuperAttributeId($productId, $attributeId);
$addPrices = $this->addPrices($superAttrbuteId, $optionId, $price);
}
$this->productIdsExcel = array_unique($this->productIdsExcel);
$productIds = $this->productIdsExcel;
foreach($productIds as $pid){
$_product = Mage::getModel("catalog/product")->load($pid);
$prod = $this->getAssociatedProducts($_product);
foreach($prod as $simpleprod)
{
if($simpleprod->getData('LIGHTSPEED_PRODUCT_SIZE'))
{
$sizeId = $simpleprod->getData('LIGHTSPEED_PRODUCT_SIZE');
$sizeAttributeValues = $this->getAttributeValues($sizeId);
foreach($sizeAttributeValues as $size){
$sizeValue = $size['value'];
}
$sizeAddtional = $this->productsExcel[$pid]['size'][$sizeValue];
$updatedSku[] = $simpleprod->getSku() ."- Size";
}
else
{
$unUpdatedSku[] = $simpleprod->getSku() ."- Size";
}
if($simpleprod->getData('LIGHTSPEED_PRODUCT_COLOR'))
{
$colorId =$simpleprod->getData('LIGHTSPEED_PRODUCT_COLOR');
$colorAttributeValues = $this->getAttributeValues($colorId);
foreach($colorAttributeValues as $color){
$colorValue = $color['value'];
}
$colorAddtional = $this->productsExcel[$pid]['color'][$colorValue];
$updatedSku[] = $simpleprod->getSku() ."- Color";
}
else
{
$unUpdatedSku[] = $simpleprod->getSku() ."- Color";
}
$base = $_product->getPrice();
$basePriceAddition = $base + $colorAddtional + $sizeAddtional;
$simpleProductPrice = $simpleprod->setPrice($basePriceAddition)->save();
}
}
$update = "";
$update .= "<h2>Records Updated</h2>";
foreach($updatedSku as $updated)
{
$update .= $updated ."<br/>";
}
$update .= "<h2>Records Not Updated</h2>";
foreach($unUpdatedSku as $unUpdated)
{
$update .= $unUpdated ."<br/>";
}
Mage::getSingleton('adminhtml/session')->setMyValue($update);
$this->_redirectUrl( Mage::helper('adminhtml')->getUrl('*/adminhtml_stock/') );
}
catch (Exception $e)
{
Mage::getSingleton('adminhtml/session')->addError( $e->getMessage() );
}
}
public function getAssociatedProducts($productId)
{
try{
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($productId);
$prod = $conf->getUsedProductCollection()
->addAttributeToSelect('*')
->addFilterByRequiredOptions();
return $prod;
}
catch(Exception $e){
echo $e->getMessage();
}
}
public function getAttributeValues($attributeId)
{
try{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$table = $resource->getTableName('eav/attribute_option');
$query = 'SELECT value FROM xyzeav_attribute_option_value WHERE option_id=' .$attributeId;
$results = $readConnection->fetchAll($query);
return $results;
}
catch(Exception $e){
echo $e->getMessage();
}
}
public function excelToArray($file_path)
{
try{
chmod($file_path,0777);
error_reporting(E_ALL ^ E_NOTICE);
require_once Mage::getBaseDir().'/excel_reader2.php';
$excel_reader = new Spreadsheet_Excel_Reader();
$excel_reader->setUTFEncoder('iconv');
$excel_reader->setOutputEncoding('CP1251');
$file=$excel_reader->read($file_path,"UTF-16");
$file_row=2;
$column_count=$excel_reader->sheets[0]['numCols'];
$row_count=$excel_reader->sheets[0]['numRows'];
$excelData = array();
for($file_row;$file_row<=$excel_reader->sheets[0]['numRows'];$file_row++)
{
$excelData[$file_row]["sku"] = $excel_reader->sheets[0]['cells'][$file_row][1];
$excelData[$file_row]["attribute"] = $excel_reader->sheets[0]['cells'][$file_row][2];
$excelData[$file_row]["attribute_value"] = $excel_reader->sheets[0]['cells'][$file_row][3];
$excelData[$file_row]["attribute_price"] = $excel_reader->sheets[0]['cells'][$file_row][4];
if($excelData == "")
{
break;
}
}
return $excelData;
}
catch(Exception $e){
echo $e->getMessage();
}
}
public function attributeOption($attributeId, $color)
{
try{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$table = $resource->getTableName('eav/attribute_option');
$query = 'SELECT option_id FROM xyzeav_attribute_option_value WHERE value="'.$color.'" AND option_id in (SELECT option_id FROM ' . $table . ' WHERE attribute_id = '
. (int)$attributeId.')';
$results = $readConnection->fetchAll($query);
return $results[0]['option_id'];
}
catch(Exception $e){
echo $e->getMessage();
}
}
public function getSuperAttributeId($productId, $attr1)
{
try{
$getSuperAttributeId = Mage::getModel('catalog/product_type_configurable_attribute')->getCollection()
->addFieldToFilter('product_id', $productId)
->addFieldToFilter('attribute_id', $attr1)->getData();
return $getSuperAttributeId[0]['product_super_attribute_id'];
}
catch(Exception $e){
echo $e->getMessage();
}
}
public function addPrices($superAttrbuteId, $optionId, $price)
{
try{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$writeConnection = $resource->getConnection('core_write');
$query = 'SELECT * FROM xyzcatalog_product_super_attribute_pricing WHERE product_super_attribute_id='.$superAttrbuteId.' AND value_index='.$optionId;
$results = $readConnection->fetchAll($query);
$getExistingPrice = $results[0]['value_id'];
if(!$getExistingPrice)
{
$insertQuery = 'INSERT INTO xyzcatalog_product_super_attribute_pricing (product_super_attribute_id, value_index, is_percent, pricing_value, website_id) VALUES('.$superAttrbuteId.','.$optionId.',"0",'.$price.',"0")';
$QueryValue = $writeConnection->query($insertQuery);
if(!$QueryValue)
{
$result = "Mismatch Values";
}
else
{
$result = "Inserted";
}
}
else{
$new_query = 'UPDATE xyzcatalog_product_super_attribute_pricing SET pricing_value='.$price.' WHERE product_super_attribute_id='.$superAttrbuteId.' AND value_index='.$optionId;
$QueryValue = $writeConnection->query($new_query);
if($QueryValue)
{
$result = "Mismatch Values";
}
else
{
$result = "Updated";
}
}
return $result;
}
catch(Exception $e){
echo $e->getMessage(addPrices,'Mismatch Values');
}
}
function printError($fromFunction, $message){
echo "<hr />";
echo $fromFunction;
echo $message;
echo "<hr />";
}
public function getProductId($productSku)
{
try{
$productId = Mage::getModel('catalog/product')->getCollection()
->addFieldToFilter('type_id', 'configurable')
->addFieldToFilter('sku', $productSku)->getFirstItem()->getId();
return $productId;
}
catch(Exception $e){
echo $e->getMessage();
}
}
public function getAttributeId($attribute)
{
try{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$superQuery ='select b.attribute_id from xyzcatalog_product_super_attribute_label a inner join xyzcatalog_product_super_attribute b on a.product_super_attribute_id = b.product_super_attribute_id where a.value ="'.$attribute.'"' ;
$superAttribute = $readConnection->fetchAll($superQuery);
foreach($superAttribute as $super)
{
$superId=$super['attribute_id'];
}
return $superId;
}
catch(Exception $e){
echo $e->getMessage();
}
}
public function getParentProductId()
{
try{
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$childQuery = 'select product_id from xyzcatalog_category_product_index where is_parent = 1';
$childResults = $readConnection->fetchAll($childQuery);
return $childResults;
}
catch(Exception $e){
echo $e->getMessage();
}
}
}
?>
- I have tried this code in my custom module. i uploaded the data's through Excel sku,attribute,label,price.
- I have used the excel reader to retrieve the values
Welcome to the wonderful world of configurable product pricing.
If you don't want to install an extension you need to set the configurable product to the price of the base item (75cm @ $2400) and the price of the 85cm option to $73 fixed, which will make it always more $73 more expensive than the 75cm one (and will display (+$73) in the option dropdown with the default theme.
Assuming the simple products are not in the catalog or searchable, the price you set for them is irrelevant.
As Reinsch has said, there are extensions around that will try and work in an easier to use format.
Related Topic
- Magento – Configurable Product with associated individual product doesn’t show
- Display Least Selling Special Price on Configurable Product View Page
- Magento – Show both regular & special price on configurable products
- Magento – Magento2 how to remove “choose an option” in configurable products drop down
Best Answer
in order to remove that additional price entirely you have to over write functionality of below script:
/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php
GO to line number : 70 and change the code with this code snippet :
From :
To :
you will find workaround this block, hope it will help