Hi,

I would like to give something back to Drupal comunity. I have created a module which extends Ubercart 3.0. It is my first module.

Name of the module: UC Attribute Stock
Sandbox: http://drupal.org/sandbox/MPeli/1173936
The intended Drupal core version: 7.x

This modules works with attributes of products. It allows you to combine several attributes info one and keep track of stock level.

http://drupal.org/sandbox/MPeli/1173936
http://drupal.org/files/issues/schema.jpg

Thanks for your time.

CommentFileSizeAuthor
#14 coder.png59.12 KBMPeli
uc_attribute_stock.zip5.74 KBMPeli

Comments

jpontani’s picture

Category: support » task
Status: Active » Needs review
tr’s picture

Issue tags: +PAReview: Ubercart

Tagging.

When submitting your project application, please remember to include the following:

The name of your module or theme.
A detailed description of what it does.
A link to its sandbox project on Drupal.org.
The intended Drupal core version (eg. 6.x or 7.x)

You should also mention Ubercart in your description, so people who review Ubercart modules can find this application in a search.

Woggers’s picture

+1 Get this module active! It is crucial for Ubercart!

Exactly what my clothing line client is requiring!

tr’s picture

@Straddle: Perhaps you can provide a review then ...

klausi’s picture

Status: Needs review » Needs work
  • git release branch missing, see http://drupal.org/node/1015226
  • lines in README.txt should not exceed 80 characters
  • uc_attribute_stock_schema(): indentation error on the first line
  • "Implementation of hook_schema" should be "Implements hook_schema().". See http://drupal.org/node/1354#hookimpl
  • "Fieldgroup module.": LOL, copy & paste error?
  • uc_attribute_stock_form_access(): why do you need this function if it always returns TRUE?
  • "if ($form_state['rebuild'] == TRUE) {" that if-statement is empty, so please remove it.
  • uc_attribute_stock_form_alter(): indentation errors, always use 2 spaces per level. Run coder to check your style http://drupal.org/project/coder
  • attribute_form_validate(): all functions need to prefixed with your module name to avoid name clashes. Same for get_attributes()
  • uc_attribute_stock_form(): add doc blocks to all your functions, so that is is clear if they are hook implementations, form/page callbacks, API functions, helper functions etc.
MPeli’s picture

Status: Needs work » Needs review

Thanks for the review.

I have tried to fix all the requirements.

http://drupalcode.org/sandbox/MPeli/1173936.git/shortlog/refs/heads/7.x-1.x

asespat’s picture

Hi, i installed the module and seems to work

i use it for a shoes shop.

it gives 10 options to the attribute stock, but we need more for all the sizes. And even more if i have to combine the sizes with differents colors

It's me unable to get it? or is still not in the module this options?

Thanks a lot an congratulations for this module , it's a great job

MPeli’s picture

Hi asespat,

A possibility to define more options will come up if you try to define all 10 options and click submit button. It is possible to define unlimited options.

Martin.

asespat’s picture

Thanks i didn't realized it works great.

klausi’s picture

Status: Needs review » Needs work
  • lines in README.txt should not exceed 80 characters, see also http://drupal.org/node/447604
  • uc_attribute_stock.css: indentation errors, see http://drupal.org/node/302199
  • "#print_r($data);": Remove all debug statements from your code
  • uc_attribute_stock_form(): you are preparing a huge db_query() there, but is it ever used later?
  • "$result = $query->execute();": any particular reason why the query is defined earlier, then you do something different, then you execute the query? Code that belongs together should be together.
  • All functions should have doc blocks, see http://drupal.org/node/1354#functions
  • "$query_select": that variable is defined, but never used later. Please remove all unused variables.
  • theme_uc_attribute_stock_form(): empty function, remove it.
  • "db_query("(SELECT * FROM {uc_attribute_stock} AS uas WHERE uas.nid = :nid)"": use db_select() here.
  • "foreach ($value['atributes'] as $aid => $oid) {": indentation error, the body of the loop should onl ybe indented 2 spaces more.
  • "$re="/^(uc_product_add_to_cart_form_)(.*)$/";": there should be a space before and after "=". Did coder not detect this?
MPeli’s picture

uc_attribute_stock.css: indentation errors, see http://drupal.org/node/302199

The file uc_attribute_stock.css has been deleted.

uc_attribute_stock_form(): you are preparing a huge db_query() there, but is it ever used later?

