Adding values to a magento dropdown or multi-select product attribute while adding a new product - php

I'm wondering if anyone has found or written an extension that would allow a magento website administrator the ability to add values to their products attribute while adding the product. For example, if I sell books and want the book author to be in a drop down list so that it would be used in layered navigation, it seems odd that I would have to add the author via the attributes section before adding the product. From a workflow standpoint it really makes sense to have an "add new value" button next to the drop down on my add product screen.
Anyone have any thoughts or insight?

It's a piece of cake to do, if you know jquery and the (if I may guess) extremely simple model behind magento.
As the other guy said, throw some money and I'll do it ;)
Otherwise, real easy -> find where that dropdown is generated, add a button next to it that opens a popup which you fill "create a new thingie" stuff, create button -> +create +close +refresh your dropdown.
Definitely easy.
And considering the attribute dialog already exists in the tool you cold probably take most from there and just add the popup handlers / button / +refresh .

This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, import images and media galleries, reindex, refresh cache, media and price rules automatically. In addition you can backup the entire database in SQL format.
So from above, once you make the csv file, you just have to add the Author header and it would build the list from there. However, the attribute must exist first. I am using this method for the creation of my own manufacturer attribute options.
AMartinez_CustomImportExport

Can't say I have, but I've developed something similar that creates an attribute and adds it to multiple products, it's completely possible, you just need to add something that will call the add attribute on the add product page or change the new product flow to allow a new attribute and add it if needed.
Don't let them scare you, it's not as hard as some people might describe :)

My curiosity finally took over my laziness and I managed to create the module author requested. It's available on github.
Please feel free to check it out and update it if you wish. Maybe in some near future I'll post it on Magento Connect, if feedback is good.

Here's some code that checks if an attribute value exists and adds it if it doesn't: http://www.magentocommerce.com/boards/viewthread/26234/
Shouldn't be too hard to integrate it with the "Add product" form.

Related

Kanboard Custom Fields

Customization work regarding Kanboard
I need to add custom fields to the create new task form. Can this be achieved using Metadata Manager plugin?
Will I need to hire a developer to get this done?
Currently there's only Title, Description & Tags available. I Just need to add three more fields to show in the task box in Kanban view.
Thanks!
No, the Metadata plugin will not achieve that. There is a plugin that will allow you to create custom fields that will be included on the create task form, but since you didn't ask, I cannot tell you which plugin (I tried already, and it was downvoted and deleted because it didn't answer your question apparently)
No, you will not need to hire a developer to get this done, assuming you can find the plugin I am referring to.
With said plugin, you will be able to add as many custom fields as you wish, as well as, including them in task exports, filtering, change their type, etc...
Good luck in your search!

Custom Fields, linking to a separate download page?

Afternoon all,
I have some Advanced Custom Fields set up, which allow the user to download files which are appropriate to a certain product.
For example, if the product was 'Product 1', the files would be 'Product 1 size' etc. This works perfectly, using the following:
Brochure
This adds the file which is added on each individual page, as in ACF I have set the location rules as shown in the screenshot
Now, the issue is as follows.
I need to create a whole new page, called downloads.
This page, will list all the products in my page, and then need to have the downloads available (the Custom Field File). Now, because this field is set up to show on the product pages, I am completely unsure as to how to show the downloads on a seperate page, because using
Brochure
is technically not telling me which product this is for.
I hope this makes sense.
EDIT:
I completely forgot to mention, this information will need to be inside a table, and I am currently using TablePress, a plugin.
So it would go like:
Prouduct --- Category --- Download
Thank you all!
After you have edited your question, my first answer does not make sense anymore. So here is what I suggest now:
A. This is the solution to what you actually asked
Install the Reveal IDs Plugin so you can see in the admin panel what post-IDs your products have
Look up the ID for a specific product
In your TablePress table-cell you paste the ACF-shortcode:
Download brochure
post_id="12": this is the ID of your product-post which you can look up with Reveal IDs.
I already tested this right now, so I do know it's working.
B. Another solution that is more a question
Your ACF field 'brochure' obviously contains a URL to a file which might be available in your WP media library too?!
When this is the case you don't need the ACF field for your table. You can just:
click "Advanced Editor" (when working with the table)click into a table cell
click into a table cell
click "Add files" and link to your file directly this way
Maybe that is an option too.
I think I understand what you're trying to do. This should point you in the right direction: http://www.advancedcustomfields.com/resources/query-posts-custom-fields/

