I've created a new attribute set from "Default" attribute set.But the media_gallery attribute is missing in the new attribute set.So the image uploader is not showing in product edit section.How do I add that system attribute to the set?
This is at least strange. I would suggest trying to re-create an attribute set based on "Default" to check if the problem will happen again.
In any ways, if you want to add a media_gallery attribute to your existing attribute set you have to add a record to eav_entity_attribute table, where relation of EAV entity to attribute set and group is stored:
INSERT INTO eav_entity_attribute
SET entity_type_id = 4,
attribute_set_id = [YOUR_ATTRIBUTE_SET_ID],
attribute_group_id = [YOUR_ATTRIBUTE_GROUP_ID],
attribute_id = [ID_OF_YOUR_MEDIA_GALLERY_ATTRIBUTE by default 82],
sort_order = 4
The ID_OF_YOUR_MEDIA_GALLERY_ATTRIBUTE can be found in eav_attribute table using the following query:
SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'media_gallery'
The YOUR_ATTRIBUTE_SET_ID can be found in eav_attribute_set table using the following query:
SELECT attribute_set_id FROM eav_attribute_set WHERE attribute_set_name = '[GIVEN_NAME_OF_YOUR_ATTRIBUTE_SET]'
And the YOUR_ATTRIBUTE_GROUP_ID can be found in eav_attribute_group table using the following query:
SELECT attribute_group_id FROM eav_attribute_group WHERE attribute_set_id = [YOUR_ATTRIBUTE_SET_ID] AND attribute_group_name = 'Images'
You can also use PHP to assign attributes to attribute sets:
$installer = Mage::getResourceModel('catalog/setup', 'catalog_setup');
$installer->addAttributeToSet(
'catalog_product', $attributeSetName, $groupName, $attributeCode
);
It is not a programming question, rather it is the question about using Magento as an end-user. I think the question will be deleted soon. However, until it is not, at least this answer may help to solve the problem, thus making people happier.
So all you need is just go to Magento's admin panel -> Catalog -> Attributes -> Manage Attribute Sets. Then select your set to open edit page for it. Drag the media_gallery attribute from the "Unassigned Attributes" list to the appropriate group in the "Groups" list. Save the attribute set.
That's all :)
Related
Please I would like to know how to change the display name (in view mode) of a field in Vtiger 7 when linking a custom module to an existing module such as Account Module. It keeps displaying the default numbering field.
Please see the following 2 images: I would the text "INSURANCE-21" in Image 1 replaced for example by the Insurance company name let say "Williams Insurance Group" in Image 2.
Any idea please?
Please find what is Insurance Company Name of the field name into a database.
for example if field name like insurance_company_name then the queries become like that
UPDATE `vtiger_entityname` SET `fieldname`="insurance_company_name" WHERE `modulename` ='Accounts' and `tablename` = 'vtiger_account';
After a whole night and day of searching, I came out with a solution.
Not sure if any cons. but this is the fix that worked:
I updated this table vtiger_entityname and set the column fieldname to the name of the field that I would like to use as display name for the concerned module.
Hope it helps anyone who want to achieve the same result.
You must change module identifier. If you’ve ever tried to find an option to update a module identifier (the field that works as a link in a module) you most probably have noticed that vtiger do not allow this from the field editor. The only way to do it is using vtiger development library called Vtlib.
use the following code:
// Turn on debugging level
$Vtiger_Utils_Log = true;
$targetmodule = 'InsuranceCompanies';
$targetfield = 'insurance_company_name';
include_once('vtlib/Vtiger/Module.php');
include_once('vtlib/Vtiger/Field.php');
$module = Vtiger_Module::getInstance($targetmodule);
$field = Vtiger_Field::getInstance($targetfield, $module);
$module->unsetEntityIdentifier();
$module->setEntityIdentifier($field);
If you need to revert this back or make a backup, you need to backup the table vtiger_entityname
I would like to add a Text depends on selected Attribute option: I create a Attribute with the optiones YES or NO.
I want to create with php if I select in the Admin Panel yes that if should start another php code (that will show a few text on the category pages)
But if I select No it should not run through the code, I mean don't display the text
If you created a Yes/No attribute (select Yes/No for the Catalog Input Type field), then you can check the value simply using
$_product->getData('my_attribute_code');
This will return either 0 or 1.
So if you try
if($_product->getData('my_attribute_code')){
echo 'My text';
}
Note that depending on the context you may have to load the product first to get this value, so if nothing comes out of the getAttribute function, so you may have to execute this code before the previous one :
$_product->load($_product->getId())
And this should work.
EDIT: Note that this will not work if you create a dropdown attribute and set manually Yes and No as values. You need to chose Yes/No for the Catalog Input Type field of your attribute.
Cheers
I want to load the product base image (main image) in a custom template.
When I use $this->helper('catalog/image')->init($_product, 'small_image'), it works perfectly.
But the base image shows the placeholder instead.
Can someone help me?
The base image cannot be shown in the product list because it is not loaded in the list.
For any other attribute this would be an easy task, just edit the attribute in the backend and set the flag 'Used in product listing' to Yes.
But, unfortunately, for some reason still unknown to me, you cannot do that for image attributes.
You have to do it manually in the db. (yes I've said it...modify the db manually against all rules that say not to).
First you need to identify the base image attribute.
select *
from
eav_attribute
where
attribute_code = 'image' and
entity_type_id IN
(select
entity_type_id
from
eav_entity_type
where
entity_type_code = 'catalog_product'
)
This should get you one row. Take the id column from the result (for me is 85) and run the following query that will set the attribute as used in product listing.
update
catalog_eav_attribute
set
used_in_product_listing = 1
where
attribute_id = 85
Replace 85 with the value you get from the first select then rebuild your indexes from System->Index Management.
Now you should be able to call the following code with success.
$this->helper('catalog/image')->init($_product, 'image')
i have several attribute sets in my magento store. (v. 1.6.2)
When i make a new product "socks" is the default attribute set. But i would like "clothing" to be the default.
How can i change this?
I hope anyone can help.
Original question didn't seem to get answered here and I was looking for what Ronny also wanted.
Found there has been an extension released that does it simply for you.
http://www.magentocommerce.com/magento-connect/default-attribute-set.html
Unfortunately, it's not possible. You should create new product.
To change an existing product attribute set, you can Create a new Attribute Set that contain all the attributes you need
You can either install this extension (Change Attribute Set) or make the changes in the database (you will need to know the products id and attribute set id)
To manually change (Always backup before making changes):
Go to eav_attribute_set table and look for the attribute_set_id of the newly create attribute set (you could also get this in the admin by look at the url www.xxxx/edit/id/10/key/xxx on Edit Attribute Set 'xxxx' page)
After you have a list of all the product ids and corresponding attribute set ids, then go to the table below and update those fields
Table Name : catalog_product_entity
Field Name : attribute_set_id
Field Name : entity_id // is product_id
Another way is to delete those product and recreate using the new attribute set.
It is possible to accomplish what you want by editing the database directly. Only do this if you are comfortable with MySQL commands or another tool like phpMyAdmin.
To make this change you will need to do two things.
Get the ID of your new attribute set, in this case your "clothing" attribute set. You can locate the id in the eav_attribute_set database table or in the browser URL when editing the attribute set from the Magento admin area. I prefer to just use the database since we need to go in there anyways to make the change.Table Name : eav_attribute_set
Column Name: attribute_set_id
Look for the row in the table that has the name you used when you created the new set - it should be pretty obvious, you'll see all the attribute set names in the column called attribute_set_name
Once you have the preferred attribute set ID you then need to visit the eav_entity_type table and update the value in default_attribute_set_id column for the row whereentity_type_id = 4 and entity_type_code = catalog_product. In a fresh installation of Magento, the value to look for in this column is also 4.
Table Name : eav_entity_type
Column Name: default_attribute_set_id
Done! Once you've changed the id value you will notice your preferred attribute set is the one selected by default the next time you go to create a new product. I believe this is what the question was asking for.
NOTE: This should work for both Magento 1 and 2. At the time of writing this post the current Magento versions are: 1.9.2.4 and 2.0.7
I have two fields... one is category name and other is document title... When i click on submit... the document title should be saved in document table linking to the category name selected... which is in other table.
A category can have n number of document titles...
$result = mysql_query("UPDATE stinky_menu SET description = '$docuTitle', url = '$linkTitle' WHERE title = '$catID'");
How can i perform another query to my other table to in WHERE clause.
Generally I handle this kind of case by having the select box in the HTML form return the Category ID, not the title. That allows me to insert or update the record without the need for an additional lookup to my reference tables (in this case your category table).
Using :named form for the parameters (?-form also works of course), simplest way to do what you want is to use a FROM and JOIN in your UPDATE -- something like (depending on some details you haven't provided):
UPDATE stinkymenu
SET description = :docuTitle, url = :linkTitle
FROM stinkymenu
JOIN categorytable
ON stinkymenu.catId = categorytable.id
WHERE categorytable.title = :catId
See PDO's docs for the way to use such a "prepared statement" and bind its parameters to your variables.