foreach ($result as $prod_attr) {
    $attribute_names .= '<th>' . check_plain($prod_attr->name) . '</th>';
    $attribute_ids[] = $prod_attr->aid;
 }

All the other points should be fixed. Thank you, Martin.

MPeli’s picture

Status: Needs work » Needs review
klausi’s picture

Status: Needs review » Needs work

Review of the 7.x-1.x branch:

  • Run coder to check your style, some issues were found (please check the Drupal coding standards):
    Severity minor, Drupal Commenting Standards, Internationalization, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards
    
    sites/all/modules/pareview_temp/test_candidate/uc_attribute_stock.module:
     +10: [minor] There should be no trailing spaces
     +24: [minor] There should be no trailing spaces
     +31: [minor] There should be no trailing spaces
     +41: [minor] There should be no trailing spaces
     +97: [minor] There should be no trailing spaces
     +101: [minor] There should be no trailing spaces
     +105: [minor] There should be no trailing spaces
     +107: [minor] There should be no trailing spaces
     +124: [minor] There should be no trailing spaces
     +143: [minor] There should be no trailing spaces
     +161: [minor] There should be no trailing spaces
     +178: [minor] There should be no trailing spaces
     +180: [minor] There should be no trailing spaces
     +182: [minor] There should be no trailing spaces
     +187: [minor] There should be no trailing spaces
     +191: [minor] There should be no trailing spaces
     +198: [minor] There should be no trailing spaces
     +200: [minor] There should be no trailing spaces
     +203: [minor] There should be no trailing spaces
     +206: [minor] There should be no trailing spaces
     +211: [minor] There should be no trailing spaces
     +219: [minor] There should be no trailing spaces
     +229: [minor] There should be no trailing spaces
     +237: [minor] There should be no trailing spaces
     +256: [minor] There should be no trailing spaces
     +259: [minor] There should be no trailing spaces
     +262: [minor] There should be no trailing spaces
     +264: [minor] There should be no trailing spaces
     +271: [minor] There should be no trailing spaces
     +273: [minor] There should be no trailing spaces
     +277: [minor] There should be no trailing spaces
     +282: [minor] There should be no trailing spaces
     +284: [minor] There should be no trailing spaces
     +285: [minor] There should be no trailing spaces
     +304: [minor] There should be no trailing spaces
     +314: [minor] There should be no trailing spaces
     +317: [minor] There should be no trailing spaces
     +319: [minor] There should be no trailing spaces
     +320: [minor] There should be no trailing spaces
     +327: [minor] There should be no trailing spaces
    
    sites/all/modules/pareview_temp/test_candidate/uc_attribute_stock.install:
     +27: [minor] There should be no trailing spaces
     +35: [minor] There should be no trailing spaces
     +71: [minor] There should be no trailing spaces
    
    sites/all/modules/pareview_temp/test_candidate/uc_attribute_stock.admin.inc:
     +6: [minor] There should be no trailing spaces
     +33: [minor] There should be no trailing spaces
     +154: [minor] There should be no trailing spaces
     +211: [minor] When labelling buttons, make it clear what the button does, "Submit" is too generic.
     +238: [minor] There should be no trailing spaces
     +242: [minor] There should be no trailing spaces
     +278: [minor] There should be no trailing spaces
     +281: [minor] There should be no trailing spaces
     +294: [minor] There should be no trailing spaces
     +297: [minor] When labelling buttons, make it clear what the button does, "Submit" is too generic.
    
    Status Messages:
     Coder found 1 projects, 3 files, 53 minor warnings, 0 warnings were flagged to be ignored
    
  • There should be a space before and after operators like ==, ===, && and ||. See http://drupal.org/node/318#controlstruct
    uc_attribute_stock.module:163:        if ($item['combination'] == $u['attributes'] && $item['stock'] < $value['qty'] && $item['stock'] > 0 && $item['unlimited'] == 0&& ($form_state['clicked_button']['#name'] != 'remove-' . $key)) {
    

This automated report was generated with PAReview.sh, your friendly project application review script. Please report any bugs to klausi.

MPeli’s picture

StatusFileSize
new59.12 KB

Thanks, I will try to fix all warning.

I ran coder to check all errors. However, it gives me different output then to you.

klausi’s picture

Make sure that you turn the "minor" setting on.

MPeli’s picture

See the screenshot. Is says

Coder found 1 projects, 3 files, 0 warnings were flagged to be ignored
Coder found 1 projects, 3 files, 3 minor warnings, 0 warnings were flagged to be ignored

The "minor" is checked.

Thank you.

MPeli’s picture

Status: Needs work » Needs review

I have deleted all trailing spaces and other minor issues.

klausi’s picture

Status: Needs review » Needs work

Review of the 7.x-1.x branch:

  • Run coder to check your style, some issues were found (please check the Drupal coding standards):
    Severity minor, Drupal Commenting Standards, Internationalization, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards
    
    sites/all/modules/pareview_temp/test_candidate/uc_attribute_stock.install:
     +27: [minor] There should be no trailing spaces
     +35: [minor] There should be no trailing spaces
     +71: [minor] There should be no trailing spaces
    
    sites/all/modules/pareview_temp/test_candidate/uc_attribute_stock.admin.inc:
     +33: [minor] There should be no trailing spaces
     +206: [minor] When labelling buttons, make it clear what the button does, "Submit" is too generic.
     +273: [minor] There should be no trailing spaces
     +276: [minor] There should be no trailing spaces
     +292: [minor] When labelling buttons, make it clear what the button does, "Submit" is too generic.
    
    Status Messages:
     Coder found 1 projects, 3 files, 8 minor warnings, 0 warnings were flagged to be ignored
    

This automated report was generated with PAReview.sh, your friendly project application review script. Please report any bugs to klausi.

manual review:

  • README.txt does not seem to be complete? See http://drupal.org/node/447604
  • uc_attribute_stock_schema(): do not run database descriptions through t(), creates only overhead for translators.
  • uc_attribute_stock_settings_form(): why don't you use system_settings_form() here? then you would not need the submit function for it, because it saves the variables automatically. And I don't understand the logic in there, why do you load the variable twice?
  • uc_attribute_stock_form_submit(): you should also use db_select() in there.
  • uc_attribute_stock_form(): this function is 200 lines long and does not contain a single comment. I have no idea what you are doing in there. short variables lik $x, $k, $v make the code hard to read, better use speaking variables like $stock_index, $stock_counter, $product_key etc.
MPeli’s picture

Status: Needs work » Needs review

Hi,

thank you for the review. I have fixed all the issues. Coder returns "Coder found 1 projects, 3 files, 0 warnings were flagged to be ignored". How come you get different output then me?

Martin.

klausi’s picture

Status: Needs review » Needs work

You need to enable the "minor" setting in Coder.

Review of the 7.x-1.x branch:

  • ./uc_attribute_stock.module: all functions should be prefixed with your module/theme name to avoid name clashes. See http://drupal.org/node/318#naming
    function uc_cart_view_form_validate($form, &$form_state) {
    function uc_cart_checkout_review_form_validate($form, &$form_state) {
    

This automated report was generated with PAReview.sh, your friendly project application review script. Please report any bugs to klausi.

manual review:

  • "/* Gets all attributes related to the node */": use "//" style comments instead of "/** ... */" in function bodies.
  • uc_attribute_stock_form(): why do you need $aid? You do not overwrite $key, so why don't you use it directly?
  • README.txt is still incomplete

I think this is nearly ready.

MPeli’s picture

Hi,

I fixed all the issues. I always set Coder to "minor". However, it does not return all problems. Thank you, Martin.

MPeli’s picture

Status: Needs work » Needs review
klausi’s picture

Status: Needs review » Reviewed & tested by the community

Great, RTBC for me.

greggles’s picture

Why is there no access arguments or access callback on admin/store/settings/stock/settings?

Seems ready to go to me as well, just curious.

MPeli’s picture

Access callback, page callback, and theme callback will be inherited from admin/store/settings/stock which is defined in uc_stock.module

http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...

I see you have a lot of experience with Drupal. Should I add access callback on admin/store/settings/stock/settings?

Thanks.

greggles’s picture

Status: Reviewed & tested by the community » Fixed

I'm somewhat wary of the inheritance system since it's easy for someone to alter the parent and not realize the unintended consequence on the child. Thanks for the explanation of your intent there.

Thanks for your contribution, MPeli! Welcome to the community of project contributors on drupal.org.

I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

As you continue to work on your module, keep in minde: Commit messages - providing history and credit and Release naming conventions.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

added name of the module and the indended Drupal core version