Prestashop - How to add a custom input field to product customization and write to db

Having gained no response on the official Prestashop forum, I thought I would try turning to you guys, my first post. Thanks for reading.
I am building a site that sells personalized items, and it is essential that i can limit the characters entered into the customization fields for each item, a feature that is still sadly missing from Prestashop, so I am endeavoring to incorporate the feature myself.
Having tinkered about a bit, I have the front end working nicely, using maxlength to limit the characters allowed in the customization input field using a value read from the database in a new field 'max_chars' in the ps_customization_field (entering the values manually at the moment)
But now I have reached the limit of my knowledge and as much as i hunt around and tinker I cannot get the last bit done, so hopefully someone more knowledgeable than I can help.
Basically, when creating the customization fields in the back office, I need an extra input field that allows me to enter the max_chars for each customization, I then need this value to be written to the database in the max_chars field of ps_customization_field table.
TL:DR How do i create a new field in the back office product customization area and save the input to the db.
Kind regards,
Clive
Your question about "how to save input to my db" is too broad to be answered in a single answer. Look up how SQL queries and PDO work, as they may give you an idea on how to start.
Displaying your customization fields in the frontend can be done as following with Smarty:
{foreach $inputfields as $field}
<input type="{$field.type}" name="{$field.name}" maxlength="{$field.maxlength}">
{/foreach}
I think you should create a module for that. Simply make a module which add a tab to the admin product controller, and list all customized field created. Then, make a form with a simple id_customization => maxcharacter relationship.
The last thing you need is to create a hook in this module and add it in the product front controller where customizations are saved (inside initContent i think). This hook will do the validation and may cancel the process by throwing an error (a prestashop's error of course).
With that, you can add some extra validations for your fields, like a type validation, or anything else.
If you never made it, you should try this one : create a module
Here are some extra clues :
Hook for extra product tabs :
$this->registerHook('displayAdminProductsExtra')
Create the validation hook :
$this->registerHook('CFvalidation')
Handle it :
public function hookCFvalidation($param)
{
//Validate the customized values in the $_POST
//return formated errors if any or nothing if it's valid
}
Add it in the overrided product controller :
[...]
if (Tools::isSubmit('submitCustomizedDatas'))
{
$this->errors[] = Hook::exec('CFvalidation');
[...]
}
To display your inputs you need to override the method _displayLabelField in controllers/admin/AdminProdutsController.php.
To update the fields you need to override the method updateLabels in classes/Product.php.

Defining dynamic pages in wordpress plugin

I am creating my first wordpress plugin. In it, the user will have the option to add new cities and view events on those cities.
My client requirement is that the URL must be like this
SITE_NAME/cities/NY
or
SITE_NAME/cities/Califonia
What is decided is that i will create a folder cities and If user tries to create a new city i will create a file in that folder with that city, Further more I will add the entry into the database as well.I will insert PHP code into the file as well.
Being new to WP plugins. Is my approach right (for creating files)? Is there any other way?
Your approach would work if you WEREN'T using Wordpress, but I would absolutely not advise doing what you're suggesting within the Wordpress Framework.
Rather than trying to reinvent the wheel, just about everything you want can be achieved with existing Plugins. I would absolutely suggest taking this route, especially if you don't have much experience with programming Wordpress Plugins.
Step 1:Install Wordpress
Self-explanatory. Can't do anything without this.
Step 2:Install Types
Installing the Types Plugin will give you a nice interface for registering your own Custom Post Types and many other features for extending Wordpress' core capabilities.
Step 3:Register your Custom Post Type
This is where things start to get complicated. Using Types, Register a Custom Post Type called Event. The reason why you want to have each event as its own Post is because each Event is unique. Cities are meant to encapsulate and define groups of events, which brings us to our next step:
Step 4:Register your Custom Taxonomy
Think of a Taxonomy as a way to classify things. Wordpress comes with two default Taxonomies: Categories (hierarchical) and Tags (non-hierarchical). In your case, you will want to define for your new Event Post Type a non-hierarchical Taxonomy called "Cities".
Step 5:Register your Custom Fields
Custom Fields are the easy part. What defines your event? Maybe some fields that define the start and end times of that particular event? A checkbox denoting free refreshments? The sky's the limit. What defining characteristics would all Events have that makes it an Event? Add those in the form of Custom Fields. These will show up on your Event Editor in the form of Meta Boxes. If you don't see the Meta Boxes on the Edit Page for a particular event, be sure to enable it by clicking Screen Options in the upper-right-hand corner of your screen and ticking the checkbox where your fields would be located.
Step 6:Configure your Permalinks
Much of this can be done either through Types itself (when configuring your Custom Taxonomy), or through .htaccess rewrites, or perhaps even through the Wordpress Permalinks Settings (though, it's fairly limited). My suggestion is to tweak your Custom Taxonomy and Permalink Settings first before messing with .htaccess.
And that's it! Hopefully this should be enough to get you started on everything you need.
maiorano84 wrote a fairly comprehensive guide to setting up the stuff you need, Rather than relying on plugins though, I prefer to show you how to write a plugin to register the custom post type and taxonomy. To that effect, I wrote a little plugin that should do everything you need and it has plenty of comments and links to the docs so that you can understand the Why of things.
Code
https://github.com/fyaconiello/WP_Cities_Events
This plugin does several things
Creates a custom post type Event
Creates a custom taxonomy City
Adds custom metaboxes to Event
Adds City taxonomy to Event
This plugin does not require any additional plugins to be installed, it is dependency free and only uses WP core.
URLS
As far as getting the correct URL Structure, I would suggest you read this thoroughly: http://codex.wordpress.org/Using_Permalinks.
I do not understand the structure you want
CITY is a single term w/i the taxonomy *cities*
EVENT is the post single
SITE_URL/cities/CITY would yield a page of all EVENT posts in that CITY
you need a url like: SITE_URL/cities/CITY/EVENT to read a specific event in a specific city
EDIT on how to urls:
In your Settings -> Permalinks administration panel select: "Post name" and save.
Then, go to your Ce Events -> Cities admin screen.
hover over one of your terms (in my case new york city) and click view.
it should open up that term(city)'s list view and the url structure looks like so: http://wp.local/city/new-york-city/
if you need city to read cities, modify line 102 of the main plugin file i shared with you:
'rewrite' => array('slug' => 'city'),
EDIT 2
Why not create City as a Custom Post Type? You can then define a slug 'cities' and get that result, and also add taxonomies like categories and tags to further aid navigation.
Don't do that. WordPress gives you a goog API for doing what you want to do: managing pretty URLs (slugs), database operations (you don't need to write/read files for that) and the right code workflow for registering and triggering actions.
So, I think you have to start reading the basics about WordPress plugins (its philosophy and API) and then just decide if you want to use its custom post types (ready to use) or if you want to create a specific content type.
yes this is fine approach.One more thing that you can do is that instead of adding the code inside the fie..Pick the code from DB.
Make a table in DB,create a column with varchar as datatype and insert the common code in it .

Modx custom tv with multiple inputs

I need to build a custom tv in modx that will all a user to select a image, a title and a date.
Can't seem to find any help other than the docs with although detailed don't answer my problem.
Anyone done this before and are able to advise me further
Cheers
I'm not 100% sure, if this is what you're trying to archieve, but I think multiItemsGridTv (MIGX) for modX revolution is what you want.
From the docs:
MIGX (multiItemsGridTv for modx) is a custom-tv-input-type for adding
multiple items into one TV-value and a snippet for listing this items
on your frontend.
It has a configurable grid and a configurable tabbed
editor-window to add and edit items. Each item can have multiple
fields.
For each field you can use another tv-input-type.
Essentially, you can make up a set of multiple different template variables (including images), that always belong together. If you then assign your MIGX tv to a template, you can enter as much of these sets as needed per resource.
You can download it via package management or from the modX Extras Repository.

Categories